documentation.d.ts 3.6 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831
  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. * User defined information that will be sent to observers
  95. */
  96. userInfo?: any;
  97. }
  98. /**
  99. * Represent an Observer registered to a given Observable object.
  100. */
  101. export class Observer<T> {
  102. /**
  103. * Defines the callback to call when the observer is notified
  104. */
  105. callback: (eventData: T, eventState: EventState) => void;
  106. /**
  107. * Defines the mask of the observer (used to filter notifications)
  108. */
  109. mask: number;
  110. /**
  111. * Defines the current scope used to restore the JS context
  112. */
  113. scope: any;
  114. /** @hidden */
  115. _willBeUnregistered: boolean;
  116. /**
  117. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  118. */
  119. unregisterOnNextCall: boolean;
  120. /**
  121. * Creates a new observer
  122. * @param callback defines the callback to call when the observer is notified
  123. * @param mask defines the mask of the observer (used to filter notifications)
  124. * @param scope defines the current scope used to restore the JS context
  125. */
  126. constructor(
  127. /**
  128. * Defines the callback to call when the observer is notified
  129. */
  130. callback: (eventData: T, eventState: EventState) => void,
  131. /**
  132. * Defines the mask of the observer (used to filter notifications)
  133. */
  134. mask: number,
  135. /**
  136. * Defines the current scope used to restore the JS context
  137. */
  138. scope?: any);
  139. }
  140. /**
  141. * Represent a list of observers registered to multiple Observables object.
  142. */
  143. export class MultiObserver<T> {
  144. private _observers;
  145. private _observables;
  146. /**
  147. * Release associated resources
  148. */
  149. dispose(): void;
  150. /**
  151. * Raise a callback when one of the observable will notify
  152. * @param observables defines a list of observables to watch
  153. * @param callback defines the callback to call on notification
  154. * @param mask defines the mask used to filter notifications
  155. * @param scope defines the current scope used to restore the JS context
  156. * @returns the new MultiObserver
  157. */
  158. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  159. }
  160. /**
  161. * The Observable class is a simple implementation of the Observable pattern.
  162. *
  163. * 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.
  164. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  165. * 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).
  166. * 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.
  167. */
  168. export class Observable<T> {
  169. private _observers;
  170. private _eventState;
  171. private _onObserverAdded;
  172. /**
  173. * Gets the list of observers
  174. */
  175. get observers(): Array<Observer<T>>;
  176. /**
  177. * Creates a new observable
  178. * @param onObserverAdded defines a callback to call when a new observer is added
  179. */
  180. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  181. /**
  182. * Create a new Observer with the specified callback
  183. * @param callback the callback that will be executed for that Observer
  184. * @param mask the mask used to filter observers
  185. * @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.
  186. * @param scope optional scope for the callback to be called from
  187. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  188. * @returns the new observer created for the callback
  189. */
  190. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  191. /**
  192. * Create a new Observer with the specified callback and unregisters after the next notification
  193. * @param callback the callback that will be executed for that Observer
  194. * @returns the new observer created for the callback
  195. */
  196. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  197. /**
  198. * Remove an Observer from the Observable object
  199. * @param observer the instance of the Observer to remove
  200. * @returns false if it doesn't belong to this Observable
  201. */
  202. remove(observer: Nullable<Observer<T>>): boolean;
  203. /**
  204. * Remove a callback from the Observable object
  205. * @param callback the callback to remove
  206. * @param scope optional scope. If used only the callbacks with this scope will be removed
  207. * @returns false if it doesn't belong to this Observable
  208. */
  209. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  210. private _deferUnregister;
  211. private _remove;
  212. /**
  213. * Moves the observable to the top of the observer list making it get called first when notified
  214. * @param observer the observer to move
  215. */
  216. makeObserverTopPriority(observer: Observer<T>): void;
  217. /**
  218. * Moves the observable to the bottom of the observer list making it get called last when notified
  219. * @param observer the observer to move
  220. */
  221. makeObserverBottomPriority(observer: Observer<T>): void;
  222. /**
  223. * Notify all Observers by calling their respective callback with the given data
  224. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  225. * @param eventData defines the data to send to all observers
  226. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  227. * @param target defines the original target of the state
  228. * @param currentTarget defines the current target of the state
  229. * @param userInfo defines any user info to send to observers
  230. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  231. */
  232. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): boolean;
  233. /**
  234. * Calling this will execute each callback, expecting it to be a promise or return a value.
  235. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  236. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  237. * and it is crucial that all callbacks will be executed.
  238. * The order of the callbacks is kept, callbacks are not executed parallel.
  239. *
  240. * @param eventData The data to be sent to each callback
  241. * @param mask is used to filter observers defaults to -1
  242. * @param target defines the callback target (see EventState)
  243. * @param currentTarget defines he current object in the bubbling phase
  244. * @param userInfo defines any user info to send to observers
  245. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  246. */
  247. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any, userInfo?: any): Promise<T>;
  248. /**
  249. * Notify a specific observer
  250. * @param observer defines the observer to notify
  251. * @param eventData defines the data to be sent to each callback
  252. * @param mask is used to filter observers defaults to -1
  253. */
  254. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  255. /**
  256. * Gets a boolean indicating if the observable has at least one observer
  257. * @returns true is the Observable has at least one Observer registered
  258. */
  259. hasObservers(): boolean;
  260. /**
  261. * Clear the list of observers
  262. */
  263. clear(): void;
  264. /**
  265. * Clone the current observable
  266. * @returns a new observable
  267. */
  268. clone(): Observable<T>;
  269. /**
  270. * Does this observable handles observer registered with a given mask
  271. * @param mask defines the mask to be tested
  272. * @return whether or not one observer registered with the given mask is handeled
  273. **/
  274. hasSpecificMask(mask?: number): boolean;
  275. }
  276. }
  277. declare module BABYLON {
  278. /**
  279. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  280. * Babylon.js
  281. */
  282. export class DomManagement {
  283. /**
  284. * Checks if the window object exists
  285. * @returns true if the window object exists
  286. */
  287. static IsWindowObjectExist(): boolean;
  288. /**
  289. * Checks if the navigator object exists
  290. * @returns true if the navigator object exists
  291. */
  292. static IsNavigatorAvailable(): boolean;
  293. /**
  294. * Check if the document object exists
  295. * @returns true if the document object exists
  296. */
  297. static IsDocumentAvailable(): boolean;
  298. /**
  299. * Extracts text content from a DOM element hierarchy
  300. * @param element defines the root element
  301. * @returns a string
  302. */
  303. static GetDOMTextContent(element: HTMLElement): string;
  304. }
  305. }
  306. declare module BABYLON {
  307. /**
  308. * Logger used througouht the application to allow configuration of
  309. * the log level required for the messages.
  310. */
  311. export class Logger {
  312. /**
  313. * No log
  314. */
  315. static readonly NoneLogLevel: number;
  316. /**
  317. * Only message logs
  318. */
  319. static readonly MessageLogLevel: number;
  320. /**
  321. * Only warning logs
  322. */
  323. static readonly WarningLogLevel: number;
  324. /**
  325. * Only error logs
  326. */
  327. static readonly ErrorLogLevel: number;
  328. /**
  329. * All logs
  330. */
  331. static readonly AllLogLevel: number;
  332. private static _LogCache;
  333. /**
  334. * Gets a value indicating the number of loading errors
  335. * @ignorenaming
  336. */
  337. static errorsCount: number;
  338. /**
  339. * Callback called when a new log is added
  340. */
  341. static OnNewCacheEntry: (entry: string) => void;
  342. private static _AddLogEntry;
  343. private static _FormatMessage;
  344. private static _LogDisabled;
  345. private static _LogEnabled;
  346. private static _WarnDisabled;
  347. private static _WarnEnabled;
  348. private static _ErrorDisabled;
  349. private static _ErrorEnabled;
  350. /**
  351. * Log a message to the console
  352. */
  353. static Log: (message: string) => void;
  354. /**
  355. * Write a warning message to the console
  356. */
  357. static Warn: (message: string) => void;
  358. /**
  359. * Write an error message to the console
  360. */
  361. static Error: (message: string) => void;
  362. /**
  363. * Gets current log cache (list of logs)
  364. */
  365. static get LogCache(): string;
  366. /**
  367. * Clears the log cache
  368. */
  369. static ClearLogCache(): void;
  370. /**
  371. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  372. */
  373. static set LogLevels(level: number);
  374. }
  375. }
  376. declare module BABYLON {
  377. /** @hidden */
  378. export class _TypeStore {
  379. /** @hidden */
  380. static RegisteredTypes: {
  381. [key: string]: Object;
  382. };
  383. /** @hidden */
  384. static GetClass(fqdn: string): any;
  385. }
  386. }
  387. declare module BABYLON {
  388. /**
  389. * Helper to manipulate strings
  390. */
  391. export class StringTools {
  392. /**
  393. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  394. * @param str Source string
  395. * @param suffix Suffix to search for in the source string
  396. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  397. */
  398. static EndsWith(str: string, suffix: string): boolean;
  399. /**
  400. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  401. * @param str Source string
  402. * @param suffix Suffix to search for in the source string
  403. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  404. */
  405. static StartsWith(str: string, suffix: string): boolean;
  406. /**
  407. * Decodes a buffer into a string
  408. * @param buffer The buffer to decode
  409. * @returns The decoded string
  410. */
  411. static Decode(buffer: Uint8Array | Uint16Array): string;
  412. /**
  413. * Encode a buffer to a base64 string
  414. * @param buffer defines the buffer to encode
  415. * @returns the encoded string
  416. */
  417. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  418. /**
  419. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  420. * @param num the number to convert and pad
  421. * @param length the expected length of the string
  422. * @returns the padded string
  423. */
  424. static PadNumber(num: number, length: number): string;
  425. }
  426. }
  427. declare module BABYLON {
  428. /**
  429. * Class containing a set of static utilities functions for deep copy.
  430. */
  431. export class DeepCopier {
  432. /**
  433. * Tries to copy an object by duplicating every property
  434. * @param source defines the source object
  435. * @param destination defines the target object
  436. * @param doNotCopyList defines a list of properties to avoid
  437. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  438. */
  439. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  440. }
  441. }
  442. declare module BABYLON {
  443. /**
  444. * Class containing a set of static utilities functions for precision date
  445. */
  446. export class PrecisionDate {
  447. /**
  448. * Gets either window.performance.now() if supported or Date.now() else
  449. */
  450. static get Now(): number;
  451. }
  452. }
  453. declare module BABYLON {
  454. /** @hidden */
  455. export class _DevTools {
  456. static WarnImport(name: string): string;
  457. }
  458. }
  459. declare module BABYLON {
  460. /**
  461. * Interface used to define the mechanism to get data from the network
  462. */
  463. export interface IWebRequest {
  464. /**
  465. * Returns client's response url
  466. */
  467. responseURL: string;
  468. /**
  469. * Returns client's status
  470. */
  471. status: number;
  472. /**
  473. * Returns client's status as a text
  474. */
  475. statusText: string;
  476. }
  477. }
  478. declare module BABYLON {
  479. /**
  480. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  481. */
  482. export class WebRequest implements IWebRequest {
  483. private _xhr;
  484. /**
  485. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  486. * i.e. when loading files, where the server/service expects an Authorization header
  487. */
  488. static CustomRequestHeaders: {
  489. [key: string]: string;
  490. };
  491. /**
  492. * Add callback functions in this array to update all the requests before they get sent to the network
  493. */
  494. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  495. private _injectCustomRequestHeaders;
  496. /**
  497. * Gets or sets a function to be called when loading progress changes
  498. */
  499. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  500. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  501. /**
  502. * Returns client's state
  503. */
  504. get readyState(): number;
  505. /**
  506. * Returns client's status
  507. */
  508. get status(): number;
  509. /**
  510. * Returns client's status as a text
  511. */
  512. get statusText(): string;
  513. /**
  514. * Returns client's response
  515. */
  516. get response(): any;
  517. /**
  518. * Returns client's response url
  519. */
  520. get responseURL(): string;
  521. /**
  522. * Returns client's response as text
  523. */
  524. get responseText(): string;
  525. /**
  526. * Gets or sets the expected response type
  527. */
  528. get responseType(): XMLHttpRequestResponseType;
  529. set responseType(value: XMLHttpRequestResponseType);
  530. /** @hidden */
  531. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  532. /** @hidden */
  533. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  534. /**
  535. * Cancels any network activity
  536. */
  537. abort(): void;
  538. /**
  539. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  540. * @param body defines an optional request body
  541. */
  542. send(body?: Document | BodyInit | null): void;
  543. /**
  544. * Sets the request method, request URL
  545. * @param method defines the method to use (GET, POST, etc..)
  546. * @param url defines the url to connect with
  547. */
  548. open(method: string, url: string): void;
  549. /**
  550. * Sets the value of a request header.
  551. * @param name The name of the header whose value is to be set
  552. * @param value The value to set as the body of the header
  553. */
  554. setRequestHeader(name: string, value: string): void;
  555. /**
  556. * Get the string containing the text of a particular header's value.
  557. * @param name The name of the header
  558. * @returns The string containing the text of the given header name
  559. */
  560. getResponseHeader(name: string): Nullable<string>;
  561. }
  562. }
  563. declare module BABYLON {
  564. /**
  565. * File request interface
  566. */
  567. export interface IFileRequest {
  568. /**
  569. * Raised when the request is complete (success or error).
  570. */
  571. onCompleteObservable: Observable<IFileRequest>;
  572. /**
  573. * Aborts the request for a file.
  574. */
  575. abort: () => void;
  576. }
  577. }
  578. declare module BABYLON {
  579. /**
  580. * Define options used to create a render target texture
  581. */
  582. export class RenderTargetCreationOptions {
  583. /**
  584. * Specifies is mipmaps must be generated
  585. */
  586. generateMipMaps?: boolean;
  587. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  588. generateDepthBuffer?: boolean;
  589. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  590. generateStencilBuffer?: boolean;
  591. /** Defines texture type (int by default) */
  592. type?: number;
  593. /** Defines sampling mode (trilinear by default) */
  594. samplingMode?: number;
  595. /** Defines format (RGBA by default) */
  596. format?: number;
  597. }
  598. }
  599. declare module BABYLON {
  600. /** Defines the cross module used constants to avoid circular dependncies */
  601. export class Constants {
  602. /** Defines that alpha blending is disabled */
  603. static readonly ALPHA_DISABLE: number;
  604. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  605. static readonly ALPHA_ADD: number;
  606. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  607. static readonly ALPHA_COMBINE: number;
  608. /** Defines that alpha blending is DEST - SRC * DEST */
  609. static readonly ALPHA_SUBTRACT: number;
  610. /** Defines that alpha blending is SRC * DEST */
  611. static readonly ALPHA_MULTIPLY: number;
  612. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  613. static readonly ALPHA_MAXIMIZED: number;
  614. /** Defines that alpha blending is SRC + DEST */
  615. static readonly ALPHA_ONEONE: number;
  616. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  617. static readonly ALPHA_PREMULTIPLIED: number;
  618. /**
  619. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  620. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  621. */
  622. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  623. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  624. static readonly ALPHA_INTERPOLATE: number;
  625. /**
  626. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  627. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  628. */
  629. static readonly ALPHA_SCREENMODE: number;
  630. /**
  631. * Defines that alpha blending is SRC + DST
  632. * Alpha will be set to SRC ALPHA + DST ALPHA
  633. */
  634. static readonly ALPHA_ONEONE_ONEONE: number;
  635. /**
  636. * Defines that alpha blending is SRC * DST ALPHA + DST
  637. * Alpha will be set to 0
  638. */
  639. static readonly ALPHA_ALPHATOCOLOR: number;
  640. /**
  641. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  642. */
  643. static readonly ALPHA_REVERSEONEMINUS: number;
  644. /**
  645. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  646. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  647. */
  648. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  649. /**
  650. * Defines that alpha blending is SRC + DST
  651. * Alpha will be set to SRC ALPHA
  652. */
  653. static readonly ALPHA_ONEONE_ONEZERO: number;
  654. /**
  655. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  656. * Alpha will be set to DST ALPHA
  657. */
  658. static readonly ALPHA_EXCLUSION: number;
  659. /** Defines that alpha blending equation a SUM */
  660. static readonly ALPHA_EQUATION_ADD: number;
  661. /** Defines that alpha blending equation a SUBSTRACTION */
  662. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  663. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  664. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  665. /** Defines that alpha blending equation a MAX operation */
  666. static readonly ALPHA_EQUATION_MAX: number;
  667. /** Defines that alpha blending equation a MIN operation */
  668. static readonly ALPHA_EQUATION_MIN: number;
  669. /**
  670. * Defines that alpha blending equation a DARKEN operation:
  671. * It takes the min of the src and sums the alpha channels.
  672. */
  673. static readonly ALPHA_EQUATION_DARKEN: number;
  674. /** Defines that the ressource is not delayed*/
  675. static readonly DELAYLOADSTATE_NONE: number;
  676. /** Defines that the ressource was successfully delay loaded */
  677. static readonly DELAYLOADSTATE_LOADED: number;
  678. /** Defines that the ressource is currently delay loading */
  679. static readonly DELAYLOADSTATE_LOADING: number;
  680. /** Defines that the ressource is delayed and has not started loading */
  681. static readonly DELAYLOADSTATE_NOTLOADED: number;
  682. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  683. static readonly NEVER: number;
  684. /** 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 */
  685. static readonly ALWAYS: number;
  686. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  687. static readonly LESS: number;
  688. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  689. static readonly EQUAL: number;
  690. /** 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 */
  691. static readonly LEQUAL: number;
  692. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  693. static readonly GREATER: number;
  694. /** 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 */
  695. static readonly GEQUAL: number;
  696. /** 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 */
  697. static readonly NOTEQUAL: number;
  698. /** Passed to stencilOperation to specify that stencil value must be kept */
  699. static readonly KEEP: number;
  700. /** Passed to stencilOperation to specify that stencil value must be replaced */
  701. static readonly REPLACE: number;
  702. /** Passed to stencilOperation to specify that stencil value must be incremented */
  703. static readonly INCR: number;
  704. /** Passed to stencilOperation to specify that stencil value must be decremented */
  705. static readonly DECR: number;
  706. /** Passed to stencilOperation to specify that stencil value must be inverted */
  707. static readonly INVERT: number;
  708. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  709. static readonly INCR_WRAP: number;
  710. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  711. static readonly DECR_WRAP: number;
  712. /** Texture is not repeating outside of 0..1 UVs */
  713. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  714. /** Texture is repeating outside of 0..1 UVs */
  715. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  716. /** Texture is repeating and mirrored */
  717. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  718. /** ALPHA */
  719. static readonly TEXTUREFORMAT_ALPHA: number;
  720. /** LUMINANCE */
  721. static readonly TEXTUREFORMAT_LUMINANCE: number;
  722. /** LUMINANCE_ALPHA */
  723. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  724. /** RGB */
  725. static readonly TEXTUREFORMAT_RGB: number;
  726. /** RGBA */
  727. static readonly TEXTUREFORMAT_RGBA: number;
  728. /** RED */
  729. static readonly TEXTUREFORMAT_RED: number;
  730. /** RED (2nd reference) */
  731. static readonly TEXTUREFORMAT_R: number;
  732. /** RG */
  733. static readonly TEXTUREFORMAT_RG: number;
  734. /** RED_INTEGER */
  735. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  736. /** RED_INTEGER (2nd reference) */
  737. static readonly TEXTUREFORMAT_R_INTEGER: number;
  738. /** RG_INTEGER */
  739. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  740. /** RGB_INTEGER */
  741. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  742. /** RGBA_INTEGER */
  743. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  744. /** UNSIGNED_BYTE */
  745. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  746. /** UNSIGNED_BYTE (2nd reference) */
  747. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  748. /** FLOAT */
  749. static readonly TEXTURETYPE_FLOAT: number;
  750. /** HALF_FLOAT */
  751. static readonly TEXTURETYPE_HALF_FLOAT: number;
  752. /** BYTE */
  753. static readonly TEXTURETYPE_BYTE: number;
  754. /** SHORT */
  755. static readonly TEXTURETYPE_SHORT: number;
  756. /** UNSIGNED_SHORT */
  757. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  758. /** INT */
  759. static readonly TEXTURETYPE_INT: number;
  760. /** UNSIGNED_INT */
  761. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  762. /** UNSIGNED_SHORT_4_4_4_4 */
  763. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  764. /** UNSIGNED_SHORT_5_5_5_1 */
  765. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  766. /** UNSIGNED_SHORT_5_6_5 */
  767. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  768. /** UNSIGNED_INT_2_10_10_10_REV */
  769. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  770. /** UNSIGNED_INT_24_8 */
  771. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  772. /** UNSIGNED_INT_10F_11F_11F_REV */
  773. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  774. /** UNSIGNED_INT_5_9_9_9_REV */
  775. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  776. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  777. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  778. /** nearest is mag = nearest and min = nearest and no mip */
  779. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  780. /** mag = nearest and min = nearest and mip = none */
  781. static readonly TEXTURE_NEAREST_NEAREST: number;
  782. /** Bilinear is mag = linear and min = linear and no mip */
  783. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  784. /** mag = linear and min = linear and mip = none */
  785. static readonly TEXTURE_LINEAR_LINEAR: number;
  786. /** Trilinear is mag = linear and min = linear and mip = linear */
  787. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  788. /** Trilinear is mag = linear and min = linear and mip = linear */
  789. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  790. /** mag = nearest and min = nearest and mip = nearest */
  791. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  792. /** mag = nearest and min = linear and mip = nearest */
  793. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  794. /** mag = nearest and min = linear and mip = linear */
  795. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  796. /** mag = nearest and min = linear and mip = none */
  797. static readonly TEXTURE_NEAREST_LINEAR: number;
  798. /** nearest is mag = nearest and min = nearest and mip = linear */
  799. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  800. /** mag = linear and min = nearest and mip = nearest */
  801. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  802. /** mag = linear and min = nearest and mip = linear */
  803. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  804. /** Bilinear is mag = linear and min = linear and mip = nearest */
  805. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  806. /** mag = linear and min = nearest and mip = none */
  807. static readonly TEXTURE_LINEAR_NEAREST: number;
  808. /** Explicit coordinates mode */
  809. static readonly TEXTURE_EXPLICIT_MODE: number;
  810. /** Spherical coordinates mode */
  811. static readonly TEXTURE_SPHERICAL_MODE: number;
  812. /** Planar coordinates mode */
  813. static readonly TEXTURE_PLANAR_MODE: number;
  814. /** Cubic coordinates mode */
  815. static readonly TEXTURE_CUBIC_MODE: number;
  816. /** Projection coordinates mode */
  817. static readonly TEXTURE_PROJECTION_MODE: number;
  818. /** Skybox coordinates mode */
  819. static readonly TEXTURE_SKYBOX_MODE: number;
  820. /** Inverse Cubic coordinates mode */
  821. static readonly TEXTURE_INVCUBIC_MODE: number;
  822. /** Equirectangular coordinates mode */
  823. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  824. /** Equirectangular Fixed coordinates mode */
  825. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  826. /** Equirectangular Fixed Mirrored coordinates mode */
  827. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  828. /** Offline (baking) quality for texture filtering */
  829. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  830. /** High quality for texture filtering */
  831. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  832. /** Medium quality for texture filtering */
  833. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  834. /** Low quality for texture filtering */
  835. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  836. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  837. static readonly SCALEMODE_FLOOR: number;
  838. /** Defines that texture rescaling will look for the nearest power of 2 size */
  839. static readonly SCALEMODE_NEAREST: number;
  840. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  841. static readonly SCALEMODE_CEILING: number;
  842. /**
  843. * The dirty texture flag value
  844. */
  845. static readonly MATERIAL_TextureDirtyFlag: number;
  846. /**
  847. * The dirty light flag value
  848. */
  849. static readonly MATERIAL_LightDirtyFlag: number;
  850. /**
  851. * The dirty fresnel flag value
  852. */
  853. static readonly MATERIAL_FresnelDirtyFlag: number;
  854. /**
  855. * The dirty attribute flag value
  856. */
  857. static readonly MATERIAL_AttributesDirtyFlag: number;
  858. /**
  859. * The dirty misc flag value
  860. */
  861. static readonly MATERIAL_MiscDirtyFlag: number;
  862. /**
  863. * The dirty prepass flag value
  864. */
  865. static readonly MATERIAL_PrePassDirtyFlag: number;
  866. /**
  867. * The all dirty flag value
  868. */
  869. static readonly MATERIAL_AllDirtyFlag: number;
  870. /**
  871. * Returns the triangle fill mode
  872. */
  873. static readonly MATERIAL_TriangleFillMode: number;
  874. /**
  875. * Returns the wireframe mode
  876. */
  877. static readonly MATERIAL_WireFrameFillMode: number;
  878. /**
  879. * Returns the point fill mode
  880. */
  881. static readonly MATERIAL_PointFillMode: number;
  882. /**
  883. * Returns the point list draw mode
  884. */
  885. static readonly MATERIAL_PointListDrawMode: number;
  886. /**
  887. * Returns the line list draw mode
  888. */
  889. static readonly MATERIAL_LineListDrawMode: number;
  890. /**
  891. * Returns the line loop draw mode
  892. */
  893. static readonly MATERIAL_LineLoopDrawMode: number;
  894. /**
  895. * Returns the line strip draw mode
  896. */
  897. static readonly MATERIAL_LineStripDrawMode: number;
  898. /**
  899. * Returns the triangle strip draw mode
  900. */
  901. static readonly MATERIAL_TriangleStripDrawMode: number;
  902. /**
  903. * Returns the triangle fan draw mode
  904. */
  905. static readonly MATERIAL_TriangleFanDrawMode: number;
  906. /**
  907. * Stores the clock-wise side orientation
  908. */
  909. static readonly MATERIAL_ClockWiseSideOrientation: number;
  910. /**
  911. * Stores the counter clock-wise side orientation
  912. */
  913. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  914. /**
  915. * Nothing
  916. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  917. */
  918. static readonly ACTION_NothingTrigger: number;
  919. /**
  920. * On pick
  921. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  922. */
  923. static readonly ACTION_OnPickTrigger: number;
  924. /**
  925. * On left pick
  926. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  927. */
  928. static readonly ACTION_OnLeftPickTrigger: number;
  929. /**
  930. * On right pick
  931. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  932. */
  933. static readonly ACTION_OnRightPickTrigger: number;
  934. /**
  935. * On center pick
  936. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  937. */
  938. static readonly ACTION_OnCenterPickTrigger: number;
  939. /**
  940. * On pick down
  941. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  942. */
  943. static readonly ACTION_OnPickDownTrigger: number;
  944. /**
  945. * On double pick
  946. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  947. */
  948. static readonly ACTION_OnDoublePickTrigger: number;
  949. /**
  950. * On pick up
  951. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  952. */
  953. static readonly ACTION_OnPickUpTrigger: number;
  954. /**
  955. * On pick out.
  956. * This trigger will only be raised if you also declared a OnPickDown
  957. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  958. */
  959. static readonly ACTION_OnPickOutTrigger: number;
  960. /**
  961. * On long press
  962. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  963. */
  964. static readonly ACTION_OnLongPressTrigger: number;
  965. /**
  966. * On pointer over
  967. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  968. */
  969. static readonly ACTION_OnPointerOverTrigger: number;
  970. /**
  971. * On pointer out
  972. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  973. */
  974. static readonly ACTION_OnPointerOutTrigger: number;
  975. /**
  976. * On every frame
  977. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  978. */
  979. static readonly ACTION_OnEveryFrameTrigger: number;
  980. /**
  981. * On intersection enter
  982. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  983. */
  984. static readonly ACTION_OnIntersectionEnterTrigger: number;
  985. /**
  986. * On intersection exit
  987. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  988. */
  989. static readonly ACTION_OnIntersectionExitTrigger: number;
  990. /**
  991. * On key down
  992. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  993. */
  994. static readonly ACTION_OnKeyDownTrigger: number;
  995. /**
  996. * On key up
  997. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  998. */
  999. static readonly ACTION_OnKeyUpTrigger: number;
  1000. /**
  1001. * Billboard mode will only apply to Y axis
  1002. */
  1003. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  1004. /**
  1005. * Billboard mode will apply to all axes
  1006. */
  1007. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  1008. /**
  1009. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  1010. */
  1011. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  1012. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  1013. * Test order :
  1014. * Is the bounding sphere outside the frustum ?
  1015. * If not, are the bounding box vertices outside the frustum ?
  1016. * It not, then the cullable object is in the frustum.
  1017. */
  1018. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1019. /** Culling strategy : Bounding Sphere Only.
  1020. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1021. * It's also less accurate than the standard because some not visible objects can still be selected.
  1022. * Test : is the bounding sphere outside the frustum ?
  1023. * If not, then the cullable object is in the frustum.
  1024. */
  1025. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1026. /** Culling strategy : Optimistic Inclusion.
  1027. * This in an inclusion test first, then the standard exclusion test.
  1028. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1029. * 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.
  1030. * Anyway, it's as accurate as the standard strategy.
  1031. * Test :
  1032. * Is the cullable object bounding sphere center in the frustum ?
  1033. * If not, apply the default culling strategy.
  1034. */
  1035. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1036. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1037. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1038. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1039. * 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.
  1040. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1041. * Test :
  1042. * Is the cullable object bounding sphere center in the frustum ?
  1043. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1044. */
  1045. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1046. /**
  1047. * No logging while loading
  1048. */
  1049. static readonly SCENELOADER_NO_LOGGING: number;
  1050. /**
  1051. * Minimal logging while loading
  1052. */
  1053. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1054. /**
  1055. * Summary logging while loading
  1056. */
  1057. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1058. /**
  1059. * Detailled logging while loading
  1060. */
  1061. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1062. /**
  1063. * Constant used to retrieve the irradiance texture index in the textures array in the prepass
  1064. * using getIndex(Constants.PREPASS_IRRADIANCE_TEXTURE_TYPE)
  1065. */
  1066. static readonly PREPASS_IRRADIANCE_TEXTURE_TYPE: number;
  1067. /**
  1068. * Constant used to retrieve the position texture index in the textures array in the prepass
  1069. * using getIndex(Constants.PREPASS_POSITION_TEXTURE_INDEX)
  1070. */
  1071. static readonly PREPASS_POSITION_TEXTURE_TYPE: number;
  1072. /**
  1073. * Constant used to retrieve the velocity texture index in the textures array in the prepass
  1074. * using getIndex(Constants.PREPASS_VELOCITY_TEXTURE_INDEX)
  1075. */
  1076. static readonly PREPASS_VELOCITY_TEXTURE_TYPE: number;
  1077. /**
  1078. * Constant used to retrieve the reflectivity texture index in the textures array in the prepass
  1079. * using the getIndex(Constants.PREPASS_REFLECTIVITY_TEXTURE_TYPE)
  1080. */
  1081. static readonly PREPASS_REFLECTIVITY_TEXTURE_TYPE: number;
  1082. /**
  1083. * Constant used to retrieve the lit color texture index in the textures array in the prepass
  1084. * using the getIndex(Constants.PREPASS_COLOR_TEXTURE_TYPE)
  1085. */
  1086. static readonly PREPASS_COLOR_TEXTURE_TYPE: number;
  1087. /**
  1088. * Constant used to retrieve depth + normal index in the textures array in the prepass
  1089. * using the getIndex(Constants.PREPASS_DEPTHNORMAL_TEXTURE_TYPE)
  1090. */
  1091. static readonly PREPASS_DEPTHNORMAL_TEXTURE_TYPE: number;
  1092. /**
  1093. * Constant used to retrieve albedo index in the textures array in the prepass
  1094. * using the getIndex(Constants.PREPASS_ALBEDO_TEXTURE_TYPE)
  1095. */
  1096. static readonly PREPASS_ALBEDO_TEXTURE_TYPE: number;
  1097. }
  1098. }
  1099. declare module BABYLON {
  1100. /**
  1101. * This represents the required contract to create a new type of texture loader.
  1102. */
  1103. export interface IInternalTextureLoader {
  1104. /**
  1105. * Defines wether the loader supports cascade loading the different faces.
  1106. */
  1107. supportCascades: boolean;
  1108. /**
  1109. * This returns if the loader support the current file information.
  1110. * @param extension defines the file extension of the file being loaded
  1111. * @param mimeType defines the optional mime type of the file being loaded
  1112. * @returns true if the loader can load the specified file
  1113. */
  1114. canLoad(extension: string, mimeType?: string): boolean;
  1115. /**
  1116. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1117. * @param data contains the texture data
  1118. * @param texture defines the BabylonJS internal texture
  1119. * @param createPolynomials will be true if polynomials have been requested
  1120. * @param onLoad defines the callback to trigger once the texture is ready
  1121. * @param onError defines the callback to trigger in case of error
  1122. */
  1123. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1124. /**
  1125. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1126. * @param data contains the texture data
  1127. * @param texture defines the BabylonJS internal texture
  1128. * @param callback defines the method to call once ready to upload
  1129. */
  1130. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1131. }
  1132. }
  1133. declare module BABYLON {
  1134. /**
  1135. * Class used to store and describe the pipeline context associated with an effect
  1136. */
  1137. export interface IPipelineContext {
  1138. /**
  1139. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1140. */
  1141. isAsync: boolean;
  1142. /**
  1143. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1144. */
  1145. isReady: boolean;
  1146. /** @hidden */
  1147. _getVertexShaderCode(): string | null;
  1148. /** @hidden */
  1149. _getFragmentShaderCode(): string | null;
  1150. /** @hidden */
  1151. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1152. }
  1153. }
  1154. declare module BABYLON {
  1155. /**
  1156. * Class used to store gfx data (like WebGLBuffer)
  1157. */
  1158. export class DataBuffer {
  1159. /**
  1160. * Gets or sets the number of objects referencing this buffer
  1161. */
  1162. references: number;
  1163. /** Gets or sets the size of the underlying buffer */
  1164. capacity: number;
  1165. /**
  1166. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1167. */
  1168. is32Bits: boolean;
  1169. /**
  1170. * Gets the underlying buffer
  1171. */
  1172. get underlyingResource(): any;
  1173. }
  1174. }
  1175. declare module BABYLON {
  1176. /** @hidden */
  1177. export interface IShaderProcessor {
  1178. attributeProcessor?: (attribute: string) => string;
  1179. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1180. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1181. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1182. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1183. lineProcessor?: (line: string, isFragment: boolean) => string;
  1184. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1185. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1186. }
  1187. }
  1188. declare module BABYLON {
  1189. /** @hidden */
  1190. export interface ProcessingOptions {
  1191. defines: string[];
  1192. indexParameters: any;
  1193. isFragment: boolean;
  1194. shouldUseHighPrecisionShader: boolean;
  1195. supportsUniformBuffers: boolean;
  1196. shadersRepository: string;
  1197. includesShadersStore: {
  1198. [key: string]: string;
  1199. };
  1200. processor?: IShaderProcessor;
  1201. version: string;
  1202. platformName: string;
  1203. lookForClosingBracketForUniformBuffer?: boolean;
  1204. }
  1205. }
  1206. declare module BABYLON {
  1207. /** @hidden */
  1208. export class ShaderCodeNode {
  1209. line: string;
  1210. children: ShaderCodeNode[];
  1211. additionalDefineKey?: string;
  1212. additionalDefineValue?: string;
  1213. isValid(preprocessors: {
  1214. [key: string]: string;
  1215. }): boolean;
  1216. process(preprocessors: {
  1217. [key: string]: string;
  1218. }, options: ProcessingOptions): string;
  1219. }
  1220. }
  1221. declare module BABYLON {
  1222. /** @hidden */
  1223. export class ShaderCodeCursor {
  1224. private _lines;
  1225. lineIndex: number;
  1226. get currentLine(): string;
  1227. get canRead(): boolean;
  1228. set lines(value: string[]);
  1229. }
  1230. }
  1231. declare module BABYLON {
  1232. /** @hidden */
  1233. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1234. process(preprocessors: {
  1235. [key: string]: string;
  1236. }, options: ProcessingOptions): string;
  1237. }
  1238. }
  1239. declare module BABYLON {
  1240. /** @hidden */
  1241. export class ShaderDefineExpression {
  1242. isTrue(preprocessors: {
  1243. [key: string]: string;
  1244. }): boolean;
  1245. private static _OperatorPriority;
  1246. private static _Stack;
  1247. static postfixToInfix(postfix: string[]): string;
  1248. static infixToPostfix(infix: string): string[];
  1249. }
  1250. }
  1251. declare module BABYLON {
  1252. /** @hidden */
  1253. export class ShaderCodeTestNode extends ShaderCodeNode {
  1254. testExpression: ShaderDefineExpression;
  1255. isValid(preprocessors: {
  1256. [key: string]: string;
  1257. }): boolean;
  1258. }
  1259. }
  1260. declare module BABYLON {
  1261. /** @hidden */
  1262. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1263. define: string;
  1264. not: boolean;
  1265. constructor(define: string, not?: boolean);
  1266. isTrue(preprocessors: {
  1267. [key: string]: string;
  1268. }): boolean;
  1269. }
  1270. }
  1271. declare module BABYLON {
  1272. /** @hidden */
  1273. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1274. leftOperand: ShaderDefineExpression;
  1275. rightOperand: ShaderDefineExpression;
  1276. isTrue(preprocessors: {
  1277. [key: string]: string;
  1278. }): boolean;
  1279. }
  1280. }
  1281. declare module BABYLON {
  1282. /** @hidden */
  1283. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1284. leftOperand: ShaderDefineExpression;
  1285. rightOperand: ShaderDefineExpression;
  1286. isTrue(preprocessors: {
  1287. [key: string]: string;
  1288. }): boolean;
  1289. }
  1290. }
  1291. declare module BABYLON {
  1292. /** @hidden */
  1293. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1294. define: string;
  1295. operand: string;
  1296. testValue: string;
  1297. constructor(define: string, operand: string, testValue: string);
  1298. isTrue(preprocessors: {
  1299. [key: string]: string;
  1300. }): boolean;
  1301. }
  1302. }
  1303. declare module BABYLON {
  1304. /**
  1305. * Class used to enable access to offline support
  1306. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1307. */
  1308. export interface IOfflineProvider {
  1309. /**
  1310. * Gets a boolean indicating if scene must be saved in the database
  1311. */
  1312. enableSceneOffline: boolean;
  1313. /**
  1314. * Gets a boolean indicating if textures must be saved in the database
  1315. */
  1316. enableTexturesOffline: boolean;
  1317. /**
  1318. * Open the offline support and make it available
  1319. * @param successCallback defines the callback to call on success
  1320. * @param errorCallback defines the callback to call on error
  1321. */
  1322. open(successCallback: () => void, errorCallback: () => void): void;
  1323. /**
  1324. * Loads an image from the offline support
  1325. * @param url defines the url to load from
  1326. * @param image defines the target DOM image
  1327. */
  1328. loadImage(url: string, image: HTMLImageElement): void;
  1329. /**
  1330. * Loads a file from offline support
  1331. * @param url defines the URL to load from
  1332. * @param sceneLoaded defines a callback to call on success
  1333. * @param progressCallBack defines a callback to call when progress changed
  1334. * @param errorCallback defines a callback to call on error
  1335. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1336. */
  1337. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1338. }
  1339. }
  1340. declare module BABYLON {
  1341. /**
  1342. * Class used to help managing file picking and drag'n'drop
  1343. * File Storage
  1344. */
  1345. export class FilesInputStore {
  1346. /**
  1347. * List of files ready to be loaded
  1348. */
  1349. static FilesToLoad: {
  1350. [key: string]: File;
  1351. };
  1352. }
  1353. }
  1354. declare module BABYLON {
  1355. /**
  1356. * Class used to define a retry strategy when error happens while loading assets
  1357. */
  1358. export class RetryStrategy {
  1359. /**
  1360. * Function used to defines an exponential back off strategy
  1361. * @param maxRetries defines the maximum number of retries (3 by default)
  1362. * @param baseInterval defines the interval between retries
  1363. * @returns the strategy function to use
  1364. */
  1365. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1366. }
  1367. }
  1368. declare module BABYLON {
  1369. /**
  1370. * @ignore
  1371. * Application error to support additional information when loading a file
  1372. */
  1373. export abstract class BaseError extends Error {
  1374. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1375. }
  1376. }
  1377. declare module BABYLON {
  1378. /** @ignore */
  1379. export class LoadFileError extends BaseError {
  1380. request?: WebRequest;
  1381. file?: File;
  1382. /**
  1383. * Creates a new LoadFileError
  1384. * @param message defines the message of the error
  1385. * @param request defines the optional web request
  1386. * @param file defines the optional file
  1387. */
  1388. constructor(message: string, object?: WebRequest | File);
  1389. }
  1390. /** @ignore */
  1391. export class RequestFileError extends BaseError {
  1392. request: WebRequest;
  1393. /**
  1394. * Creates a new LoadFileError
  1395. * @param message defines the message of the error
  1396. * @param request defines the optional web request
  1397. */
  1398. constructor(message: string, request: WebRequest);
  1399. }
  1400. /** @ignore */
  1401. export class ReadFileError extends BaseError {
  1402. file: File;
  1403. /**
  1404. * Creates a new ReadFileError
  1405. * @param message defines the message of the error
  1406. * @param file defines the optional file
  1407. */
  1408. constructor(message: string, file: File);
  1409. }
  1410. /**
  1411. * @hidden
  1412. */
  1413. export class FileTools {
  1414. /**
  1415. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1416. */
  1417. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1418. /**
  1419. * Gets or sets the base URL to use to load assets
  1420. */
  1421. static BaseUrl: string;
  1422. /**
  1423. * Default behaviour for cors in the application.
  1424. * It can be a string if the expected behavior is identical in the entire app.
  1425. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1426. */
  1427. static CorsBehavior: string | ((url: string | string[]) => string);
  1428. /**
  1429. * Gets or sets a function used to pre-process url before using them to load assets
  1430. */
  1431. static PreprocessUrl: (url: string) => string;
  1432. /**
  1433. * Removes unwanted characters from an url
  1434. * @param url defines the url to clean
  1435. * @returns the cleaned url
  1436. */
  1437. private static _CleanUrl;
  1438. /**
  1439. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1440. * @param url define the url we are trying
  1441. * @param element define the dom element where to configure the cors policy
  1442. */
  1443. static SetCorsBehavior(url: string | string[], element: {
  1444. crossOrigin: string | null;
  1445. }): void;
  1446. /**
  1447. * Loads an image as an HTMLImageElement.
  1448. * @param input url string, ArrayBuffer, or Blob to load
  1449. * @param onLoad callback called when the image successfully loads
  1450. * @param onError callback called when the image fails to load
  1451. * @param offlineProvider offline provider for caching
  1452. * @param mimeType optional mime type
  1453. * @returns the HTMLImageElement of the loaded image
  1454. */
  1455. 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>;
  1456. /**
  1457. * Reads a file from a File object
  1458. * @param file defines the file to load
  1459. * @param onSuccess defines the callback to call when data is loaded
  1460. * @param onProgress defines the callback to call during loading process
  1461. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1462. * @param onError defines the callback to call when an error occurs
  1463. * @returns a file request object
  1464. */
  1465. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1466. /**
  1467. * Loads a file from a url
  1468. * @param url url to load
  1469. * @param onSuccess callback called when the file successfully loads
  1470. * @param onProgress callback called while file is loading (if the server supports this mode)
  1471. * @param offlineProvider defines the offline provider for caching
  1472. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1473. * @param onError callback called when the file fails to load
  1474. * @returns a file request object
  1475. */
  1476. 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;
  1477. /**
  1478. * Loads a file
  1479. * @param url url to load
  1480. * @param onSuccess callback called when the file successfully loads
  1481. * @param onProgress callback called while file is loading (if the server supports this mode)
  1482. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1483. * @param onError callback called when the file fails to load
  1484. * @param onOpened callback called when the web request is opened
  1485. * @returns a file request object
  1486. */
  1487. 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;
  1488. /**
  1489. * Checks if the loaded document was accessed via `file:`-Protocol.
  1490. * @returns boolean
  1491. */
  1492. static IsFileURL(): boolean;
  1493. }
  1494. }
  1495. declare module BABYLON {
  1496. /** @hidden */
  1497. export class ShaderProcessor {
  1498. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1499. private static _ProcessPrecision;
  1500. private static _ExtractOperation;
  1501. private static _BuildSubExpression;
  1502. private static _BuildExpression;
  1503. private static _MoveCursorWithinIf;
  1504. private static _MoveCursor;
  1505. private static _EvaluatePreProcessors;
  1506. private static _PreparePreProcessors;
  1507. private static _ProcessShaderConversion;
  1508. private static _ProcessIncludes;
  1509. /**
  1510. * Loads a file from a url
  1511. * @param url url to load
  1512. * @param onSuccess callback called when the file successfully loads
  1513. * @param onProgress callback called while file is loading (if the server supports this mode)
  1514. * @param offlineProvider defines the offline provider for caching
  1515. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1516. * @param onError callback called when the file fails to load
  1517. * @returns a file request object
  1518. * @hidden
  1519. */
  1520. 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;
  1521. }
  1522. }
  1523. declare module BABYLON {
  1524. /**
  1525. * @hidden
  1526. */
  1527. export interface IColor4Like {
  1528. r: float;
  1529. g: float;
  1530. b: float;
  1531. a: float;
  1532. }
  1533. /**
  1534. * @hidden
  1535. */
  1536. export interface IColor3Like {
  1537. r: float;
  1538. g: float;
  1539. b: float;
  1540. }
  1541. /**
  1542. * @hidden
  1543. */
  1544. export interface IVector4Like {
  1545. x: float;
  1546. y: float;
  1547. z: float;
  1548. w: float;
  1549. }
  1550. /**
  1551. * @hidden
  1552. */
  1553. export interface IVector3Like {
  1554. x: float;
  1555. y: float;
  1556. z: float;
  1557. }
  1558. /**
  1559. * @hidden
  1560. */
  1561. export interface IVector2Like {
  1562. x: float;
  1563. y: float;
  1564. }
  1565. /**
  1566. * @hidden
  1567. */
  1568. export interface IMatrixLike {
  1569. toArray(): DeepImmutable<Float32Array | Array<number>>;
  1570. updateFlag: int;
  1571. }
  1572. /**
  1573. * @hidden
  1574. */
  1575. export interface IViewportLike {
  1576. x: float;
  1577. y: float;
  1578. width: float;
  1579. height: float;
  1580. }
  1581. /**
  1582. * @hidden
  1583. */
  1584. export interface IPlaneLike {
  1585. normal: IVector3Like;
  1586. d: float;
  1587. normalize(): void;
  1588. }
  1589. }
  1590. declare module BABYLON {
  1591. /**
  1592. * Interface used to define common properties for effect fallbacks
  1593. */
  1594. export interface IEffectFallbacks {
  1595. /**
  1596. * Removes the defines that should be removed when falling back.
  1597. * @param currentDefines defines the current define statements for the shader.
  1598. * @param effect defines the current effect we try to compile
  1599. * @returns The resulting defines with defines of the current rank removed.
  1600. */
  1601. reduce(currentDefines: string, effect: Effect): string;
  1602. /**
  1603. * Removes the fallback from the bound mesh.
  1604. */
  1605. unBindMesh(): void;
  1606. /**
  1607. * Checks to see if more fallbacks are still availible.
  1608. */
  1609. hasMoreFallbacks: boolean;
  1610. }
  1611. }
  1612. declare module BABYLON {
  1613. /**
  1614. * Class used to evalaute queries containing `and` and `or` operators
  1615. */
  1616. export class AndOrNotEvaluator {
  1617. /**
  1618. * Evaluate a query
  1619. * @param query defines the query to evaluate
  1620. * @param evaluateCallback defines the callback used to filter result
  1621. * @returns true if the query matches
  1622. */
  1623. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1624. private static _HandleParenthesisContent;
  1625. private static _SimplifyNegation;
  1626. }
  1627. }
  1628. declare module BABYLON {
  1629. /**
  1630. * Class used to store custom tags
  1631. */
  1632. export class Tags {
  1633. /**
  1634. * Adds support for tags on the given object
  1635. * @param obj defines the object to use
  1636. */
  1637. static EnableFor(obj: any): void;
  1638. /**
  1639. * Removes tags support
  1640. * @param obj defines the object to use
  1641. */
  1642. static DisableFor(obj: any): void;
  1643. /**
  1644. * Gets a boolean indicating if the given object has tags
  1645. * @param obj defines the object to use
  1646. * @returns a boolean
  1647. */
  1648. static HasTags(obj: any): boolean;
  1649. /**
  1650. * Gets the tags available on a given object
  1651. * @param obj defines the object to use
  1652. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1653. * @returns the tags
  1654. */
  1655. static GetTags(obj: any, asString?: boolean): any;
  1656. /**
  1657. * Adds tags to an object
  1658. * @param obj defines the object to use
  1659. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1660. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1661. */
  1662. static AddTagsTo(obj: any, tagsString: string): void;
  1663. /**
  1664. * @hidden
  1665. */
  1666. static _AddTagTo(obj: any, tag: string): void;
  1667. /**
  1668. * Removes specific tags from a specific object
  1669. * @param obj defines the object to use
  1670. * @param tagsString defines the tags to remove
  1671. */
  1672. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1673. /**
  1674. * @hidden
  1675. */
  1676. static _RemoveTagFrom(obj: any, tag: string): void;
  1677. /**
  1678. * Defines if tags hosted on an object match a given query
  1679. * @param obj defines the object to use
  1680. * @param tagsQuery defines the tag query
  1681. * @returns a boolean
  1682. */
  1683. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1684. }
  1685. }
  1686. declare module BABYLON {
  1687. /**
  1688. * Scalar computation library
  1689. */
  1690. export class Scalar {
  1691. /**
  1692. * Two pi constants convenient for computation.
  1693. */
  1694. static TwoPi: number;
  1695. /**
  1696. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1697. * @param a number
  1698. * @param b number
  1699. * @param epsilon (default = 1.401298E-45)
  1700. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1701. */
  1702. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1703. /**
  1704. * Returns a string : the upper case translation of the number i to hexadecimal.
  1705. * @param i number
  1706. * @returns the upper case translation of the number i to hexadecimal.
  1707. */
  1708. static ToHex(i: number): string;
  1709. /**
  1710. * Returns -1 if value is negative and +1 is value is positive.
  1711. * @param value the value
  1712. * @returns the value itself if it's equal to zero.
  1713. */
  1714. static Sign(value: number): number;
  1715. /**
  1716. * Returns the value itself if it's between min and max.
  1717. * Returns min if the value is lower than min.
  1718. * Returns max if the value is greater than max.
  1719. * @param value the value to clmap
  1720. * @param min the min value to clamp to (default: 0)
  1721. * @param max the max value to clamp to (default: 1)
  1722. * @returns the clamped value
  1723. */
  1724. static Clamp(value: number, min?: number, max?: number): number;
  1725. /**
  1726. * the log2 of value.
  1727. * @param value the value to compute log2 of
  1728. * @returns the log2 of value.
  1729. */
  1730. static Log2(value: number): number;
  1731. /**
  1732. * Loops the value, so that it is never larger than length and never smaller than 0.
  1733. *
  1734. * This is similar to the modulo operator but it works with floating point numbers.
  1735. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1736. * With t = 5 and length = 2.5, the result would be 0.0.
  1737. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1738. * @param value the value
  1739. * @param length the length
  1740. * @returns the looped value
  1741. */
  1742. static Repeat(value: number, length: number): number;
  1743. /**
  1744. * Normalize the value between 0.0 and 1.0 using min and max values
  1745. * @param value value to normalize
  1746. * @param min max to normalize between
  1747. * @param max min to normalize between
  1748. * @returns the normalized value
  1749. */
  1750. static Normalize(value: number, min: number, max: number): number;
  1751. /**
  1752. * Denormalize the value from 0.0 and 1.0 using min and max values
  1753. * @param normalized value to denormalize
  1754. * @param min max to denormalize between
  1755. * @param max min to denormalize between
  1756. * @returns the denormalized value
  1757. */
  1758. static Denormalize(normalized: number, min: number, max: number): number;
  1759. /**
  1760. * Calculates the shortest difference between two given angles given in degrees.
  1761. * @param current current angle in degrees
  1762. * @param target target angle in degrees
  1763. * @returns the delta
  1764. */
  1765. static DeltaAngle(current: number, target: number): number;
  1766. /**
  1767. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1768. * @param tx value
  1769. * @param length length
  1770. * @returns The returned value will move back and forth between 0 and length
  1771. */
  1772. static PingPong(tx: number, length: number): number;
  1773. /**
  1774. * Interpolates between min and max with smoothing at the limits.
  1775. *
  1776. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1777. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1778. * @param from from
  1779. * @param to to
  1780. * @param tx value
  1781. * @returns the smooth stepped value
  1782. */
  1783. static SmoothStep(from: number, to: number, tx: number): number;
  1784. /**
  1785. * Moves a value current towards target.
  1786. *
  1787. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1788. * Negative values of maxDelta pushes the value away from target.
  1789. * @param current current value
  1790. * @param target target value
  1791. * @param maxDelta max distance to move
  1792. * @returns resulting value
  1793. */
  1794. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1795. /**
  1796. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1797. *
  1798. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1799. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1800. * @param current current value
  1801. * @param target target value
  1802. * @param maxDelta max distance to move
  1803. * @returns resulting angle
  1804. */
  1805. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1806. /**
  1807. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1808. * @param start start value
  1809. * @param end target value
  1810. * @param amount amount to lerp between
  1811. * @returns the lerped value
  1812. */
  1813. static Lerp(start: number, end: number, amount: number): number;
  1814. /**
  1815. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1816. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1817. * @param start start value
  1818. * @param end target value
  1819. * @param amount amount to lerp between
  1820. * @returns the lerped value
  1821. */
  1822. static LerpAngle(start: number, end: number, amount: number): number;
  1823. /**
  1824. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1825. * @param a start value
  1826. * @param b target value
  1827. * @param value value between a and b
  1828. * @returns the inverseLerp value
  1829. */
  1830. static InverseLerp(a: number, b: number, value: number): number;
  1831. /**
  1832. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1833. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1834. * @param value1 spline value
  1835. * @param tangent1 spline value
  1836. * @param value2 spline value
  1837. * @param tangent2 spline value
  1838. * @param amount input value
  1839. * @returns hermite result
  1840. */
  1841. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1842. /**
  1843. * Returns a random float number between and min and max values
  1844. * @param min min value of random
  1845. * @param max max value of random
  1846. * @returns random value
  1847. */
  1848. static RandomRange(min: number, max: number): number;
  1849. /**
  1850. * This function returns percentage of a number in a given range.
  1851. *
  1852. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1853. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1854. * @param number to convert to percentage
  1855. * @param min min range
  1856. * @param max max range
  1857. * @returns the percentage
  1858. */
  1859. static RangeToPercent(number: number, min: number, max: number): number;
  1860. /**
  1861. * This function returns number that corresponds to the percentage in a given range.
  1862. *
  1863. * PercentToRange(0.34,0,100) will return 34.
  1864. * @param percent to convert to number
  1865. * @param min min range
  1866. * @param max max range
  1867. * @returns the number
  1868. */
  1869. static PercentToRange(percent: number, min: number, max: number): number;
  1870. /**
  1871. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1872. * @param angle The angle to normalize in radian.
  1873. * @return The converted angle.
  1874. */
  1875. static NormalizeRadians(angle: number): number;
  1876. }
  1877. }
  1878. declare module BABYLON {
  1879. /**
  1880. * Constant used to convert a value to gamma space
  1881. * @ignorenaming
  1882. */
  1883. export const ToGammaSpace: number;
  1884. /**
  1885. * Constant used to convert a value to linear space
  1886. * @ignorenaming
  1887. */
  1888. export const ToLinearSpace = 2.2;
  1889. /**
  1890. * Constant used to define the minimal number value in Babylon.js
  1891. * @ignorenaming
  1892. */
  1893. let Epsilon: number;
  1894. }
  1895. declare module BABYLON {
  1896. /**
  1897. * Class used to represent a viewport on screen
  1898. */
  1899. export class Viewport {
  1900. /** viewport left coordinate */
  1901. x: number;
  1902. /** viewport top coordinate */
  1903. y: number;
  1904. /**viewport width */
  1905. width: number;
  1906. /** viewport height */
  1907. height: number;
  1908. /**
  1909. * Creates a Viewport object located at (x, y) and sized (width, height)
  1910. * @param x defines viewport left coordinate
  1911. * @param y defines viewport top coordinate
  1912. * @param width defines the viewport width
  1913. * @param height defines the viewport height
  1914. */
  1915. constructor(
  1916. /** viewport left coordinate */
  1917. x: number,
  1918. /** viewport top coordinate */
  1919. y: number,
  1920. /**viewport width */
  1921. width: number,
  1922. /** viewport height */
  1923. height: number);
  1924. /**
  1925. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1926. * @param renderWidth defines the rendering width
  1927. * @param renderHeight defines the rendering height
  1928. * @returns a new Viewport
  1929. */
  1930. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1931. /**
  1932. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1933. * @param renderWidth defines the rendering width
  1934. * @param renderHeight defines the rendering height
  1935. * @param ref defines the target viewport
  1936. * @returns the current viewport
  1937. */
  1938. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1939. /**
  1940. * Returns a new Viewport copied from the current one
  1941. * @returns a new Viewport
  1942. */
  1943. clone(): Viewport;
  1944. }
  1945. }
  1946. declare module BABYLON {
  1947. /**
  1948. * Class containing a set of static utilities functions for arrays.
  1949. */
  1950. export class ArrayTools {
  1951. /**
  1952. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1953. * @param size the number of element to construct and put in the array
  1954. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1955. * @returns a new array filled with new objects
  1956. */
  1957. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1958. }
  1959. }
  1960. declare module BABYLON {
  1961. /**
  1962. * Represents a plane by the equation ax + by + cz + d = 0
  1963. */
  1964. export class Plane {
  1965. private static _TmpMatrix;
  1966. /**
  1967. * Normal of the plane (a,b,c)
  1968. */
  1969. normal: Vector3;
  1970. /**
  1971. * d component of the plane
  1972. */
  1973. d: number;
  1974. /**
  1975. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  1976. * @param a a component of the plane
  1977. * @param b b component of the plane
  1978. * @param c c component of the plane
  1979. * @param d d component of the plane
  1980. */
  1981. constructor(a: number, b: number, c: number, d: number);
  1982. /**
  1983. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  1984. */
  1985. asArray(): number[];
  1986. /**
  1987. * @returns a new plane copied from the current Plane.
  1988. */
  1989. clone(): Plane;
  1990. /**
  1991. * @returns the string "Plane".
  1992. */
  1993. getClassName(): string;
  1994. /**
  1995. * @returns the Plane hash code.
  1996. */
  1997. getHashCode(): number;
  1998. /**
  1999. * Normalize the current Plane in place.
  2000. * @returns the updated Plane.
  2001. */
  2002. normalize(): Plane;
  2003. /**
  2004. * Applies a transformation the plane and returns the result
  2005. * @param transformation the transformation matrix to be applied to the plane
  2006. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  2007. */
  2008. transform(transformation: DeepImmutable<Matrix>): Plane;
  2009. /**
  2010. * Compute the dot product between the point and the plane normal
  2011. * @param point point to calculate the dot product with
  2012. * @returns the dot product (float) of the point coordinates and the plane normal.
  2013. */
  2014. dotCoordinate(point: DeepImmutable<Vector3>): number;
  2015. /**
  2016. * Updates the current Plane from the plane defined by the three given points.
  2017. * @param point1 one of the points used to contruct the plane
  2018. * @param point2 one of the points used to contruct the plane
  2019. * @param point3 one of the points used to contruct the plane
  2020. * @returns the updated Plane.
  2021. */
  2022. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2023. /**
  2024. * Checks if the plane is facing a given direction
  2025. * @param direction the direction to check if the plane is facing
  2026. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  2027. * @returns True is the vector "direction" is the same side than the plane normal.
  2028. */
  2029. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  2030. /**
  2031. * Calculates the distance to a point
  2032. * @param point point to calculate distance to
  2033. * @returns the signed distance (float) from the given point to the Plane.
  2034. */
  2035. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  2036. /**
  2037. * Creates a plane from an array
  2038. * @param array the array to create a plane from
  2039. * @returns a new Plane from the given array.
  2040. */
  2041. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  2042. /**
  2043. * Creates a plane from three points
  2044. * @param point1 point used to create the plane
  2045. * @param point2 point used to create the plane
  2046. * @param point3 point used to create the plane
  2047. * @returns a new Plane defined by the three given points.
  2048. */
  2049. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2050. /**
  2051. * Creates a plane from an origin point and a normal
  2052. * @param origin origin of the plane to be constructed
  2053. * @param normal normal of the plane to be constructed
  2054. * @returns a new Plane the normal vector to this plane at the given origin point.
  2055. * Note : the vector "normal" is updated because normalized.
  2056. */
  2057. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  2058. /**
  2059. * Calculates the distance from a plane and a point
  2060. * @param origin origin of the plane to be constructed
  2061. * @param normal normal of the plane to be constructed
  2062. * @param point point to calculate distance to
  2063. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2064. */
  2065. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2066. }
  2067. }
  2068. declare module BABYLON {
  2069. /** @hidden */
  2070. export class PerformanceConfigurator {
  2071. /** @hidden */
  2072. static MatrixUse64Bits: boolean;
  2073. /** @hidden */
  2074. static MatrixTrackPrecisionChange: boolean;
  2075. /** @hidden */
  2076. static MatrixCurrentType: any;
  2077. /** @hidden */
  2078. static MatrixTrackedMatrices: Array<any> | null;
  2079. /** @hidden */
  2080. static SetMatrixPrecision(use64bits: boolean): void;
  2081. }
  2082. }
  2083. declare module BABYLON {
  2084. /**
  2085. * Class representing a vector containing 2 coordinates
  2086. */
  2087. export class Vector2 {
  2088. /** defines the first coordinate */
  2089. x: number;
  2090. /** defines the second coordinate */
  2091. y: number;
  2092. /**
  2093. * Creates a new Vector2 from the given x and y coordinates
  2094. * @param x defines the first coordinate
  2095. * @param y defines the second coordinate
  2096. */
  2097. constructor(
  2098. /** defines the first coordinate */
  2099. x?: number,
  2100. /** defines the second coordinate */
  2101. y?: number);
  2102. /**
  2103. * Gets a string with the Vector2 coordinates
  2104. * @returns a string with the Vector2 coordinates
  2105. */
  2106. toString(): string;
  2107. /**
  2108. * Gets class name
  2109. * @returns the string "Vector2"
  2110. */
  2111. getClassName(): string;
  2112. /**
  2113. * Gets current vector hash code
  2114. * @returns the Vector2 hash code as a number
  2115. */
  2116. getHashCode(): number;
  2117. /**
  2118. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2119. * @param array defines the source array
  2120. * @param index defines the offset in source array
  2121. * @returns the current Vector2
  2122. */
  2123. toArray(array: FloatArray, index?: number): Vector2;
  2124. /**
  2125. * Update the current vector from an array
  2126. * @param array defines the destination array
  2127. * @param index defines the offset in the destination array
  2128. * @returns the current Vector3
  2129. */
  2130. fromArray(array: FloatArray, index?: number): Vector2;
  2131. /**
  2132. * Copy the current vector to an array
  2133. * @returns a new array with 2 elements: the Vector2 coordinates.
  2134. */
  2135. asArray(): number[];
  2136. /**
  2137. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2138. * @param source defines the source Vector2
  2139. * @returns the current updated Vector2
  2140. */
  2141. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2142. /**
  2143. * Sets the Vector2 coordinates with the given floats
  2144. * @param x defines the first coordinate
  2145. * @param y defines the second coordinate
  2146. * @returns the current updated Vector2
  2147. */
  2148. copyFromFloats(x: number, y: number): Vector2;
  2149. /**
  2150. * Sets the Vector2 coordinates with the given floats
  2151. * @param x defines the first coordinate
  2152. * @param y defines the second coordinate
  2153. * @returns the current updated Vector2
  2154. */
  2155. set(x: number, y: number): Vector2;
  2156. /**
  2157. * Add another vector with the current one
  2158. * @param otherVector defines the other vector
  2159. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2160. */
  2161. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2162. /**
  2163. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2164. * @param otherVector defines the other vector
  2165. * @param result defines the target vector
  2166. * @returns the unmodified current Vector2
  2167. */
  2168. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2169. /**
  2170. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2171. * @param otherVector defines the other vector
  2172. * @returns the current updated Vector2
  2173. */
  2174. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2175. /**
  2176. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2177. * @param otherVector defines the other vector
  2178. * @returns a new Vector2
  2179. */
  2180. addVector3(otherVector: Vector3): Vector2;
  2181. /**
  2182. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2183. * @param otherVector defines the other vector
  2184. * @returns a new Vector2
  2185. */
  2186. subtract(otherVector: Vector2): Vector2;
  2187. /**
  2188. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2189. * @param otherVector defines the other vector
  2190. * @param result defines the target vector
  2191. * @returns the unmodified current Vector2
  2192. */
  2193. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2194. /**
  2195. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2196. * @param otherVector defines the other vector
  2197. * @returns the current updated Vector2
  2198. */
  2199. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2200. /**
  2201. * Multiplies in place the current Vector2 coordinates by the given ones
  2202. * @param otherVector defines the other vector
  2203. * @returns the current updated Vector2
  2204. */
  2205. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2206. /**
  2207. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2208. * @param otherVector defines the other vector
  2209. * @returns a new Vector2
  2210. */
  2211. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2212. /**
  2213. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2214. * @param otherVector defines the other vector
  2215. * @param result defines the target vector
  2216. * @returns the unmodified current Vector2
  2217. */
  2218. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2219. /**
  2220. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2221. * @param x defines the first coordinate
  2222. * @param y defines the second coordinate
  2223. * @returns a new Vector2
  2224. */
  2225. multiplyByFloats(x: number, y: number): Vector2;
  2226. /**
  2227. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2228. * @param otherVector defines the other vector
  2229. * @returns a new Vector2
  2230. */
  2231. divide(otherVector: Vector2): Vector2;
  2232. /**
  2233. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2234. * @param otherVector defines the other vector
  2235. * @param result defines the target vector
  2236. * @returns the unmodified current Vector2
  2237. */
  2238. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2239. /**
  2240. * Divides the current Vector2 coordinates by the given ones
  2241. * @param otherVector defines the other vector
  2242. * @returns the current updated Vector2
  2243. */
  2244. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2245. /**
  2246. * Gets a new Vector2 with current Vector2 negated coordinates
  2247. * @returns a new Vector2
  2248. */
  2249. negate(): Vector2;
  2250. /**
  2251. * Negate this vector in place
  2252. * @returns this
  2253. */
  2254. negateInPlace(): Vector2;
  2255. /**
  2256. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2257. * @param result defines the Vector3 object where to store the result
  2258. * @returns the current Vector2
  2259. */
  2260. negateToRef(result: Vector2): Vector2;
  2261. /**
  2262. * Multiply the Vector2 coordinates by scale
  2263. * @param scale defines the scaling factor
  2264. * @returns the current updated Vector2
  2265. */
  2266. scaleInPlace(scale: number): Vector2;
  2267. /**
  2268. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2269. * @param scale defines the scaling factor
  2270. * @returns a new Vector2
  2271. */
  2272. scale(scale: number): Vector2;
  2273. /**
  2274. * Scale the current Vector2 values by a factor to a given Vector2
  2275. * @param scale defines the scale factor
  2276. * @param result defines the Vector2 object where to store the result
  2277. * @returns the unmodified current Vector2
  2278. */
  2279. scaleToRef(scale: number, result: Vector2): Vector2;
  2280. /**
  2281. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2282. * @param scale defines the scale factor
  2283. * @param result defines the Vector2 object where to store the result
  2284. * @returns the unmodified current Vector2
  2285. */
  2286. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2287. /**
  2288. * Gets a boolean if two vectors are equals
  2289. * @param otherVector defines the other vector
  2290. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2291. */
  2292. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2293. /**
  2294. * Gets a boolean if two vectors are equals (using an epsilon value)
  2295. * @param otherVector defines the other vector
  2296. * @param epsilon defines the minimal distance to consider equality
  2297. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2298. */
  2299. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2300. /**
  2301. * Gets a new Vector2 from current Vector2 floored values
  2302. * @returns a new Vector2
  2303. */
  2304. floor(): Vector2;
  2305. /**
  2306. * Gets a new Vector2 from current Vector2 floored values
  2307. * @returns a new Vector2
  2308. */
  2309. fract(): Vector2;
  2310. /**
  2311. * Gets the length of the vector
  2312. * @returns the vector length (float)
  2313. */
  2314. length(): number;
  2315. /**
  2316. * Gets the vector squared length
  2317. * @returns the vector squared length (float)
  2318. */
  2319. lengthSquared(): number;
  2320. /**
  2321. * Normalize the vector
  2322. * @returns the current updated Vector2
  2323. */
  2324. normalize(): Vector2;
  2325. /**
  2326. * Gets a new Vector2 copied from the Vector2
  2327. * @returns a new Vector2
  2328. */
  2329. clone(): Vector2;
  2330. /**
  2331. * Gets a new Vector2(0, 0)
  2332. * @returns a new Vector2
  2333. */
  2334. static Zero(): Vector2;
  2335. /**
  2336. * Gets a new Vector2(1, 1)
  2337. * @returns a new Vector2
  2338. */
  2339. static One(): Vector2;
  2340. /**
  2341. * Gets a new Vector2 set from the given index element of the given array
  2342. * @param array defines the data source
  2343. * @param offset defines the offset in the data source
  2344. * @returns a new Vector2
  2345. */
  2346. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2347. /**
  2348. * Sets "result" from the given index element of the given array
  2349. * @param array defines the data source
  2350. * @param offset defines the offset in the data source
  2351. * @param result defines the target vector
  2352. */
  2353. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2354. /**
  2355. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2356. * @param value1 defines 1st point of control
  2357. * @param value2 defines 2nd point of control
  2358. * @param value3 defines 3rd point of control
  2359. * @param value4 defines 4th point of control
  2360. * @param amount defines the interpolation factor
  2361. * @returns a new Vector2
  2362. */
  2363. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2364. /**
  2365. * 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".
  2366. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2367. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2368. * @param value defines the value to clamp
  2369. * @param min defines the lower limit
  2370. * @param max defines the upper limit
  2371. * @returns a new Vector2
  2372. */
  2373. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2374. /**
  2375. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2376. * @param value1 defines the 1st control point
  2377. * @param tangent1 defines the outgoing tangent
  2378. * @param value2 defines the 2nd control point
  2379. * @param tangent2 defines the incoming tangent
  2380. * @param amount defines the interpolation factor
  2381. * @returns a new Vector2
  2382. */
  2383. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2384. /**
  2385. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2386. * @param start defines the start vector
  2387. * @param end defines the end vector
  2388. * @param amount defines the interpolation factor
  2389. * @returns a new Vector2
  2390. */
  2391. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2392. /**
  2393. * Gets the dot product of the vector "left" and the vector "right"
  2394. * @param left defines first vector
  2395. * @param right defines second vector
  2396. * @returns the dot product (float)
  2397. */
  2398. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2399. /**
  2400. * Returns a new Vector2 equal to the normalized given vector
  2401. * @param vector defines the vector to normalize
  2402. * @returns a new Vector2
  2403. */
  2404. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2405. /**
  2406. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2407. * @param left defines 1st vector
  2408. * @param right defines 2nd vector
  2409. * @returns a new Vector2
  2410. */
  2411. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2412. /**
  2413. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2414. * @param left defines 1st vector
  2415. * @param right defines 2nd vector
  2416. * @returns a new Vector2
  2417. */
  2418. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2419. /**
  2420. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2421. * @param vector defines the vector to transform
  2422. * @param transformation defines the matrix to apply
  2423. * @returns a new Vector2
  2424. */
  2425. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2426. /**
  2427. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2428. * @param vector defines the vector to transform
  2429. * @param transformation defines the matrix to apply
  2430. * @param result defines the target vector
  2431. */
  2432. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2433. /**
  2434. * Determines if a given vector is included in a triangle
  2435. * @param p defines the vector to test
  2436. * @param p0 defines 1st triangle point
  2437. * @param p1 defines 2nd triangle point
  2438. * @param p2 defines 3rd triangle point
  2439. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2440. */
  2441. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2442. /**
  2443. * Gets the distance between the vectors "value1" and "value2"
  2444. * @param value1 defines first vector
  2445. * @param value2 defines second vector
  2446. * @returns the distance between vectors
  2447. */
  2448. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2449. /**
  2450. * Returns the squared distance between the vectors "value1" and "value2"
  2451. * @param value1 defines first vector
  2452. * @param value2 defines second vector
  2453. * @returns the squared distance between vectors
  2454. */
  2455. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2456. /**
  2457. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2458. * @param value1 defines first vector
  2459. * @param value2 defines second vector
  2460. * @returns a new Vector2
  2461. */
  2462. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2463. /**
  2464. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2465. * @param p defines the middle point
  2466. * @param segA defines one point of the segment
  2467. * @param segB defines the other point of the segment
  2468. * @returns the shortest distance
  2469. */
  2470. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2471. }
  2472. /**
  2473. * Class used to store (x,y,z) vector representation
  2474. * A Vector3 is the main object used in 3D geometry
  2475. * It can represent etiher the coordinates of a point the space, either a direction
  2476. * Reminder: js uses a left handed forward facing system
  2477. */
  2478. export class Vector3 {
  2479. private static _UpReadOnly;
  2480. private static _ZeroReadOnly;
  2481. /** @hidden */
  2482. _x: number;
  2483. /** @hidden */
  2484. _y: number;
  2485. /** @hidden */
  2486. _z: number;
  2487. /** @hidden */
  2488. _isDirty: boolean;
  2489. /** Gets or sets the x coordinate */
  2490. get x(): number;
  2491. set x(value: number);
  2492. /** Gets or sets the y coordinate */
  2493. get y(): number;
  2494. set y(value: number);
  2495. /** Gets or sets the z coordinate */
  2496. get z(): number;
  2497. set z(value: number);
  2498. /**
  2499. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2500. * @param x defines the first coordinates (on X axis)
  2501. * @param y defines the second coordinates (on Y axis)
  2502. * @param z defines the third coordinates (on Z axis)
  2503. */
  2504. constructor(x?: number, y?: number, z?: number);
  2505. /**
  2506. * Creates a string representation of the Vector3
  2507. * @returns a string with the Vector3 coordinates.
  2508. */
  2509. toString(): string;
  2510. /**
  2511. * Gets the class name
  2512. * @returns the string "Vector3"
  2513. */
  2514. getClassName(): string;
  2515. /**
  2516. * Creates the Vector3 hash code
  2517. * @returns a number which tends to be unique between Vector3 instances
  2518. */
  2519. getHashCode(): number;
  2520. /**
  2521. * Creates an array containing three elements : the coordinates of the Vector3
  2522. * @returns a new array of numbers
  2523. */
  2524. asArray(): number[];
  2525. /**
  2526. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2527. * @param array defines the destination array
  2528. * @param index defines the offset in the destination array
  2529. * @returns the current Vector3
  2530. */
  2531. toArray(array: FloatArray, index?: number): Vector3;
  2532. /**
  2533. * Update the current vector from an array
  2534. * @param array defines the destination array
  2535. * @param index defines the offset in the destination array
  2536. * @returns the current Vector3
  2537. */
  2538. fromArray(array: FloatArray, index?: number): Vector3;
  2539. /**
  2540. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2541. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2542. */
  2543. toQuaternion(): Quaternion;
  2544. /**
  2545. * Adds the given vector to the current Vector3
  2546. * @param otherVector defines the second operand
  2547. * @returns the current updated Vector3
  2548. */
  2549. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2550. /**
  2551. * Adds the given coordinates to the current Vector3
  2552. * @param x defines the x coordinate of the operand
  2553. * @param y defines the y coordinate of the operand
  2554. * @param z defines the z coordinate of the operand
  2555. * @returns the current updated Vector3
  2556. */
  2557. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2558. /**
  2559. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2560. * @param otherVector defines the second operand
  2561. * @returns the resulting Vector3
  2562. */
  2563. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2564. /**
  2565. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2566. * @param otherVector defines the second operand
  2567. * @param result defines the Vector3 object where to store the result
  2568. * @returns the current Vector3
  2569. */
  2570. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2571. /**
  2572. * Subtract the given vector from the current Vector3
  2573. * @param otherVector defines the second operand
  2574. * @returns the current updated Vector3
  2575. */
  2576. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2577. /**
  2578. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2579. * @param otherVector defines the second operand
  2580. * @returns the resulting Vector3
  2581. */
  2582. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2583. /**
  2584. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2585. * @param otherVector defines the second operand
  2586. * @param result defines the Vector3 object where to store the result
  2587. * @returns the current Vector3
  2588. */
  2589. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2590. /**
  2591. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2592. * @param x defines the x coordinate of the operand
  2593. * @param y defines the y coordinate of the operand
  2594. * @param z defines the z coordinate of the operand
  2595. * @returns the resulting Vector3
  2596. */
  2597. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2598. /**
  2599. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2600. * @param x defines the x coordinate of the operand
  2601. * @param y defines the y coordinate of the operand
  2602. * @param z defines the z coordinate of the operand
  2603. * @param result defines the Vector3 object where to store the result
  2604. * @returns the current Vector3
  2605. */
  2606. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2607. /**
  2608. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2609. * @returns a new Vector3
  2610. */
  2611. negate(): Vector3;
  2612. /**
  2613. * Negate this vector in place
  2614. * @returns this
  2615. */
  2616. negateInPlace(): Vector3;
  2617. /**
  2618. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2619. * @param result defines the Vector3 object where to store the result
  2620. * @returns the current Vector3
  2621. */
  2622. negateToRef(result: Vector3): Vector3;
  2623. /**
  2624. * Multiplies the Vector3 coordinates by the float "scale"
  2625. * @param scale defines the multiplier factor
  2626. * @returns the current updated Vector3
  2627. */
  2628. scaleInPlace(scale: number): Vector3;
  2629. /**
  2630. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2631. * @param scale defines the multiplier factor
  2632. * @returns a new Vector3
  2633. */
  2634. scale(scale: number): Vector3;
  2635. /**
  2636. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2637. * @param scale defines the multiplier factor
  2638. * @param result defines the Vector3 object where to store the result
  2639. * @returns the current Vector3
  2640. */
  2641. scaleToRef(scale: number, result: Vector3): Vector3;
  2642. /**
  2643. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2644. * @param scale defines the scale factor
  2645. * @param result defines the Vector3 object where to store the result
  2646. * @returns the unmodified current Vector3
  2647. */
  2648. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2649. /**
  2650. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2651. * @param origin defines the origin of the projection ray
  2652. * @param plane defines the plane to project to
  2653. * @returns the projected vector3
  2654. */
  2655. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  2656. /**
  2657. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2658. * @param origin defines the origin of the projection ray
  2659. * @param plane defines the plane to project to
  2660. * @param result defines the Vector3 where to store the result
  2661. */
  2662. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  2663. /**
  2664. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2665. * @param otherVector defines the second operand
  2666. * @returns true if both vectors are equals
  2667. */
  2668. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2669. /**
  2670. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2671. * @param otherVector defines the second operand
  2672. * @param epsilon defines the minimal distance to define values as equals
  2673. * @returns true if both vectors are distant less than epsilon
  2674. */
  2675. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2676. /**
  2677. * Returns true if the current Vector3 coordinates equals the given floats
  2678. * @param x defines the x coordinate of the operand
  2679. * @param y defines the y coordinate of the operand
  2680. * @param z defines the z coordinate of the operand
  2681. * @returns true if both vectors are equals
  2682. */
  2683. equalsToFloats(x: number, y: number, z: number): boolean;
  2684. /**
  2685. * Multiplies the current Vector3 coordinates by the given ones
  2686. * @param otherVector defines the second operand
  2687. * @returns the current updated Vector3
  2688. */
  2689. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2690. /**
  2691. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2692. * @param otherVector defines the second operand
  2693. * @returns the new Vector3
  2694. */
  2695. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2696. /**
  2697. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2698. * @param otherVector defines the second operand
  2699. * @param result defines the Vector3 object where to store the result
  2700. * @returns the current Vector3
  2701. */
  2702. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2703. /**
  2704. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2705. * @param x defines the x coordinate of the operand
  2706. * @param y defines the y coordinate of the operand
  2707. * @param z defines the z coordinate of the operand
  2708. * @returns the new Vector3
  2709. */
  2710. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2711. /**
  2712. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2713. * @param otherVector defines the second operand
  2714. * @returns the new Vector3
  2715. */
  2716. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2717. /**
  2718. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2719. * @param otherVector defines the second operand
  2720. * @param result defines the Vector3 object where to store the result
  2721. * @returns the current Vector3
  2722. */
  2723. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2724. /**
  2725. * Divides the current Vector3 coordinates by the given ones.
  2726. * @param otherVector defines the second operand
  2727. * @returns the current updated Vector3
  2728. */
  2729. divideInPlace(otherVector: Vector3): Vector3;
  2730. /**
  2731. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2732. * @param other defines the second operand
  2733. * @returns the current updated Vector3
  2734. */
  2735. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2736. /**
  2737. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2738. * @param other defines the second operand
  2739. * @returns the current updated Vector3
  2740. */
  2741. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2742. /**
  2743. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2744. * @param x defines the x coordinate of the operand
  2745. * @param y defines the y coordinate of the operand
  2746. * @param z defines the z coordinate of the operand
  2747. * @returns the current updated Vector3
  2748. */
  2749. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2750. /**
  2751. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2752. * @param x defines the x coordinate of the operand
  2753. * @param y defines the y coordinate of the operand
  2754. * @param z defines the z coordinate of the operand
  2755. * @returns the current updated Vector3
  2756. */
  2757. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2758. /**
  2759. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2760. * Check if is non uniform within a certain amount of decimal places to account for this
  2761. * @param epsilon the amount the values can differ
  2762. * @returns if the the vector is non uniform to a certain number of decimal places
  2763. */
  2764. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2765. /**
  2766. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2767. */
  2768. get isNonUniform(): boolean;
  2769. /**
  2770. * Gets a new Vector3 from current Vector3 floored values
  2771. * @returns a new Vector3
  2772. */
  2773. floor(): Vector3;
  2774. /**
  2775. * Gets a new Vector3 from current Vector3 floored values
  2776. * @returns a new Vector3
  2777. */
  2778. fract(): Vector3;
  2779. /**
  2780. * Gets the length of the Vector3
  2781. * @returns the length of the Vector3
  2782. */
  2783. length(): number;
  2784. /**
  2785. * Gets the squared length of the Vector3
  2786. * @returns squared length of the Vector3
  2787. */
  2788. lengthSquared(): number;
  2789. /**
  2790. * Normalize the current Vector3.
  2791. * Please note that this is an in place operation.
  2792. * @returns the current updated Vector3
  2793. */
  2794. normalize(): Vector3;
  2795. /**
  2796. * Reorders the x y z properties of the vector in place
  2797. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2798. * @returns the current updated vector
  2799. */
  2800. reorderInPlace(order: string): this;
  2801. /**
  2802. * Rotates the vector around 0,0,0 by a quaternion
  2803. * @param quaternion the rotation quaternion
  2804. * @param result vector to store the result
  2805. * @returns the resulting vector
  2806. */
  2807. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2808. /**
  2809. * Rotates a vector around a given point
  2810. * @param quaternion the rotation quaternion
  2811. * @param point the point to rotate around
  2812. * @param result vector to store the result
  2813. * @returns the resulting vector
  2814. */
  2815. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2816. /**
  2817. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2818. * The cross product is then orthogonal to both current and "other"
  2819. * @param other defines the right operand
  2820. * @returns the cross product
  2821. */
  2822. cross(other: Vector3): Vector3;
  2823. /**
  2824. * Normalize the current Vector3 with the given input length.
  2825. * Please note that this is an in place operation.
  2826. * @param len the length of the vector
  2827. * @returns the current updated Vector3
  2828. */
  2829. normalizeFromLength(len: number): Vector3;
  2830. /**
  2831. * Normalize the current Vector3 to a new vector
  2832. * @returns the new Vector3
  2833. */
  2834. normalizeToNew(): Vector3;
  2835. /**
  2836. * Normalize the current Vector3 to the reference
  2837. * @param reference define the Vector3 to update
  2838. * @returns the updated Vector3
  2839. */
  2840. normalizeToRef(reference: Vector3): Vector3;
  2841. /**
  2842. * Creates a new Vector3 copied from the current Vector3
  2843. * @returns the new Vector3
  2844. */
  2845. clone(): Vector3;
  2846. /**
  2847. * Copies the given vector coordinates to the current Vector3 ones
  2848. * @param source defines the source Vector3
  2849. * @returns the current updated Vector3
  2850. */
  2851. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2852. /**
  2853. * Copies the given floats to the current Vector3 coordinates
  2854. * @param x defines the x coordinate of the operand
  2855. * @param y defines the y coordinate of the operand
  2856. * @param z defines the z coordinate of the operand
  2857. * @returns the current updated Vector3
  2858. */
  2859. copyFromFloats(x: number, y: number, z: number): Vector3;
  2860. /**
  2861. * Copies the given floats to the current Vector3 coordinates
  2862. * @param x defines the x coordinate of the operand
  2863. * @param y defines the y coordinate of the operand
  2864. * @param z defines the z coordinate of the operand
  2865. * @returns the current updated Vector3
  2866. */
  2867. set(x: number, y: number, z: number): Vector3;
  2868. /**
  2869. * Copies the given float to the current Vector3 coordinates
  2870. * @param v defines the x, y and z coordinates of the operand
  2871. * @returns the current updated Vector3
  2872. */
  2873. setAll(v: number): Vector3;
  2874. /**
  2875. * Get the clip factor between two vectors
  2876. * @param vector0 defines the first operand
  2877. * @param vector1 defines the second operand
  2878. * @param axis defines the axis to use
  2879. * @param size defines the size along the axis
  2880. * @returns the clip factor
  2881. */
  2882. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2883. /**
  2884. * Get angle between two vectors
  2885. * @param vector0 angle between vector0 and vector1
  2886. * @param vector1 angle between vector0 and vector1
  2887. * @param normal direction of the normal
  2888. * @return the angle between vector0 and vector1
  2889. */
  2890. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2891. /**
  2892. * Returns a new Vector3 set from the index "offset" of the given array
  2893. * @param array defines the source array
  2894. * @param offset defines the offset in the source array
  2895. * @returns the new Vector3
  2896. */
  2897. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2898. /**
  2899. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2900. * @param array defines the source array
  2901. * @param offset defines the offset in the source array
  2902. * @returns the new Vector3
  2903. * @deprecated Please use FromArray instead.
  2904. */
  2905. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2906. /**
  2907. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2908. * @param array defines the source array
  2909. * @param offset defines the offset in the source array
  2910. * @param result defines the Vector3 where to store the result
  2911. */
  2912. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2913. /**
  2914. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2915. * @param array defines the source array
  2916. * @param offset defines the offset in the source array
  2917. * @param result defines the Vector3 where to store the result
  2918. * @deprecated Please use FromArrayToRef instead.
  2919. */
  2920. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2921. /**
  2922. * Sets the given vector "result" with the given floats.
  2923. * @param x defines the x coordinate of the source
  2924. * @param y defines the y coordinate of the source
  2925. * @param z defines the z coordinate of the source
  2926. * @param result defines the Vector3 where to store the result
  2927. */
  2928. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2929. /**
  2930. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2931. * @returns a new empty Vector3
  2932. */
  2933. static Zero(): Vector3;
  2934. /**
  2935. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2936. * @returns a new unit Vector3
  2937. */
  2938. static One(): Vector3;
  2939. /**
  2940. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2941. * @returns a new up Vector3
  2942. */
  2943. static Up(): Vector3;
  2944. /**
  2945. * Gets a up Vector3 that must not be updated
  2946. */
  2947. static get UpReadOnly(): DeepImmutable<Vector3>;
  2948. /**
  2949. * Gets a zero Vector3 that must not be updated
  2950. */
  2951. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2952. /**
  2953. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2954. * @returns a new down Vector3
  2955. */
  2956. static Down(): Vector3;
  2957. /**
  2958. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2959. * @param rightHandedSystem is the scene right-handed (negative z)
  2960. * @returns a new forward Vector3
  2961. */
  2962. static Forward(rightHandedSystem?: boolean): Vector3;
  2963. /**
  2964. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2965. * @param rightHandedSystem is the scene right-handed (negative-z)
  2966. * @returns a new forward Vector3
  2967. */
  2968. static Backward(rightHandedSystem?: boolean): Vector3;
  2969. /**
  2970. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2971. * @returns a new right Vector3
  2972. */
  2973. static Right(): Vector3;
  2974. /**
  2975. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2976. * @returns a new left Vector3
  2977. */
  2978. static Left(): Vector3;
  2979. /**
  2980. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2981. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2982. * @param vector defines the Vector3 to transform
  2983. * @param transformation defines the transformation matrix
  2984. * @returns the transformed Vector3
  2985. */
  2986. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2987. /**
  2988. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2989. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2990. * @param vector defines the Vector3 to transform
  2991. * @param transformation defines the transformation matrix
  2992. * @param result defines the Vector3 where to store the result
  2993. */
  2994. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2995. /**
  2996. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2997. * This method computes tranformed coordinates only, not transformed direction vectors
  2998. * @param x define the x coordinate of the source vector
  2999. * @param y define the y coordinate of the source vector
  3000. * @param z define the z coordinate of the source vector
  3001. * @param transformation defines the transformation matrix
  3002. * @param result defines the Vector3 where to store the result
  3003. */
  3004. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3005. /**
  3006. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  3007. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3008. * @param vector defines the Vector3 to transform
  3009. * @param transformation defines the transformation matrix
  3010. * @returns the new Vector3
  3011. */
  3012. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3013. /**
  3014. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  3015. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3016. * @param vector defines the Vector3 to transform
  3017. * @param transformation defines the transformation matrix
  3018. * @param result defines the Vector3 where to store the result
  3019. */
  3020. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3021. /**
  3022. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  3023. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3024. * @param x define the x coordinate of the source vector
  3025. * @param y define the y coordinate of the source vector
  3026. * @param z define the z coordinate of the source vector
  3027. * @param transformation defines the transformation matrix
  3028. * @param result defines the Vector3 where to store the result
  3029. */
  3030. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3031. /**
  3032. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  3033. * @param value1 defines the first control point
  3034. * @param value2 defines the second control point
  3035. * @param value3 defines the third control point
  3036. * @param value4 defines the fourth control point
  3037. * @param amount defines the amount on the spline to use
  3038. * @returns the new Vector3
  3039. */
  3040. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  3041. /**
  3042. * 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"
  3043. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3044. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3045. * @param value defines the current value
  3046. * @param min defines the lower range value
  3047. * @param max defines the upper range value
  3048. * @returns the new Vector3
  3049. */
  3050. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  3051. /**
  3052. * 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"
  3053. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3054. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3055. * @param value defines the current value
  3056. * @param min defines the lower range value
  3057. * @param max defines the upper range value
  3058. * @param result defines the Vector3 where to store the result
  3059. */
  3060. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  3061. /**
  3062. * Checks if a given vector is inside a specific range
  3063. * @param v defines the vector to test
  3064. * @param min defines the minimum range
  3065. * @param max defines the maximum range
  3066. */
  3067. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3068. /**
  3069. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3070. * @param value1 defines the first control point
  3071. * @param tangent1 defines the first tangent vector
  3072. * @param value2 defines the second control point
  3073. * @param tangent2 defines the second tangent vector
  3074. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3075. * @returns the new Vector3
  3076. */
  3077. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3078. /**
  3079. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3080. * @param start defines the start value
  3081. * @param end defines the end value
  3082. * @param amount max defines amount between both (between 0 and 1)
  3083. * @returns the new Vector3
  3084. */
  3085. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3086. /**
  3087. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3088. * @param start defines the start value
  3089. * @param end defines the end value
  3090. * @param amount max defines amount between both (between 0 and 1)
  3091. * @param result defines the Vector3 where to store the result
  3092. */
  3093. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3094. /**
  3095. * Returns the dot product (float) between the vectors "left" and "right"
  3096. * @param left defines the left operand
  3097. * @param right defines the right operand
  3098. * @returns the dot product
  3099. */
  3100. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3101. /**
  3102. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3103. * The cross product is then orthogonal to both "left" and "right"
  3104. * @param left defines the left operand
  3105. * @param right defines the right operand
  3106. * @returns the cross product
  3107. */
  3108. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3109. /**
  3110. * Sets the given vector "result" with the cross product of "left" and "right"
  3111. * The cross product is then orthogonal to both "left" and "right"
  3112. * @param left defines the left operand
  3113. * @param right defines the right operand
  3114. * @param result defines the Vector3 where to store the result
  3115. */
  3116. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  3117. /**
  3118. * Returns a new Vector3 as the normalization of the given vector
  3119. * @param vector defines the Vector3 to normalize
  3120. * @returns the new Vector3
  3121. */
  3122. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3123. /**
  3124. * Sets the given vector "result" with the normalization of the given first vector
  3125. * @param vector defines the Vector3 to normalize
  3126. * @param result defines the Vector3 where to store the result
  3127. */
  3128. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3129. /**
  3130. * Project a Vector3 onto screen space
  3131. * @param vector defines the Vector3 to project
  3132. * @param world defines the world matrix to use
  3133. * @param transform defines the transform (view x projection) matrix to use
  3134. * @param viewport defines the screen viewport to use
  3135. * @returns the new Vector3
  3136. */
  3137. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3138. /** @hidden */
  3139. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3140. /**
  3141. * Unproject from screen space to object space
  3142. * @param source defines the screen space Vector3 to use
  3143. * @param viewportWidth defines the current width of the viewport
  3144. * @param viewportHeight defines the current height of the viewport
  3145. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3146. * @param transform defines the transform (view x projection) matrix to use
  3147. * @returns the new Vector3
  3148. */
  3149. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3150. /**
  3151. * Unproject from screen space to object space
  3152. * @param source defines the screen space Vector3 to use
  3153. * @param viewportWidth defines the current width of the viewport
  3154. * @param viewportHeight defines the current height of the viewport
  3155. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3156. * @param view defines the view matrix to use
  3157. * @param projection defines the projection matrix to use
  3158. * @returns the new Vector3
  3159. */
  3160. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3161. /**
  3162. * Unproject from screen space to object space
  3163. * @param source defines the screen space Vector3 to use
  3164. * @param viewportWidth defines the current width of the viewport
  3165. * @param viewportHeight defines the current height of the viewport
  3166. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3167. * @param view defines the view matrix to use
  3168. * @param projection defines the projection matrix to use
  3169. * @param result defines the Vector3 where to store the result
  3170. */
  3171. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3172. /**
  3173. * Unproject from screen space to object space
  3174. * @param sourceX defines the screen space x coordinate to use
  3175. * @param sourceY defines the screen space y coordinate to use
  3176. * @param sourceZ defines the screen space z coordinate to use
  3177. * @param viewportWidth defines the current width of the viewport
  3178. * @param viewportHeight defines the current height of the viewport
  3179. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3180. * @param view defines the view matrix to use
  3181. * @param projection defines the projection matrix to use
  3182. * @param result defines the Vector3 where to store the result
  3183. */
  3184. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3185. /**
  3186. * Gets the minimal coordinate values between two Vector3
  3187. * @param left defines the first operand
  3188. * @param right defines the second operand
  3189. * @returns the new Vector3
  3190. */
  3191. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3192. /**
  3193. * Gets the maximal coordinate values between two Vector3
  3194. * @param left defines the first operand
  3195. * @param right defines the second operand
  3196. * @returns the new Vector3
  3197. */
  3198. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3199. /**
  3200. * Returns the distance between the vectors "value1" and "value2"
  3201. * @param value1 defines the first operand
  3202. * @param value2 defines the second operand
  3203. * @returns the distance
  3204. */
  3205. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3206. /**
  3207. * Returns the squared distance between the vectors "value1" and "value2"
  3208. * @param value1 defines the first operand
  3209. * @param value2 defines the second operand
  3210. * @returns the squared distance
  3211. */
  3212. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3213. /**
  3214. * Returns a new Vector3 located at the center between "value1" and "value2"
  3215. * @param value1 defines the first operand
  3216. * @param value2 defines the second operand
  3217. * @returns the new Vector3
  3218. */
  3219. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3220. /**
  3221. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3222. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3223. * to something in order to rotate it from its local system to the given target system
  3224. * Note: axis1, axis2 and axis3 are normalized during this operation
  3225. * @param axis1 defines the first axis
  3226. * @param axis2 defines the second axis
  3227. * @param axis3 defines the third axis
  3228. * @returns a new Vector3
  3229. */
  3230. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3231. /**
  3232. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3233. * @param axis1 defines the first axis
  3234. * @param axis2 defines the second axis
  3235. * @param axis3 defines the third axis
  3236. * @param ref defines the Vector3 where to store the result
  3237. */
  3238. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3239. }
  3240. /**
  3241. * Vector4 class created for EulerAngle class conversion to Quaternion
  3242. */
  3243. export class Vector4 {
  3244. /** x value of the vector */
  3245. x: number;
  3246. /** y value of the vector */
  3247. y: number;
  3248. /** z value of the vector */
  3249. z: number;
  3250. /** w value of the vector */
  3251. w: number;
  3252. /**
  3253. * Creates a Vector4 object from the given floats.
  3254. * @param x x value of the vector
  3255. * @param y y value of the vector
  3256. * @param z z value of the vector
  3257. * @param w w value of the vector
  3258. */
  3259. constructor(
  3260. /** x value of the vector */
  3261. x: number,
  3262. /** y value of the vector */
  3263. y: number,
  3264. /** z value of the vector */
  3265. z: number,
  3266. /** w value of the vector */
  3267. w: number);
  3268. /**
  3269. * Returns the string with the Vector4 coordinates.
  3270. * @returns a string containing all the vector values
  3271. */
  3272. toString(): string;
  3273. /**
  3274. * Returns the string "Vector4".
  3275. * @returns "Vector4"
  3276. */
  3277. getClassName(): string;
  3278. /**
  3279. * Returns the Vector4 hash code.
  3280. * @returns a unique hash code
  3281. */
  3282. getHashCode(): number;
  3283. /**
  3284. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3285. * @returns the resulting array
  3286. */
  3287. asArray(): number[];
  3288. /**
  3289. * Populates the given array from the given index with the Vector4 coordinates.
  3290. * @param array array to populate
  3291. * @param index index of the array to start at (default: 0)
  3292. * @returns the Vector4.
  3293. */
  3294. toArray(array: FloatArray, index?: number): Vector4;
  3295. /**
  3296. * Update the current vector from an array
  3297. * @param array defines the destination array
  3298. * @param index defines the offset in the destination array
  3299. * @returns the current Vector3
  3300. */
  3301. fromArray(array: FloatArray, index?: number): Vector4;
  3302. /**
  3303. * Adds the given vector to the current Vector4.
  3304. * @param otherVector the vector to add
  3305. * @returns the updated Vector4.
  3306. */
  3307. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3308. /**
  3309. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3310. * @param otherVector the vector to add
  3311. * @returns the resulting vector
  3312. */
  3313. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3314. /**
  3315. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3316. * @param otherVector the vector to add
  3317. * @param result the vector to store the result
  3318. * @returns the current Vector4.
  3319. */
  3320. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3321. /**
  3322. * Subtract in place the given vector from the current Vector4.
  3323. * @param otherVector the vector to subtract
  3324. * @returns the updated Vector4.
  3325. */
  3326. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3327. /**
  3328. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3329. * @param otherVector the vector to add
  3330. * @returns the new vector with the result
  3331. */
  3332. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3333. /**
  3334. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3335. * @param otherVector the vector to subtract
  3336. * @param result the vector to store the result
  3337. * @returns the current Vector4.
  3338. */
  3339. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3340. /**
  3341. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3342. */
  3343. /**
  3344. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3345. * @param x value to subtract
  3346. * @param y value to subtract
  3347. * @param z value to subtract
  3348. * @param w value to subtract
  3349. * @returns new vector containing the result
  3350. */
  3351. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3352. /**
  3353. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3354. * @param x value to subtract
  3355. * @param y value to subtract
  3356. * @param z value to subtract
  3357. * @param w value to subtract
  3358. * @param result the vector to store the result in
  3359. * @returns the current Vector4.
  3360. */
  3361. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3362. /**
  3363. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3364. * @returns a new vector with the negated values
  3365. */
  3366. negate(): Vector4;
  3367. /**
  3368. * Negate this vector in place
  3369. * @returns this
  3370. */
  3371. negateInPlace(): Vector4;
  3372. /**
  3373. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3374. * @param result defines the Vector3 object where to store the result
  3375. * @returns the current Vector4
  3376. */
  3377. negateToRef(result: Vector4): Vector4;
  3378. /**
  3379. * Multiplies the current Vector4 coordinates by scale (float).
  3380. * @param scale the number to scale with
  3381. * @returns the updated Vector4.
  3382. */
  3383. scaleInPlace(scale: number): Vector4;
  3384. /**
  3385. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3386. * @param scale the number to scale with
  3387. * @returns a new vector with the result
  3388. */
  3389. scale(scale: number): Vector4;
  3390. /**
  3391. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3392. * @param scale the number to scale with
  3393. * @param result a vector to store the result in
  3394. * @returns the current Vector4.
  3395. */
  3396. scaleToRef(scale: number, result: Vector4): Vector4;
  3397. /**
  3398. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3399. * @param scale defines the scale factor
  3400. * @param result defines the Vector4 object where to store the result
  3401. * @returns the unmodified current Vector4
  3402. */
  3403. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3404. /**
  3405. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3406. * @param otherVector the vector to compare against
  3407. * @returns true if they are equal
  3408. */
  3409. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3410. /**
  3411. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3412. * @param otherVector vector to compare against
  3413. * @param epsilon (Default: very small number)
  3414. * @returns true if they are equal
  3415. */
  3416. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3417. /**
  3418. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3419. * @param x x value to compare against
  3420. * @param y y value to compare against
  3421. * @param z z value to compare against
  3422. * @param w w value to compare against
  3423. * @returns true if equal
  3424. */
  3425. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3426. /**
  3427. * Multiplies in place the current Vector4 by the given one.
  3428. * @param otherVector vector to multiple with
  3429. * @returns the updated Vector4.
  3430. */
  3431. multiplyInPlace(otherVector: Vector4): Vector4;
  3432. /**
  3433. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3434. * @param otherVector vector to multiple with
  3435. * @returns resulting new vector
  3436. */
  3437. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3438. /**
  3439. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3440. * @param otherVector vector to multiple with
  3441. * @param result vector to store the result
  3442. * @returns the current Vector4.
  3443. */
  3444. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3445. /**
  3446. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3447. * @param x x value multiply with
  3448. * @param y y value multiply with
  3449. * @param z z value multiply with
  3450. * @param w w value multiply with
  3451. * @returns resulting new vector
  3452. */
  3453. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3454. /**
  3455. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3456. * @param otherVector vector to devide with
  3457. * @returns resulting new vector
  3458. */
  3459. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3460. /**
  3461. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3462. * @param otherVector vector to devide with
  3463. * @param result vector to store the result
  3464. * @returns the current Vector4.
  3465. */
  3466. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3467. /**
  3468. * Divides the current Vector3 coordinates by the given ones.
  3469. * @param otherVector vector to devide with
  3470. * @returns the updated Vector3.
  3471. */
  3472. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3473. /**
  3474. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3475. * @param other defines the second operand
  3476. * @returns the current updated Vector4
  3477. */
  3478. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3479. /**
  3480. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3481. * @param other defines the second operand
  3482. * @returns the current updated Vector4
  3483. */
  3484. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3485. /**
  3486. * Gets a new Vector4 from current Vector4 floored values
  3487. * @returns a new Vector4
  3488. */
  3489. floor(): Vector4;
  3490. /**
  3491. * Gets a new Vector4 from current Vector3 floored values
  3492. * @returns a new Vector4
  3493. */
  3494. fract(): Vector4;
  3495. /**
  3496. * Returns the Vector4 length (float).
  3497. * @returns the length
  3498. */
  3499. length(): number;
  3500. /**
  3501. * Returns the Vector4 squared length (float).
  3502. * @returns the length squared
  3503. */
  3504. lengthSquared(): number;
  3505. /**
  3506. * Normalizes in place the Vector4.
  3507. * @returns the updated Vector4.
  3508. */
  3509. normalize(): Vector4;
  3510. /**
  3511. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3512. * @returns this converted to a new vector3
  3513. */
  3514. toVector3(): Vector3;
  3515. /**
  3516. * Returns a new Vector4 copied from the current one.
  3517. * @returns the new cloned vector
  3518. */
  3519. clone(): Vector4;
  3520. /**
  3521. * Updates the current Vector4 with the given one coordinates.
  3522. * @param source the source vector to copy from
  3523. * @returns the updated Vector4.
  3524. */
  3525. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3526. /**
  3527. * Updates the current Vector4 coordinates with the given floats.
  3528. * @param x float to copy from
  3529. * @param y float to copy from
  3530. * @param z float to copy from
  3531. * @param w float to copy from
  3532. * @returns the updated Vector4.
  3533. */
  3534. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3535. /**
  3536. * Updates the current Vector4 coordinates with the given floats.
  3537. * @param x float to set from
  3538. * @param y float to set from
  3539. * @param z float to set from
  3540. * @param w float to set from
  3541. * @returns the updated Vector4.
  3542. */
  3543. set(x: number, y: number, z: number, w: number): Vector4;
  3544. /**
  3545. * Copies the given float to the current Vector3 coordinates
  3546. * @param v defines the x, y, z and w coordinates of the operand
  3547. * @returns the current updated Vector3
  3548. */
  3549. setAll(v: number): Vector4;
  3550. /**
  3551. * Returns a new Vector4 set from the starting index of the given array.
  3552. * @param array the array to pull values from
  3553. * @param offset the offset into the array to start at
  3554. * @returns the new vector
  3555. */
  3556. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3557. /**
  3558. * Updates the given vector "result" from the starting index of the given array.
  3559. * @param array the array to pull values from
  3560. * @param offset the offset into the array to start at
  3561. * @param result the vector to store the result in
  3562. */
  3563. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3564. /**
  3565. * Updates the given vector "result" from the starting index of the given Float32Array.
  3566. * @param array the array to pull values from
  3567. * @param offset the offset into the array to start at
  3568. * @param result the vector to store the result in
  3569. */
  3570. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3571. /**
  3572. * Updates the given vector "result" coordinates from the given floats.
  3573. * @param x float to set from
  3574. * @param y float to set from
  3575. * @param z float to set from
  3576. * @param w float to set from
  3577. * @param result the vector to the floats in
  3578. */
  3579. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3580. /**
  3581. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3582. * @returns the new vector
  3583. */
  3584. static Zero(): Vector4;
  3585. /**
  3586. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3587. * @returns the new vector
  3588. */
  3589. static One(): Vector4;
  3590. /**
  3591. * Returns a new normalized Vector4 from the given one.
  3592. * @param vector the vector to normalize
  3593. * @returns the vector
  3594. */
  3595. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3596. /**
  3597. * Updates the given vector "result" from the normalization of the given one.
  3598. * @param vector the vector to normalize
  3599. * @param result the vector to store the result in
  3600. */
  3601. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3602. /**
  3603. * Returns a vector with the minimum values from the left and right vectors
  3604. * @param left left vector to minimize
  3605. * @param right right vector to minimize
  3606. * @returns a new vector with the minimum of the left and right vector values
  3607. */
  3608. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3609. /**
  3610. * Returns a vector with the maximum values from the left and right vectors
  3611. * @param left left vector to maximize
  3612. * @param right right vector to maximize
  3613. * @returns a new vector with the maximum of the left and right vector values
  3614. */
  3615. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3616. /**
  3617. * Returns the distance (float) between the vectors "value1" and "value2".
  3618. * @param value1 value to calulate the distance between
  3619. * @param value2 value to calulate the distance between
  3620. * @return the distance between the two vectors
  3621. */
  3622. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3623. /**
  3624. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3625. * @param value1 value to calulate the distance between
  3626. * @param value2 value to calulate the distance between
  3627. * @return the distance between the two vectors squared
  3628. */
  3629. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3630. /**
  3631. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3632. * @param value1 value to calulate the center between
  3633. * @param value2 value to calulate the center between
  3634. * @return the center between the two vectors
  3635. */
  3636. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3637. /**
  3638. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3639. * This methods computes transformed normalized direction vectors only.
  3640. * @param vector the vector to transform
  3641. * @param transformation the transformation matrix to apply
  3642. * @returns the new vector
  3643. */
  3644. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3645. /**
  3646. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3647. * This methods computes transformed normalized direction vectors only.
  3648. * @param vector the vector to transform
  3649. * @param transformation the transformation matrix to apply
  3650. * @param result the vector to store the result in
  3651. */
  3652. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3653. /**
  3654. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3655. * This methods computes transformed normalized direction vectors only.
  3656. * @param x value to transform
  3657. * @param y value to transform
  3658. * @param z value to transform
  3659. * @param w value to transform
  3660. * @param transformation the transformation matrix to apply
  3661. * @param result the vector to store the results in
  3662. */
  3663. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3664. /**
  3665. * Creates a new Vector4 from a Vector3
  3666. * @param source defines the source data
  3667. * @param w defines the 4th component (default is 0)
  3668. * @returns a new Vector4
  3669. */
  3670. static FromVector3(source: Vector3, w?: number): Vector4;
  3671. }
  3672. /**
  3673. * Class used to store quaternion data
  3674. * @see https://en.wikipedia.org/wiki/Quaternion
  3675. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  3676. */
  3677. export class Quaternion {
  3678. /** @hidden */
  3679. _x: number;
  3680. /** @hidden */
  3681. _y: number;
  3682. /** @hidden */
  3683. _z: number;
  3684. /** @hidden */
  3685. _w: number;
  3686. /** @hidden */
  3687. _isDirty: boolean;
  3688. /** Gets or sets the x coordinate */
  3689. get x(): number;
  3690. set x(value: number);
  3691. /** Gets or sets the y coordinate */
  3692. get y(): number;
  3693. set y(value: number);
  3694. /** Gets or sets the z coordinate */
  3695. get z(): number;
  3696. set z(value: number);
  3697. /** Gets or sets the w coordinate */
  3698. get w(): number;
  3699. set w(value: number);
  3700. /**
  3701. * Creates a new Quaternion from the given floats
  3702. * @param x defines the first component (0 by default)
  3703. * @param y defines the second component (0 by default)
  3704. * @param z defines the third component (0 by default)
  3705. * @param w defines the fourth component (1.0 by default)
  3706. */
  3707. constructor(x?: number, y?: number, z?: number, w?: number);
  3708. /**
  3709. * Gets a string representation for the current quaternion
  3710. * @returns a string with the Quaternion coordinates
  3711. */
  3712. toString(): string;
  3713. /**
  3714. * Gets the class name of the quaternion
  3715. * @returns the string "Quaternion"
  3716. */
  3717. getClassName(): string;
  3718. /**
  3719. * Gets a hash code for this quaternion
  3720. * @returns the quaternion hash code
  3721. */
  3722. getHashCode(): number;
  3723. /**
  3724. * Copy the quaternion to an array
  3725. * @returns a new array populated with 4 elements from the quaternion coordinates
  3726. */
  3727. asArray(): number[];
  3728. /**
  3729. * Check if two quaternions are equals
  3730. * @param otherQuaternion defines the second operand
  3731. * @return true if the current quaternion and the given one coordinates are strictly equals
  3732. */
  3733. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3734. /**
  3735. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3736. * @param otherQuaternion defines the other quaternion
  3737. * @param epsilon defines the minimal distance to consider equality
  3738. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3739. */
  3740. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3741. /**
  3742. * Clone the current quaternion
  3743. * @returns a new quaternion copied from the current one
  3744. */
  3745. clone(): Quaternion;
  3746. /**
  3747. * Copy a quaternion to the current one
  3748. * @param other defines the other quaternion
  3749. * @returns the updated current quaternion
  3750. */
  3751. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3752. /**
  3753. * Updates the current quaternion with the given float coordinates
  3754. * @param x defines the x coordinate
  3755. * @param y defines the y coordinate
  3756. * @param z defines the z coordinate
  3757. * @param w defines the w coordinate
  3758. * @returns the updated current quaternion
  3759. */
  3760. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3761. /**
  3762. * Updates the current quaternion from the given float coordinates
  3763. * @param x defines the x coordinate
  3764. * @param y defines the y coordinate
  3765. * @param z defines the z coordinate
  3766. * @param w defines the w coordinate
  3767. * @returns the updated current quaternion
  3768. */
  3769. set(x: number, y: number, z: number, w: number): Quaternion;
  3770. /**
  3771. * Adds two quaternions
  3772. * @param other defines the second operand
  3773. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3774. */
  3775. add(other: DeepImmutable<Quaternion>): Quaternion;
  3776. /**
  3777. * Add a quaternion to the current one
  3778. * @param other defines the quaternion to add
  3779. * @returns the current quaternion
  3780. */
  3781. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3782. /**
  3783. * Subtract two quaternions
  3784. * @param other defines the second operand
  3785. * @returns a new quaternion as the subtraction result of the given one from the current one
  3786. */
  3787. subtract(other: Quaternion): Quaternion;
  3788. /**
  3789. * Multiplies the current quaternion by a scale factor
  3790. * @param value defines the scale factor
  3791. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3792. */
  3793. scale(value: number): Quaternion;
  3794. /**
  3795. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3796. * @param scale defines the scale factor
  3797. * @param result defines the Quaternion object where to store the result
  3798. * @returns the unmodified current quaternion
  3799. */
  3800. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3801. /**
  3802. * Multiplies in place the current quaternion by a scale factor
  3803. * @param value defines the scale factor
  3804. * @returns the current modified quaternion
  3805. */
  3806. scaleInPlace(value: number): Quaternion;
  3807. /**
  3808. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3809. * @param scale defines the scale factor
  3810. * @param result defines the Quaternion object where to store the result
  3811. * @returns the unmodified current quaternion
  3812. */
  3813. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3814. /**
  3815. * Multiplies two quaternions
  3816. * @param q1 defines the second operand
  3817. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3818. */
  3819. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3820. /**
  3821. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3822. * @param q1 defines the second operand
  3823. * @param result defines the target quaternion
  3824. * @returns the current quaternion
  3825. */
  3826. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3827. /**
  3828. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3829. * @param q1 defines the second operand
  3830. * @returns the currentupdated quaternion
  3831. */
  3832. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3833. /**
  3834. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3835. * @param ref defines the target quaternion
  3836. * @returns the current quaternion
  3837. */
  3838. conjugateToRef(ref: Quaternion): Quaternion;
  3839. /**
  3840. * Conjugates in place (1-q) the current quaternion
  3841. * @returns the current updated quaternion
  3842. */
  3843. conjugateInPlace(): Quaternion;
  3844. /**
  3845. * Conjugates in place (1-q) the current quaternion
  3846. * @returns a new quaternion
  3847. */
  3848. conjugate(): Quaternion;
  3849. /**
  3850. * Gets length of current quaternion
  3851. * @returns the quaternion length (float)
  3852. */
  3853. length(): number;
  3854. /**
  3855. * Normalize in place the current quaternion
  3856. * @returns the current updated quaternion
  3857. */
  3858. normalize(): Quaternion;
  3859. /**
  3860. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3861. * @param order is a reserved parameter and is ignored for now
  3862. * @returns a new Vector3 containing the Euler angles
  3863. */
  3864. toEulerAngles(order?: string): Vector3;
  3865. /**
  3866. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3867. * @param result defines the vector which will be filled with the Euler angles
  3868. * @returns the current unchanged quaternion
  3869. */
  3870. toEulerAnglesToRef(result: Vector3): Quaternion;
  3871. /**
  3872. * Updates the given rotation matrix with the current quaternion values
  3873. * @param result defines the target matrix
  3874. * @returns the current unchanged quaternion
  3875. */
  3876. toRotationMatrix(result: Matrix): Quaternion;
  3877. /**
  3878. * Updates the current quaternion from the given rotation matrix values
  3879. * @param matrix defines the source matrix
  3880. * @returns the current updated quaternion
  3881. */
  3882. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3883. /**
  3884. * Creates a new quaternion from a rotation matrix
  3885. * @param matrix defines the source matrix
  3886. * @returns a new quaternion created from the given rotation matrix values
  3887. */
  3888. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3889. /**
  3890. * Updates the given quaternion with the given rotation matrix values
  3891. * @param matrix defines the source matrix
  3892. * @param result defines the target quaternion
  3893. */
  3894. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3895. /**
  3896. * Returns the dot product (float) between the quaternions "left" and "right"
  3897. * @param left defines the left operand
  3898. * @param right defines the right operand
  3899. * @returns the dot product
  3900. */
  3901. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3902. /**
  3903. * Checks if the two quaternions are close to each other
  3904. * @param quat0 defines the first quaternion to check
  3905. * @param quat1 defines the second quaternion to check
  3906. * @returns true if the two quaternions are close to each other
  3907. */
  3908. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3909. /**
  3910. * Creates an empty quaternion
  3911. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3912. */
  3913. static Zero(): Quaternion;
  3914. /**
  3915. * Inverse a given quaternion
  3916. * @param q defines the source quaternion
  3917. * @returns a new quaternion as the inverted current quaternion
  3918. */
  3919. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3920. /**
  3921. * Inverse a given quaternion
  3922. * @param q defines the source quaternion
  3923. * @param result the quaternion the result will be stored in
  3924. * @returns the result quaternion
  3925. */
  3926. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3927. /**
  3928. * Creates an identity quaternion
  3929. * @returns the identity quaternion
  3930. */
  3931. static Identity(): Quaternion;
  3932. /**
  3933. * Gets a boolean indicating if the given quaternion is identity
  3934. * @param quaternion defines the quaternion to check
  3935. * @returns true if the quaternion is identity
  3936. */
  3937. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3938. /**
  3939. * Creates a quaternion from a rotation around an axis
  3940. * @param axis defines the axis to use
  3941. * @param angle defines the angle to use
  3942. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3943. */
  3944. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3945. /**
  3946. * Creates a rotation around an axis and stores it into the given quaternion
  3947. * @param axis defines the axis to use
  3948. * @param angle defines the angle to use
  3949. * @param result defines the target quaternion
  3950. * @returns the target quaternion
  3951. */
  3952. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3953. /**
  3954. * Creates a new quaternion from data stored into an array
  3955. * @param array defines the data source
  3956. * @param offset defines the offset in the source array where the data starts
  3957. * @returns a new quaternion
  3958. */
  3959. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3960. /**
  3961. * Updates the given quaternion "result" from the starting index of the given array.
  3962. * @param array the array to pull values from
  3963. * @param offset the offset into the array to start at
  3964. * @param result the quaternion to store the result in
  3965. */
  3966. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3967. /**
  3968. * Create a quaternion from Euler rotation angles
  3969. * @param x Pitch
  3970. * @param y Yaw
  3971. * @param z Roll
  3972. * @returns the new Quaternion
  3973. */
  3974. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3975. /**
  3976. * Updates a quaternion from Euler rotation angles
  3977. * @param x Pitch
  3978. * @param y Yaw
  3979. * @param z Roll
  3980. * @param result the quaternion to store the result
  3981. * @returns the updated quaternion
  3982. */
  3983. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3984. /**
  3985. * Create a quaternion from Euler rotation vector
  3986. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3987. * @returns the new Quaternion
  3988. */
  3989. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3990. /**
  3991. * Updates a quaternion from Euler rotation vector
  3992. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3993. * @param result the quaternion to store the result
  3994. * @returns the updated quaternion
  3995. */
  3996. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3997. /**
  3998. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3999. * @param yaw defines the rotation around Y axis
  4000. * @param pitch defines the rotation around X axis
  4001. * @param roll defines the rotation around Z axis
  4002. * @returns the new quaternion
  4003. */
  4004. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  4005. /**
  4006. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  4007. * @param yaw defines the rotation around Y axis
  4008. * @param pitch defines the rotation around X axis
  4009. * @param roll defines the rotation around Z axis
  4010. * @param result defines the target quaternion
  4011. */
  4012. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  4013. /**
  4014. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  4015. * @param alpha defines the rotation around first axis
  4016. * @param beta defines the rotation around second axis
  4017. * @param gamma defines the rotation around third axis
  4018. * @returns the new quaternion
  4019. */
  4020. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  4021. /**
  4022. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  4023. * @param alpha defines the rotation around first axis
  4024. * @param beta defines the rotation around second axis
  4025. * @param gamma defines the rotation around third axis
  4026. * @param result defines the target quaternion
  4027. */
  4028. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  4029. /**
  4030. * 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)
  4031. * @param axis1 defines the first axis
  4032. * @param axis2 defines the second axis
  4033. * @param axis3 defines the third axis
  4034. * @returns the new quaternion
  4035. */
  4036. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  4037. /**
  4038. * 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
  4039. * @param axis1 defines the first axis
  4040. * @param axis2 defines the second axis
  4041. * @param axis3 defines the third axis
  4042. * @param ref defines the target quaternion
  4043. */
  4044. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  4045. /**
  4046. * Interpolates between two quaternions
  4047. * @param left defines first quaternion
  4048. * @param right defines second quaternion
  4049. * @param amount defines the gradient to use
  4050. * @returns the new interpolated quaternion
  4051. */
  4052. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4053. /**
  4054. * Interpolates between two quaternions and stores it into a target quaternion
  4055. * @param left defines first quaternion
  4056. * @param right defines second quaternion
  4057. * @param amount defines the gradient to use
  4058. * @param result defines the target quaternion
  4059. */
  4060. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  4061. /**
  4062. * Interpolate between two quaternions using Hermite interpolation
  4063. * @param value1 defines first quaternion
  4064. * @param tangent1 defines the incoming tangent
  4065. * @param value2 defines second quaternion
  4066. * @param tangent2 defines the outgoing tangent
  4067. * @param amount defines the target quaternion
  4068. * @returns the new interpolated quaternion
  4069. */
  4070. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4071. }
  4072. /**
  4073. * Class used to store matrix data (4x4)
  4074. */
  4075. export class Matrix {
  4076. /**
  4077. * Gets the precision of matrix computations
  4078. */
  4079. static get Use64Bits(): boolean;
  4080. private static _updateFlagSeed;
  4081. private static _identityReadOnly;
  4082. private _isIdentity;
  4083. private _isIdentityDirty;
  4084. private _isIdentity3x2;
  4085. private _isIdentity3x2Dirty;
  4086. /**
  4087. * Gets the update flag of the matrix which is an unique number for the matrix.
  4088. * It will be incremented every time the matrix data change.
  4089. * You can use it to speed the comparison between two versions of the same matrix.
  4090. */
  4091. updateFlag: number;
  4092. private readonly _m;
  4093. /**
  4094. * Gets the internal data of the matrix
  4095. */
  4096. get m(): DeepImmutable<Float32Array | Array<number>>;
  4097. /** @hidden */
  4098. _markAsUpdated(): void;
  4099. /** @hidden */
  4100. private _updateIdentityStatus;
  4101. /**
  4102. * Creates an empty matrix (filled with zeros)
  4103. */
  4104. constructor();
  4105. /**
  4106. * Check if the current matrix is identity
  4107. * @returns true is the matrix is the identity matrix
  4108. */
  4109. isIdentity(): boolean;
  4110. /**
  4111. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4112. * @returns true is the matrix is the identity matrix
  4113. */
  4114. isIdentityAs3x2(): boolean;
  4115. /**
  4116. * Gets the determinant of the matrix
  4117. * @returns the matrix determinant
  4118. */
  4119. determinant(): number;
  4120. /**
  4121. * Returns the matrix as a Float32Array or Array<number>
  4122. * @returns the matrix underlying array
  4123. */
  4124. toArray(): DeepImmutable<Float32Array | Array<number>>;
  4125. /**
  4126. * Returns the matrix as a Float32Array or Array<number>
  4127. * @returns the matrix underlying array.
  4128. */
  4129. asArray(): DeepImmutable<Float32Array | Array<number>>;
  4130. /**
  4131. * Inverts the current matrix in place
  4132. * @returns the current inverted matrix
  4133. */
  4134. invert(): Matrix;
  4135. /**
  4136. * Sets all the matrix elements to zero
  4137. * @returns the current matrix
  4138. */
  4139. reset(): Matrix;
  4140. /**
  4141. * Adds the current matrix with a second one
  4142. * @param other defines the matrix to add
  4143. * @returns a new matrix as the addition of the current matrix and the given one
  4144. */
  4145. add(other: DeepImmutable<Matrix>): Matrix;
  4146. /**
  4147. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4148. * @param other defines the matrix to add
  4149. * @param result defines the target matrix
  4150. * @returns the current matrix
  4151. */
  4152. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4153. /**
  4154. * Adds in place the given matrix to the current matrix
  4155. * @param other defines the second operand
  4156. * @returns the current updated matrix
  4157. */
  4158. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4159. /**
  4160. * Sets the given matrix to the current inverted Matrix
  4161. * @param other defines the target matrix
  4162. * @returns the unmodified current matrix
  4163. */
  4164. invertToRef(other: Matrix): Matrix;
  4165. /**
  4166. * add a value at the specified position in the current Matrix
  4167. * @param index the index of the value within the matrix. between 0 and 15.
  4168. * @param value the value to be added
  4169. * @returns the current updated matrix
  4170. */
  4171. addAtIndex(index: number, value: number): Matrix;
  4172. /**
  4173. * mutiply the specified position in the current Matrix by a value
  4174. * @param index the index of the value within the matrix. between 0 and 15.
  4175. * @param value the value to be added
  4176. * @returns the current updated matrix
  4177. */
  4178. multiplyAtIndex(index: number, value: number): Matrix;
  4179. /**
  4180. * Inserts the translation vector (using 3 floats) in the current matrix
  4181. * @param x defines the 1st component of the translation
  4182. * @param y defines the 2nd component of the translation
  4183. * @param z defines the 3rd component of the translation
  4184. * @returns the current updated matrix
  4185. */
  4186. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4187. /**
  4188. * Adds the translation vector (using 3 floats) in the current matrix
  4189. * @param x defines the 1st component of the translation
  4190. * @param y defines the 2nd component of the translation
  4191. * @param z defines the 3rd component of the translation
  4192. * @returns the current updated matrix
  4193. */
  4194. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4195. /**
  4196. * Inserts the translation vector in the current matrix
  4197. * @param vector3 defines the translation to insert
  4198. * @returns the current updated matrix
  4199. */
  4200. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4201. /**
  4202. * Gets the translation value of the current matrix
  4203. * @returns a new Vector3 as the extracted translation from the matrix
  4204. */
  4205. getTranslation(): Vector3;
  4206. /**
  4207. * Fill a Vector3 with the extracted translation from the matrix
  4208. * @param result defines the Vector3 where to store the translation
  4209. * @returns the current matrix
  4210. */
  4211. getTranslationToRef(result: Vector3): Matrix;
  4212. /**
  4213. * Remove rotation and scaling part from the matrix
  4214. * @returns the updated matrix
  4215. */
  4216. removeRotationAndScaling(): Matrix;
  4217. /**
  4218. * Multiply two matrices
  4219. * @param other defines the second operand
  4220. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4221. */
  4222. multiply(other: DeepImmutable<Matrix>): Matrix;
  4223. /**
  4224. * Copy the current matrix from the given one
  4225. * @param other defines the source matrix
  4226. * @returns the current updated matrix
  4227. */
  4228. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4229. /**
  4230. * Populates the given array from the starting index with the current matrix values
  4231. * @param array defines the target array
  4232. * @param offset defines the offset in the target array where to start storing values
  4233. * @returns the current matrix
  4234. */
  4235. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  4236. /**
  4237. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4238. * @param other defines the second operand
  4239. * @param result defines the matrix where to store the multiplication
  4240. * @returns the current matrix
  4241. */
  4242. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4243. /**
  4244. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4245. * @param other defines the second operand
  4246. * @param result defines the array where to store the multiplication
  4247. * @param offset defines the offset in the target array where to start storing values
  4248. * @returns the current matrix
  4249. */
  4250. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  4251. /**
  4252. * Check equality between this matrix and a second one
  4253. * @param value defines the second matrix to compare
  4254. * @returns true is the current matrix and the given one values are strictly equal
  4255. */
  4256. equals(value: DeepImmutable<Matrix>): boolean;
  4257. /**
  4258. * Clone the current matrix
  4259. * @returns a new matrix from the current matrix
  4260. */
  4261. clone(): Matrix;
  4262. /**
  4263. * Returns the name of the current matrix class
  4264. * @returns the string "Matrix"
  4265. */
  4266. getClassName(): string;
  4267. /**
  4268. * Gets the hash code of the current matrix
  4269. * @returns the hash code
  4270. */
  4271. getHashCode(): number;
  4272. /**
  4273. * Decomposes the current Matrix into a translation, rotation and scaling components
  4274. * @param scale defines the scale vector3 given as a reference to update
  4275. * @param rotation defines the rotation quaternion given as a reference to update
  4276. * @param translation defines the translation vector3 given as a reference to update
  4277. * @returns true if operation was successful
  4278. */
  4279. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4280. /**
  4281. * Gets specific row of the matrix
  4282. * @param index defines the number of the row to get
  4283. * @returns the index-th row of the current matrix as a new Vector4
  4284. */
  4285. getRow(index: number): Nullable<Vector4>;
  4286. /**
  4287. * Sets the index-th row of the current matrix to the vector4 values
  4288. * @param index defines the number of the row to set
  4289. * @param row defines the target vector4
  4290. * @returns the updated current matrix
  4291. */
  4292. setRow(index: number, row: Vector4): Matrix;
  4293. /**
  4294. * Compute the transpose of the matrix
  4295. * @returns the new transposed matrix
  4296. */
  4297. transpose(): Matrix;
  4298. /**
  4299. * Compute the transpose of the matrix and store it in a given matrix
  4300. * @param result defines the target matrix
  4301. * @returns the current matrix
  4302. */
  4303. transposeToRef(result: Matrix): Matrix;
  4304. /**
  4305. * Sets the index-th row of the current matrix with the given 4 x float values
  4306. * @param index defines the row index
  4307. * @param x defines the x component to set
  4308. * @param y defines the y component to set
  4309. * @param z defines the z component to set
  4310. * @param w defines the w component to set
  4311. * @returns the updated current matrix
  4312. */
  4313. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4314. /**
  4315. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4316. * @param scale defines the scale factor
  4317. * @returns a new matrix
  4318. */
  4319. scale(scale: number): Matrix;
  4320. /**
  4321. * Scale the current matrix values by a factor to a given result matrix
  4322. * @param scale defines the scale factor
  4323. * @param result defines the matrix to store the result
  4324. * @returns the current matrix
  4325. */
  4326. scaleToRef(scale: number, result: Matrix): Matrix;
  4327. /**
  4328. * Scale the current matrix values by a factor and add the result to a given matrix
  4329. * @param scale defines the scale factor
  4330. * @param result defines the Matrix to store the result
  4331. * @returns the current matrix
  4332. */
  4333. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4334. /**
  4335. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4336. * @param ref matrix to store the result
  4337. */
  4338. toNormalMatrix(ref: Matrix): void;
  4339. /**
  4340. * Gets only rotation part of the current matrix
  4341. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4342. */
  4343. getRotationMatrix(): Matrix;
  4344. /**
  4345. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4346. * @param result defines the target matrix to store data to
  4347. * @returns the current matrix
  4348. */
  4349. getRotationMatrixToRef(result: Matrix): Matrix;
  4350. /**
  4351. * Toggles model matrix from being right handed to left handed in place and vice versa
  4352. */
  4353. toggleModelMatrixHandInPlace(): void;
  4354. /**
  4355. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4356. */
  4357. toggleProjectionMatrixHandInPlace(): void;
  4358. /**
  4359. * Creates a matrix from an array
  4360. * @param array defines the source array
  4361. * @param offset defines an offset in the source array
  4362. * @returns a new Matrix set from the starting index of the given array
  4363. */
  4364. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4365. /**
  4366. * Copy the content of an array into a given matrix
  4367. * @param array defines the source array
  4368. * @param offset defines an offset in the source array
  4369. * @param result defines the target matrix
  4370. */
  4371. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4372. /**
  4373. * Stores an array into a matrix after having multiplied each component by a given factor
  4374. * @param array defines the source array
  4375. * @param offset defines the offset in the source array
  4376. * @param scale defines the scaling factor
  4377. * @param result defines the target matrix
  4378. */
  4379. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  4380. /**
  4381. * Gets an identity matrix that must not be updated
  4382. */
  4383. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4384. /**
  4385. * Stores a list of values (16) inside a given matrix
  4386. * @param initialM11 defines 1st value of 1st row
  4387. * @param initialM12 defines 2nd value of 1st row
  4388. * @param initialM13 defines 3rd value of 1st row
  4389. * @param initialM14 defines 4th value of 1st row
  4390. * @param initialM21 defines 1st value of 2nd row
  4391. * @param initialM22 defines 2nd value of 2nd row
  4392. * @param initialM23 defines 3rd value of 2nd row
  4393. * @param initialM24 defines 4th value of 2nd row
  4394. * @param initialM31 defines 1st value of 3rd row
  4395. * @param initialM32 defines 2nd value of 3rd row
  4396. * @param initialM33 defines 3rd value of 3rd row
  4397. * @param initialM34 defines 4th value of 3rd row
  4398. * @param initialM41 defines 1st value of 4th row
  4399. * @param initialM42 defines 2nd value of 4th row
  4400. * @param initialM43 defines 3rd value of 4th row
  4401. * @param initialM44 defines 4th value of 4th row
  4402. * @param result defines the target matrix
  4403. */
  4404. 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;
  4405. /**
  4406. * Creates new matrix from a list of values (16)
  4407. * @param initialM11 defines 1st value of 1st row
  4408. * @param initialM12 defines 2nd value of 1st row
  4409. * @param initialM13 defines 3rd value of 1st row
  4410. * @param initialM14 defines 4th value of 1st row
  4411. * @param initialM21 defines 1st value of 2nd row
  4412. * @param initialM22 defines 2nd value of 2nd row
  4413. * @param initialM23 defines 3rd value of 2nd row
  4414. * @param initialM24 defines 4th value of 2nd row
  4415. * @param initialM31 defines 1st value of 3rd row
  4416. * @param initialM32 defines 2nd value of 3rd row
  4417. * @param initialM33 defines 3rd value of 3rd row
  4418. * @param initialM34 defines 4th value of 3rd row
  4419. * @param initialM41 defines 1st value of 4th row
  4420. * @param initialM42 defines 2nd value of 4th row
  4421. * @param initialM43 defines 3rd value of 4th row
  4422. * @param initialM44 defines 4th value of 4th row
  4423. * @returns the new matrix
  4424. */
  4425. 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;
  4426. /**
  4427. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4428. * @param scale defines the scale vector3
  4429. * @param rotation defines the rotation quaternion
  4430. * @param translation defines the translation vector3
  4431. * @returns a new matrix
  4432. */
  4433. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4434. /**
  4435. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4436. * @param scale defines the scale vector3
  4437. * @param rotation defines the rotation quaternion
  4438. * @param translation defines the translation vector3
  4439. * @param result defines the target matrix
  4440. */
  4441. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4442. /**
  4443. * Creates a new identity matrix
  4444. * @returns a new identity matrix
  4445. */
  4446. static Identity(): Matrix;
  4447. /**
  4448. * Creates a new identity matrix and stores the result in a given matrix
  4449. * @param result defines the target matrix
  4450. */
  4451. static IdentityToRef(result: Matrix): void;
  4452. /**
  4453. * Creates a new zero matrix
  4454. * @returns a new zero matrix
  4455. */
  4456. static Zero(): Matrix;
  4457. /**
  4458. * Creates a new rotation matrix for "angle" radians around the X axis
  4459. * @param angle defines the angle (in radians) to use
  4460. * @return the new matrix
  4461. */
  4462. static RotationX(angle: number): Matrix;
  4463. /**
  4464. * Creates a new matrix as the invert of a given matrix
  4465. * @param source defines the source matrix
  4466. * @returns the new matrix
  4467. */
  4468. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4469. /**
  4470. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4471. * @param angle defines the angle (in radians) to use
  4472. * @param result defines the target matrix
  4473. */
  4474. static RotationXToRef(angle: number, result: Matrix): void;
  4475. /**
  4476. * Creates a new rotation matrix for "angle" radians around the Y axis
  4477. * @param angle defines the angle (in radians) to use
  4478. * @return the new matrix
  4479. */
  4480. static RotationY(angle: number): Matrix;
  4481. /**
  4482. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4483. * @param angle defines the angle (in radians) to use
  4484. * @param result defines the target matrix
  4485. */
  4486. static RotationYToRef(angle: number, result: Matrix): void;
  4487. /**
  4488. * Creates a new rotation matrix for "angle" radians around the Z axis
  4489. * @param angle defines the angle (in radians) to use
  4490. * @return the new matrix
  4491. */
  4492. static RotationZ(angle: number): Matrix;
  4493. /**
  4494. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4495. * @param angle defines the angle (in radians) to use
  4496. * @param result defines the target matrix
  4497. */
  4498. static RotationZToRef(angle: number, result: Matrix): void;
  4499. /**
  4500. * Creates a new rotation matrix for "angle" radians around the given axis
  4501. * @param axis defines the axis to use
  4502. * @param angle defines the angle (in radians) to use
  4503. * @return the new matrix
  4504. */
  4505. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4506. /**
  4507. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4508. * @param axis defines the axis to use
  4509. * @param angle defines the angle (in radians) to use
  4510. * @param result defines the target matrix
  4511. */
  4512. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4513. /**
  4514. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4515. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4516. * @param from defines the vector to align
  4517. * @param to defines the vector to align to
  4518. * @param result defines the target matrix
  4519. */
  4520. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4521. /**
  4522. * Creates a rotation matrix
  4523. * @param yaw defines the yaw angle in radians (Y axis)
  4524. * @param pitch defines the pitch angle in radians (X axis)
  4525. * @param roll defines the roll angle in radians (Z axis)
  4526. * @returns the new rotation matrix
  4527. */
  4528. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4529. /**
  4530. * Creates a rotation matrix and stores it in a given matrix
  4531. * @param yaw defines the yaw angle in radians (Y axis)
  4532. * @param pitch defines the pitch angle in radians (X axis)
  4533. * @param roll defines the roll angle in radians (Z axis)
  4534. * @param result defines the target matrix
  4535. */
  4536. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4537. /**
  4538. * Creates a scaling matrix
  4539. * @param x defines the scale factor on X axis
  4540. * @param y defines the scale factor on Y axis
  4541. * @param z defines the scale factor on Z axis
  4542. * @returns the new matrix
  4543. */
  4544. static Scaling(x: number, y: number, z: number): Matrix;
  4545. /**
  4546. * Creates a scaling matrix and stores it in a given matrix
  4547. * @param x defines the scale factor on X axis
  4548. * @param y defines the scale factor on Y axis
  4549. * @param z defines the scale factor on Z axis
  4550. * @param result defines the target matrix
  4551. */
  4552. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4553. /**
  4554. * Creates a translation matrix
  4555. * @param x defines the translation on X axis
  4556. * @param y defines the translation on Y axis
  4557. * @param z defines the translationon Z axis
  4558. * @returns the new matrix
  4559. */
  4560. static Translation(x: number, y: number, z: number): Matrix;
  4561. /**
  4562. * Creates a translation matrix and stores it in a given matrix
  4563. * @param x defines the translation on X axis
  4564. * @param y defines the translation on Y axis
  4565. * @param z defines the translationon Z axis
  4566. * @param result defines the target matrix
  4567. */
  4568. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4569. /**
  4570. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4571. * @param startValue defines the start value
  4572. * @param endValue defines the end value
  4573. * @param gradient defines the gradient factor
  4574. * @returns the new matrix
  4575. */
  4576. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4577. /**
  4578. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4579. * @param startValue defines the start value
  4580. * @param endValue defines the end value
  4581. * @param gradient defines the gradient factor
  4582. * @param result defines the Matrix object where to store data
  4583. */
  4584. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4585. /**
  4586. * Builds a new matrix whose values are computed by:
  4587. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4588. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4589. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4590. * @param startValue defines the first matrix
  4591. * @param endValue defines the second matrix
  4592. * @param gradient defines the gradient between the two matrices
  4593. * @returns the new matrix
  4594. */
  4595. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4596. /**
  4597. * Update a matrix to values which are computed by:
  4598. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4599. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4600. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4601. * @param startValue defines the first matrix
  4602. * @param endValue defines the second matrix
  4603. * @param gradient defines the gradient between the two matrices
  4604. * @param result defines the target matrix
  4605. */
  4606. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4607. /**
  4608. * 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"
  4609. * This function works in left handed mode
  4610. * @param eye defines the final position of the entity
  4611. * @param target defines where the entity should look at
  4612. * @param up defines the up vector for the entity
  4613. * @returns the new matrix
  4614. */
  4615. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4616. /**
  4617. * 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".
  4618. * This function works in left handed mode
  4619. * @param eye defines the final position of the entity
  4620. * @param target defines where the entity should look at
  4621. * @param up defines the up vector for the entity
  4622. * @param result defines the target matrix
  4623. */
  4624. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4625. /**
  4626. * 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"
  4627. * This function works in right handed mode
  4628. * @param eye defines the final position of the entity
  4629. * @param target defines where the entity should look at
  4630. * @param up defines the up vector for the entity
  4631. * @returns the new matrix
  4632. */
  4633. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4634. /**
  4635. * 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".
  4636. * This function works in right handed mode
  4637. * @param eye defines the final position of the entity
  4638. * @param target defines where the entity should look at
  4639. * @param up defines the up vector for the entity
  4640. * @param result defines the target matrix
  4641. */
  4642. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4643. /**
  4644. * Create a left-handed orthographic projection matrix
  4645. * @param width defines the viewport width
  4646. * @param height defines the viewport height
  4647. * @param znear defines the near clip plane
  4648. * @param zfar defines the far clip plane
  4649. * @returns a new matrix as a left-handed orthographic projection matrix
  4650. */
  4651. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4652. /**
  4653. * Store a left-handed orthographic projection to a given matrix
  4654. * @param width defines the viewport width
  4655. * @param height defines the viewport height
  4656. * @param znear defines the near clip plane
  4657. * @param zfar defines the far clip plane
  4658. * @param result defines the target matrix
  4659. */
  4660. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4661. /**
  4662. * Create a left-handed orthographic projection matrix
  4663. * @param left defines the viewport left coordinate
  4664. * @param right defines the viewport right coordinate
  4665. * @param bottom defines the viewport bottom coordinate
  4666. * @param top defines the viewport top coordinate
  4667. * @param znear defines the near clip plane
  4668. * @param zfar defines the far clip plane
  4669. * @returns a new matrix as a left-handed orthographic projection matrix
  4670. */
  4671. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4672. /**
  4673. * Stores a left-handed orthographic projection into a given matrix
  4674. * @param left defines the viewport left coordinate
  4675. * @param right defines the viewport right coordinate
  4676. * @param bottom defines the viewport bottom coordinate
  4677. * @param top defines the viewport top coordinate
  4678. * @param znear defines the near clip plane
  4679. * @param zfar defines the far clip plane
  4680. * @param result defines the target matrix
  4681. */
  4682. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4683. /**
  4684. * Creates a right-handed orthographic projection matrix
  4685. * @param left defines the viewport left coordinate
  4686. * @param right defines the viewport right coordinate
  4687. * @param bottom defines the viewport bottom coordinate
  4688. * @param top defines the viewport top coordinate
  4689. * @param znear defines the near clip plane
  4690. * @param zfar defines the far clip plane
  4691. * @returns a new matrix as a right-handed orthographic projection matrix
  4692. */
  4693. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4694. /**
  4695. * Stores a right-handed orthographic projection into a given matrix
  4696. * @param left defines the viewport left coordinate
  4697. * @param right defines the viewport right coordinate
  4698. * @param bottom defines the viewport bottom coordinate
  4699. * @param top defines the viewport top coordinate
  4700. * @param znear defines the near clip plane
  4701. * @param zfar defines the far clip plane
  4702. * @param result defines the target matrix
  4703. */
  4704. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4705. /**
  4706. * Creates a left-handed perspective projection matrix
  4707. * @param width defines the viewport width
  4708. * @param height defines the viewport height
  4709. * @param znear defines the near clip plane
  4710. * @param zfar defines the far clip plane
  4711. * @returns a new matrix as a left-handed perspective projection matrix
  4712. */
  4713. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4714. /**
  4715. * Creates a left-handed perspective projection matrix
  4716. * @param fov defines the horizontal field of view
  4717. * @param aspect defines the aspect ratio
  4718. * @param znear defines the near clip plane
  4719. * @param zfar defines the far clip plane
  4720. * @returns a new matrix as a left-handed perspective projection matrix
  4721. */
  4722. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4723. /**
  4724. * Stores a left-handed perspective projection into a given matrix
  4725. * @param fov defines the horizontal field of view
  4726. * @param aspect defines the aspect ratio
  4727. * @param znear defines the near clip plane
  4728. * @param zfar defines the far clip plane
  4729. * @param result defines the target matrix
  4730. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4731. */
  4732. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4733. /**
  4734. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4735. * @param fov defines the horizontal field of view
  4736. * @param aspect defines the aspect ratio
  4737. * @param znear defines the near clip plane
  4738. * @param zfar not used as infinity is used as far clip
  4739. * @param result defines the target matrix
  4740. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4741. */
  4742. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4743. /**
  4744. * Creates a right-handed perspective projection matrix
  4745. * @param fov defines the horizontal field of view
  4746. * @param aspect defines the aspect ratio
  4747. * @param znear defines the near clip plane
  4748. * @param zfar defines the far clip plane
  4749. * @returns a new matrix as a right-handed perspective projection matrix
  4750. */
  4751. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4752. /**
  4753. * Stores a right-handed perspective projection into a given matrix
  4754. * @param fov defines the horizontal field of view
  4755. * @param aspect defines the aspect ratio
  4756. * @param znear defines the near clip plane
  4757. * @param zfar defines the far clip plane
  4758. * @param result defines the target matrix
  4759. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4760. */
  4761. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4762. /**
  4763. * Stores a right-handed perspective projection into a given matrix
  4764. * @param fov defines the horizontal field of view
  4765. * @param aspect defines the aspect ratio
  4766. * @param znear defines the near clip plane
  4767. * @param zfar not used as infinity is used as far clip
  4768. * @param result defines the target matrix
  4769. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4770. */
  4771. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4772. /**
  4773. * Stores a perspective projection for WebVR info a given matrix
  4774. * @param fov defines the field of view
  4775. * @param znear defines the near clip plane
  4776. * @param zfar defines the far clip plane
  4777. * @param result defines the target matrix
  4778. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4779. */
  4780. static PerspectiveFovWebVRToRef(fov: {
  4781. upDegrees: number;
  4782. downDegrees: number;
  4783. leftDegrees: number;
  4784. rightDegrees: number;
  4785. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4786. /**
  4787. * Computes a complete transformation matrix
  4788. * @param viewport defines the viewport to use
  4789. * @param world defines the world matrix
  4790. * @param view defines the view matrix
  4791. * @param projection defines the projection matrix
  4792. * @param zmin defines the near clip plane
  4793. * @param zmax defines the far clip plane
  4794. * @returns the transformation matrix
  4795. */
  4796. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4797. /**
  4798. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4799. * @param matrix defines the matrix to use
  4800. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4801. */
  4802. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4803. /**
  4804. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4805. * @param matrix defines the matrix to use
  4806. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4807. */
  4808. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4809. /**
  4810. * Compute the transpose of a given matrix
  4811. * @param matrix defines the matrix to transpose
  4812. * @returns the new matrix
  4813. */
  4814. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4815. /**
  4816. * Compute the transpose of a matrix and store it in a target matrix
  4817. * @param matrix defines the matrix to transpose
  4818. * @param result defines the target matrix
  4819. */
  4820. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4821. /**
  4822. * Computes a reflection matrix from a plane
  4823. * @param plane defines the reflection plane
  4824. * @returns a new matrix
  4825. */
  4826. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4827. /**
  4828. * Computes a reflection matrix from a plane
  4829. * @param plane defines the reflection plane
  4830. * @param result defines the target matrix
  4831. */
  4832. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4833. /**
  4834. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4835. * @param xaxis defines the value of the 1st axis
  4836. * @param yaxis defines the value of the 2nd axis
  4837. * @param zaxis defines the value of the 3rd axis
  4838. * @param result defines the target matrix
  4839. */
  4840. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4841. /**
  4842. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4843. * @param quat defines the quaternion to use
  4844. * @param result defines the target matrix
  4845. */
  4846. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4847. }
  4848. /**
  4849. * @hidden
  4850. */
  4851. export class TmpVectors {
  4852. static Vector2: Vector2[];
  4853. static Vector3: Vector3[];
  4854. static Vector4: Vector4[];
  4855. static Quaternion: Quaternion[];
  4856. static Matrix: Matrix[];
  4857. }
  4858. }
  4859. declare module BABYLON {
  4860. /**
  4861. * Defines potential orientation for back face culling
  4862. */
  4863. export enum Orientation {
  4864. /**
  4865. * Clockwise
  4866. */
  4867. CW = 0,
  4868. /** Counter clockwise */
  4869. CCW = 1
  4870. }
  4871. /** Class used to represent a Bezier curve */
  4872. export class BezierCurve {
  4873. /**
  4874. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4875. * @param t defines the time
  4876. * @param x1 defines the left coordinate on X axis
  4877. * @param y1 defines the left coordinate on Y axis
  4878. * @param x2 defines the right coordinate on X axis
  4879. * @param y2 defines the right coordinate on Y axis
  4880. * @returns the interpolated value
  4881. */
  4882. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4883. }
  4884. /**
  4885. * Defines angle representation
  4886. */
  4887. export class Angle {
  4888. private _radians;
  4889. /**
  4890. * Creates an Angle object of "radians" radians (float).
  4891. * @param radians the angle in radians
  4892. */
  4893. constructor(radians: number);
  4894. /**
  4895. * Get value in degrees
  4896. * @returns the Angle value in degrees (float)
  4897. */
  4898. degrees(): number;
  4899. /**
  4900. * Get value in radians
  4901. * @returns the Angle value in radians (float)
  4902. */
  4903. radians(): number;
  4904. /**
  4905. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  4906. * @param a defines first point as the origin
  4907. * @param b defines point
  4908. * @returns a new Angle
  4909. */
  4910. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4911. /**
  4912. * Gets a new Angle object from the given float in radians
  4913. * @param radians defines the angle value in radians
  4914. * @returns a new Angle
  4915. */
  4916. static FromRadians(radians: number): Angle;
  4917. /**
  4918. * Gets a new Angle object from the given float in degrees
  4919. * @param degrees defines the angle value in degrees
  4920. * @returns a new Angle
  4921. */
  4922. static FromDegrees(degrees: number): Angle;
  4923. }
  4924. /**
  4925. * This represents an arc in a 2d space.
  4926. */
  4927. export class Arc2 {
  4928. /** Defines the start point of the arc */
  4929. startPoint: Vector2;
  4930. /** Defines the mid point of the arc */
  4931. midPoint: Vector2;
  4932. /** Defines the end point of the arc */
  4933. endPoint: Vector2;
  4934. /**
  4935. * Defines the center point of the arc.
  4936. */
  4937. centerPoint: Vector2;
  4938. /**
  4939. * Defines the radius of the arc.
  4940. */
  4941. radius: number;
  4942. /**
  4943. * Defines the angle of the arc (from mid point to end point).
  4944. */
  4945. angle: Angle;
  4946. /**
  4947. * Defines the start angle of the arc (from start point to middle point).
  4948. */
  4949. startAngle: Angle;
  4950. /**
  4951. * Defines the orientation of the arc (clock wise/counter clock wise).
  4952. */
  4953. orientation: Orientation;
  4954. /**
  4955. * Creates an Arc object from the three given points : start, middle and end.
  4956. * @param startPoint Defines the start point of the arc
  4957. * @param midPoint Defines the midlle point of the arc
  4958. * @param endPoint Defines the end point of the arc
  4959. */
  4960. constructor(
  4961. /** Defines the start point of the arc */
  4962. startPoint: Vector2,
  4963. /** Defines the mid point of the arc */
  4964. midPoint: Vector2,
  4965. /** Defines the end point of the arc */
  4966. endPoint: Vector2);
  4967. }
  4968. /**
  4969. * Represents a 2D path made up of multiple 2D points
  4970. */
  4971. export class Path2 {
  4972. private _points;
  4973. private _length;
  4974. /**
  4975. * If the path start and end point are the same
  4976. */
  4977. closed: boolean;
  4978. /**
  4979. * Creates a Path2 object from the starting 2D coordinates x and y.
  4980. * @param x the starting points x value
  4981. * @param y the starting points y value
  4982. */
  4983. constructor(x: number, y: number);
  4984. /**
  4985. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  4986. * @param x the added points x value
  4987. * @param y the added points y value
  4988. * @returns the updated Path2.
  4989. */
  4990. addLineTo(x: number, y: number): Path2;
  4991. /**
  4992. * 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.
  4993. * @param midX middle point x value
  4994. * @param midY middle point y value
  4995. * @param endX end point x value
  4996. * @param endY end point y value
  4997. * @param numberOfSegments (default: 36)
  4998. * @returns the updated Path2.
  4999. */
  5000. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5001. /**
  5002. * Closes the Path2.
  5003. * @returns the Path2.
  5004. */
  5005. close(): Path2;
  5006. /**
  5007. * Gets the sum of the distance between each sequential point in the path
  5008. * @returns the Path2 total length (float).
  5009. */
  5010. length(): number;
  5011. /**
  5012. * Gets the points which construct the path
  5013. * @returns the Path2 internal array of points.
  5014. */
  5015. getPoints(): Vector2[];
  5016. /**
  5017. * Retreives the point at the distance aways from the starting point
  5018. * @param normalizedLengthPosition the length along the path to retreive the point from
  5019. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5020. */
  5021. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5022. /**
  5023. * Creates a new path starting from an x and y position
  5024. * @param x starting x value
  5025. * @param y starting y value
  5026. * @returns a new Path2 starting at the coordinates (x, y).
  5027. */
  5028. static StartingAt(x: number, y: number): Path2;
  5029. }
  5030. /**
  5031. * Represents a 3D path made up of multiple 3D points
  5032. */
  5033. export class Path3D {
  5034. /**
  5035. * an array of Vector3, the curve axis of the Path3D
  5036. */
  5037. path: Vector3[];
  5038. private _curve;
  5039. private _distances;
  5040. private _tangents;
  5041. private _normals;
  5042. private _binormals;
  5043. private _raw;
  5044. private _alignTangentsWithPath;
  5045. private readonly _pointAtData;
  5046. /**
  5047. * new Path3D(path, normal, raw)
  5048. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5049. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5050. * @param path an array of Vector3, the curve axis of the Path3D
  5051. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5052. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5053. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  5054. */
  5055. constructor(
  5056. /**
  5057. * an array of Vector3, the curve axis of the Path3D
  5058. */
  5059. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  5060. /**
  5061. * Returns the Path3D array of successive Vector3 designing its curve.
  5062. * @returns the Path3D array of successive Vector3 designing its curve.
  5063. */
  5064. getCurve(): Vector3[];
  5065. /**
  5066. * Returns the Path3D array of successive Vector3 designing its curve.
  5067. * @returns the Path3D array of successive Vector3 designing its curve.
  5068. */
  5069. getPoints(): Vector3[];
  5070. /**
  5071. * @returns the computed length (float) of the path.
  5072. */
  5073. length(): number;
  5074. /**
  5075. * Returns an array populated with tangent vectors on each Path3D curve point.
  5076. * @returns an array populated with tangent vectors on each Path3D curve point.
  5077. */
  5078. getTangents(): Vector3[];
  5079. /**
  5080. * Returns an array populated with normal vectors on each Path3D curve point.
  5081. * @returns an array populated with normal vectors on each Path3D curve point.
  5082. */
  5083. getNormals(): Vector3[];
  5084. /**
  5085. * Returns an array populated with binormal vectors on each Path3D curve point.
  5086. * @returns an array populated with binormal vectors on each Path3D curve point.
  5087. */
  5088. getBinormals(): Vector3[];
  5089. /**
  5090. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5091. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5092. */
  5093. getDistances(): number[];
  5094. /**
  5095. * Returns an interpolated point along this path
  5096. * @param position the position of the point along this path, from 0.0 to 1.0
  5097. * @returns a new Vector3 as the point
  5098. */
  5099. getPointAt(position: number): Vector3;
  5100. /**
  5101. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5102. * @param position the position of the point along this path, from 0.0 to 1.0
  5103. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5104. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5105. */
  5106. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5107. /**
  5108. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5109. * @param position the position of the point along this path, from 0.0 to 1.0
  5110. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5111. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5112. */
  5113. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5114. /**
  5115. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5116. * @param position the position of the point along this path, from 0.0 to 1.0
  5117. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5118. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5119. */
  5120. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5121. /**
  5122. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5123. * @param position the position of the point along this path, from 0.0 to 1.0
  5124. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5125. */
  5126. getDistanceAt(position: number): number;
  5127. /**
  5128. * Returns the array index of the previous point of an interpolated point along this path
  5129. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5130. * @returns the array index
  5131. */
  5132. getPreviousPointIndexAt(position: number): number;
  5133. /**
  5134. * 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)
  5135. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5136. * @returns the sub position
  5137. */
  5138. getSubPositionAt(position: number): number;
  5139. /**
  5140. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5141. * @param target the vector of which to get the closest position to
  5142. * @returns the position of the closest virtual point on this path to the target vector
  5143. */
  5144. getClosestPositionTo(target: Vector3): number;
  5145. /**
  5146. * Returns a sub path (slice) of this path
  5147. * @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
  5148. * @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
  5149. * @returns a sub path (slice) of this path
  5150. */
  5151. slice(start?: number, end?: number): Path3D;
  5152. /**
  5153. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5154. * @param path path which all values are copied into the curves points
  5155. * @param firstNormal which should be projected onto the curve
  5156. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5157. * @returns the same object updated.
  5158. */
  5159. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5160. private _compute;
  5161. private _getFirstNonNullVector;
  5162. private _getLastNonNullVector;
  5163. private _normalVector;
  5164. /**
  5165. * Updates the point at data for an interpolated point along this curve
  5166. * @param position the position of the point along this curve, from 0.0 to 1.0
  5167. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5168. * @returns the (updated) point at data
  5169. */
  5170. private _updatePointAtData;
  5171. /**
  5172. * Updates the point at data from the specified parameters
  5173. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5174. * @param point the interpolated point
  5175. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5176. */
  5177. private _setPointAtData;
  5178. /**
  5179. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5180. */
  5181. private _updateInterpolationMatrix;
  5182. }
  5183. /**
  5184. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5185. * A Curve3 is designed from a series of successive Vector3.
  5186. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5187. */
  5188. export class Curve3 {
  5189. private _points;
  5190. private _length;
  5191. /**
  5192. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5193. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5194. * @param v1 (Vector3) the control point
  5195. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5196. * @param nbPoints (integer) the wanted number of points in the curve
  5197. * @returns the created Curve3
  5198. */
  5199. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5200. /**
  5201. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5202. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5203. * @param v1 (Vector3) the first control point
  5204. * @param v2 (Vector3) the second control point
  5205. * @param v3 (Vector3) the end point of the Cubic Bezier
  5206. * @param nbPoints (integer) the wanted number of points in the curve
  5207. * @returns the created Curve3
  5208. */
  5209. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5210. /**
  5211. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5212. * @param p1 (Vector3) the origin point of the Hermite Spline
  5213. * @param t1 (Vector3) the tangent vector at the origin point
  5214. * @param p2 (Vector3) the end point of the Hermite Spline
  5215. * @param t2 (Vector3) the tangent vector at the end point
  5216. * @param nbPoints (integer) the wanted number of points in the curve
  5217. * @returns the created Curve3
  5218. */
  5219. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5220. /**
  5221. * Returns a Curve3 object along a CatmullRom Spline curve :
  5222. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5223. * @param nbPoints (integer) the wanted number of points between each curve control points
  5224. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5225. * @returns the created Curve3
  5226. */
  5227. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5228. /**
  5229. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5230. * A Curve3 is designed from a series of successive Vector3.
  5231. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5232. * @param points points which make up the curve
  5233. */
  5234. constructor(points: Vector3[]);
  5235. /**
  5236. * @returns the Curve3 stored array of successive Vector3
  5237. */
  5238. getPoints(): Vector3[];
  5239. /**
  5240. * @returns the computed length (float) of the curve.
  5241. */
  5242. length(): number;
  5243. /**
  5244. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5245. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5246. * curveA and curveB keep unchanged.
  5247. * @param curve the curve to continue from this curve
  5248. * @returns the newly constructed curve
  5249. */
  5250. continue(curve: DeepImmutable<Curve3>): Curve3;
  5251. private _computeLength;
  5252. }
  5253. }
  5254. declare module BABYLON {
  5255. /**
  5256. * This represents the main contract an easing function should follow.
  5257. * Easing functions are used throughout the animation system.
  5258. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5259. */
  5260. export interface IEasingFunction {
  5261. /**
  5262. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5263. * of the easing function.
  5264. * The link below provides some of the most common examples of easing functions.
  5265. * @see https://easings.net/
  5266. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5267. * @returns the corresponding value on the curve defined by the easing function
  5268. */
  5269. ease(gradient: number): number;
  5270. }
  5271. /**
  5272. * Base class used for every default easing function.
  5273. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5274. */
  5275. export class EasingFunction implements IEasingFunction {
  5276. /**
  5277. * Interpolation follows the mathematical formula associated with the easing function.
  5278. */
  5279. static readonly EASINGMODE_EASEIN: number;
  5280. /**
  5281. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5282. */
  5283. static readonly EASINGMODE_EASEOUT: number;
  5284. /**
  5285. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5286. */
  5287. static readonly EASINGMODE_EASEINOUT: number;
  5288. private _easingMode;
  5289. /**
  5290. * Sets the easing mode of the current function.
  5291. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5292. */
  5293. setEasingMode(easingMode: number): void;
  5294. /**
  5295. * Gets the current easing mode.
  5296. * @returns the easing mode
  5297. */
  5298. getEasingMode(): number;
  5299. /**
  5300. * @hidden
  5301. */
  5302. easeInCore(gradient: number): number;
  5303. /**
  5304. * Given an input gradient between 0 and 1, this returns the corresponding value
  5305. * of the easing function.
  5306. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5307. * @returns the corresponding value on the curve defined by the easing function
  5308. */
  5309. ease(gradient: number): number;
  5310. }
  5311. /**
  5312. * Easing function with a circle shape (see link below).
  5313. * @see https://easings.net/#easeInCirc
  5314. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5315. */
  5316. export class CircleEase extends EasingFunction implements IEasingFunction {
  5317. /** @hidden */
  5318. easeInCore(gradient: number): number;
  5319. }
  5320. /**
  5321. * Easing function with a ease back shape (see link below).
  5322. * @see https://easings.net/#easeInBack
  5323. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5324. */
  5325. export class BackEase extends EasingFunction implements IEasingFunction {
  5326. /** Defines the amplitude of the function */
  5327. amplitude: number;
  5328. /**
  5329. * Instantiates a back ease easing
  5330. * @see https://easings.net/#easeInBack
  5331. * @param amplitude Defines the amplitude of the function
  5332. */
  5333. constructor(
  5334. /** Defines the amplitude of the function */
  5335. amplitude?: number);
  5336. /** @hidden */
  5337. easeInCore(gradient: number): number;
  5338. }
  5339. /**
  5340. * Easing function with a bouncing shape (see link below).
  5341. * @see https://easings.net/#easeInBounce
  5342. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5343. */
  5344. export class BounceEase extends EasingFunction implements IEasingFunction {
  5345. /** Defines the number of bounces */
  5346. bounces: number;
  5347. /** Defines the amplitude of the bounce */
  5348. bounciness: number;
  5349. /**
  5350. * Instantiates a bounce easing
  5351. * @see https://easings.net/#easeInBounce
  5352. * @param bounces Defines the number of bounces
  5353. * @param bounciness Defines the amplitude of the bounce
  5354. */
  5355. constructor(
  5356. /** Defines the number of bounces */
  5357. bounces?: number,
  5358. /** Defines the amplitude of the bounce */
  5359. bounciness?: number);
  5360. /** @hidden */
  5361. easeInCore(gradient: number): number;
  5362. }
  5363. /**
  5364. * Easing function with a power of 3 shape (see link below).
  5365. * @see https://easings.net/#easeInCubic
  5366. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5367. */
  5368. export class CubicEase extends EasingFunction implements IEasingFunction {
  5369. /** @hidden */
  5370. easeInCore(gradient: number): number;
  5371. }
  5372. /**
  5373. * Easing function with an elastic shape (see link below).
  5374. * @see https://easings.net/#easeInElastic
  5375. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5376. */
  5377. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5378. /** Defines the number of oscillations*/
  5379. oscillations: number;
  5380. /** Defines the amplitude of the oscillations*/
  5381. springiness: number;
  5382. /**
  5383. * Instantiates an elastic easing function
  5384. * @see https://easings.net/#easeInElastic
  5385. * @param oscillations Defines the number of oscillations
  5386. * @param springiness Defines the amplitude of the oscillations
  5387. */
  5388. constructor(
  5389. /** Defines the number of oscillations*/
  5390. oscillations?: number,
  5391. /** Defines the amplitude of the oscillations*/
  5392. springiness?: number);
  5393. /** @hidden */
  5394. easeInCore(gradient: number): number;
  5395. }
  5396. /**
  5397. * Easing function with an exponential shape (see link below).
  5398. * @see https://easings.net/#easeInExpo
  5399. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5400. */
  5401. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5402. /** Defines the exponent of the function */
  5403. exponent: number;
  5404. /**
  5405. * Instantiates an exponential easing function
  5406. * @see https://easings.net/#easeInExpo
  5407. * @param exponent Defines the exponent of the function
  5408. */
  5409. constructor(
  5410. /** Defines the exponent of the function */
  5411. exponent?: number);
  5412. /** @hidden */
  5413. easeInCore(gradient: number): number;
  5414. }
  5415. /**
  5416. * Easing function with a power shape (see link below).
  5417. * @see https://easings.net/#easeInQuad
  5418. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5419. */
  5420. export class PowerEase extends EasingFunction implements IEasingFunction {
  5421. /** Defines the power of the function */
  5422. power: number;
  5423. /**
  5424. * Instantiates an power base easing function
  5425. * @see https://easings.net/#easeInQuad
  5426. * @param power Defines the power of the function
  5427. */
  5428. constructor(
  5429. /** Defines the power of the function */
  5430. power?: number);
  5431. /** @hidden */
  5432. easeInCore(gradient: number): number;
  5433. }
  5434. /**
  5435. * Easing function with a power of 2 shape (see link below).
  5436. * @see https://easings.net/#easeInQuad
  5437. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5438. */
  5439. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5440. /** @hidden */
  5441. easeInCore(gradient: number): number;
  5442. }
  5443. /**
  5444. * Easing function with a power of 4 shape (see link below).
  5445. * @see https://easings.net/#easeInQuart
  5446. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5447. */
  5448. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5449. /** @hidden */
  5450. easeInCore(gradient: number): number;
  5451. }
  5452. /**
  5453. * Easing function with a power of 5 shape (see link below).
  5454. * @see https://easings.net/#easeInQuint
  5455. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5456. */
  5457. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5458. /** @hidden */
  5459. easeInCore(gradient: number): number;
  5460. }
  5461. /**
  5462. * Easing function with a sin shape (see link below).
  5463. * @see https://easings.net/#easeInSine
  5464. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5465. */
  5466. export class SineEase extends EasingFunction implements IEasingFunction {
  5467. /** @hidden */
  5468. easeInCore(gradient: number): number;
  5469. }
  5470. /**
  5471. * Easing function with a bezier shape (see link below).
  5472. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5473. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5474. */
  5475. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5476. /** Defines the x component of the start tangent in the bezier curve */
  5477. x1: number;
  5478. /** Defines the y component of the start tangent in the bezier curve */
  5479. y1: number;
  5480. /** Defines the x component of the end tangent in the bezier curve */
  5481. x2: number;
  5482. /** Defines the y component of the end tangent in the bezier curve */
  5483. y2: number;
  5484. /**
  5485. * Instantiates a bezier function
  5486. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5487. * @param x1 Defines the x component of the start tangent in the bezier curve
  5488. * @param y1 Defines the y component of the start tangent in the bezier curve
  5489. * @param x2 Defines the x component of the end tangent in the bezier curve
  5490. * @param y2 Defines the y component of the end tangent in the bezier curve
  5491. */
  5492. constructor(
  5493. /** Defines the x component of the start tangent in the bezier curve */
  5494. x1?: number,
  5495. /** Defines the y component of the start tangent in the bezier curve */
  5496. y1?: number,
  5497. /** Defines the x component of the end tangent in the bezier curve */
  5498. x2?: number,
  5499. /** Defines the y component of the end tangent in the bezier curve */
  5500. y2?: number);
  5501. /** @hidden */
  5502. easeInCore(gradient: number): number;
  5503. }
  5504. }
  5505. declare module BABYLON {
  5506. /**
  5507. * Class used to hold a RBG color
  5508. */
  5509. export class Color3 {
  5510. /**
  5511. * Defines the red component (between 0 and 1, default is 0)
  5512. */
  5513. r: number;
  5514. /**
  5515. * Defines the green component (between 0 and 1, default is 0)
  5516. */
  5517. g: number;
  5518. /**
  5519. * Defines the blue component (between 0 and 1, default is 0)
  5520. */
  5521. b: number;
  5522. /**
  5523. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5524. * @param r defines the red component (between 0 and 1, default is 0)
  5525. * @param g defines the green component (between 0 and 1, default is 0)
  5526. * @param b defines the blue component (between 0 and 1, default is 0)
  5527. */
  5528. constructor(
  5529. /**
  5530. * Defines the red component (between 0 and 1, default is 0)
  5531. */
  5532. r?: number,
  5533. /**
  5534. * Defines the green component (between 0 and 1, default is 0)
  5535. */
  5536. g?: number,
  5537. /**
  5538. * Defines the blue component (between 0 and 1, default is 0)
  5539. */
  5540. b?: number);
  5541. /**
  5542. * Creates a string with the Color3 current values
  5543. * @returns the string representation of the Color3 object
  5544. */
  5545. toString(): string;
  5546. /**
  5547. * Returns the string "Color3"
  5548. * @returns "Color3"
  5549. */
  5550. getClassName(): string;
  5551. /**
  5552. * Compute the Color3 hash code
  5553. * @returns an unique number that can be used to hash Color3 objects
  5554. */
  5555. getHashCode(): number;
  5556. /**
  5557. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5558. * @param array defines the array where to store the r,g,b components
  5559. * @param index defines an optional index in the target array to define where to start storing values
  5560. * @returns the current Color3 object
  5561. */
  5562. toArray(array: FloatArray, index?: number): Color3;
  5563. /**
  5564. * Update the current color with values stored in an array from the starting index of the given array
  5565. * @param array defines the source array
  5566. * @param offset defines an offset in the source array
  5567. * @returns the current Color3 object
  5568. */
  5569. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5570. /**
  5571. * Returns a new Color4 object from the current Color3 and the given alpha
  5572. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5573. * @returns a new Color4 object
  5574. */
  5575. toColor4(alpha?: number): Color4;
  5576. /**
  5577. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5578. * @returns the new array
  5579. */
  5580. asArray(): number[];
  5581. /**
  5582. * Returns the luminance value
  5583. * @returns a float value
  5584. */
  5585. toLuminance(): number;
  5586. /**
  5587. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5588. * @param otherColor defines the second operand
  5589. * @returns the new Color3 object
  5590. */
  5591. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5592. /**
  5593. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5594. * @param otherColor defines the second operand
  5595. * @param result defines the Color3 object where to store the result
  5596. * @returns the current Color3
  5597. */
  5598. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5599. /**
  5600. * Determines equality between Color3 objects
  5601. * @param otherColor defines the second operand
  5602. * @returns true if the rgb values are equal to the given ones
  5603. */
  5604. equals(otherColor: DeepImmutable<Color3>): boolean;
  5605. /**
  5606. * Determines equality between the current Color3 object and a set of r,b,g values
  5607. * @param r defines the red component to check
  5608. * @param g defines the green component to check
  5609. * @param b defines the blue component to check
  5610. * @returns true if the rgb values are equal to the given ones
  5611. */
  5612. equalsFloats(r: number, g: number, b: number): boolean;
  5613. /**
  5614. * Multiplies in place each rgb value by scale
  5615. * @param scale defines the scaling factor
  5616. * @returns the updated Color3
  5617. */
  5618. scale(scale: number): Color3;
  5619. /**
  5620. * Multiplies the rgb values by scale and stores the result into "result"
  5621. * @param scale defines the scaling factor
  5622. * @param result defines the Color3 object where to store the result
  5623. * @returns the unmodified current Color3
  5624. */
  5625. scaleToRef(scale: number, result: Color3): Color3;
  5626. /**
  5627. * Scale the current Color3 values by a factor and add the result to a given Color3
  5628. * @param scale defines the scale factor
  5629. * @param result defines color to store the result into
  5630. * @returns the unmodified current Color3
  5631. */
  5632. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5633. /**
  5634. * Clamps the rgb values by the min and max values and stores the result into "result"
  5635. * @param min defines minimum clamping value (default is 0)
  5636. * @param max defines maximum clamping value (default is 1)
  5637. * @param result defines color to store the result into
  5638. * @returns the original Color3
  5639. */
  5640. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5641. /**
  5642. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5643. * @param otherColor defines the second operand
  5644. * @returns the new Color3
  5645. */
  5646. add(otherColor: DeepImmutable<Color3>): Color3;
  5647. /**
  5648. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5649. * @param otherColor defines the second operand
  5650. * @param result defines Color3 object to store the result into
  5651. * @returns the unmodified current Color3
  5652. */
  5653. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5654. /**
  5655. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5656. * @param otherColor defines the second operand
  5657. * @returns the new Color3
  5658. */
  5659. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5660. /**
  5661. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5662. * @param otherColor defines the second operand
  5663. * @param result defines Color3 object to store the result into
  5664. * @returns the unmodified current Color3
  5665. */
  5666. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5667. /**
  5668. * Copy the current object
  5669. * @returns a new Color3 copied the current one
  5670. */
  5671. clone(): Color3;
  5672. /**
  5673. * Copies the rgb values from the source in the current Color3
  5674. * @param source defines the source Color3 object
  5675. * @returns the updated Color3 object
  5676. */
  5677. copyFrom(source: DeepImmutable<Color3>): Color3;
  5678. /**
  5679. * Updates the Color3 rgb values from the given floats
  5680. * @param r defines the red component to read from
  5681. * @param g defines the green component to read from
  5682. * @param b defines the blue component to read from
  5683. * @returns the current Color3 object
  5684. */
  5685. copyFromFloats(r: number, g: number, b: number): Color3;
  5686. /**
  5687. * Updates the Color3 rgb values from the given floats
  5688. * @param r defines the red component to read from
  5689. * @param g defines the green component to read from
  5690. * @param b defines the blue component to read from
  5691. * @returns the current Color3 object
  5692. */
  5693. set(r: number, g: number, b: number): Color3;
  5694. /**
  5695. * Compute the Color3 hexadecimal code as a string
  5696. * @returns a string containing the hexadecimal representation of the Color3 object
  5697. */
  5698. toHexString(): string;
  5699. /**
  5700. * Computes a new Color3 converted from the current one to linear space
  5701. * @returns a new Color3 object
  5702. */
  5703. toLinearSpace(): Color3;
  5704. /**
  5705. * Converts current color in rgb space to HSV values
  5706. * @returns a new color3 representing the HSV values
  5707. */
  5708. toHSV(): Color3;
  5709. /**
  5710. * Converts current color in rgb space to HSV values
  5711. * @param result defines the Color3 where to store the HSV values
  5712. */
  5713. toHSVToRef(result: Color3): void;
  5714. /**
  5715. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5716. * @param convertedColor defines the Color3 object where to store the linear space version
  5717. * @returns the unmodified Color3
  5718. */
  5719. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5720. /**
  5721. * Computes a new Color3 converted from the current one to gamma space
  5722. * @returns a new Color3 object
  5723. */
  5724. toGammaSpace(): Color3;
  5725. /**
  5726. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5727. * @param convertedColor defines the Color3 object where to store the gamma space version
  5728. * @returns the unmodified Color3
  5729. */
  5730. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5731. private static _BlackReadOnly;
  5732. /**
  5733. * Convert Hue, saturation and value to a Color3 (RGB)
  5734. * @param hue defines the hue
  5735. * @param saturation defines the saturation
  5736. * @param value defines the value
  5737. * @param result defines the Color3 where to store the RGB values
  5738. */
  5739. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5740. /**
  5741. * Creates a new Color3 from the string containing valid hexadecimal values
  5742. * @param hex defines a string containing valid hexadecimal values
  5743. * @returns a new Color3 object
  5744. */
  5745. static FromHexString(hex: string): Color3;
  5746. /**
  5747. * Creates a new Color3 from the starting index of the given array
  5748. * @param array defines the source array
  5749. * @param offset defines an offset in the source array
  5750. * @returns a new Color3 object
  5751. */
  5752. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5753. /**
  5754. * Creates a new Color3 from the starting index element of the given array
  5755. * @param array defines the source array to read from
  5756. * @param offset defines the offset in the source array
  5757. * @param result defines the target Color3 object
  5758. */
  5759. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  5760. /**
  5761. * Creates a new Color3 from integer values (< 256)
  5762. * @param r defines the red component to read from (value between 0 and 255)
  5763. * @param g defines the green component to read from (value between 0 and 255)
  5764. * @param b defines the blue component to read from (value between 0 and 255)
  5765. * @returns a new Color3 object
  5766. */
  5767. static FromInts(r: number, g: number, b: number): Color3;
  5768. /**
  5769. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5770. * @param start defines the start Color3 value
  5771. * @param end defines the end Color3 value
  5772. * @param amount defines the gradient value between start and end
  5773. * @returns a new Color3 object
  5774. */
  5775. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5776. /**
  5777. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5778. * @param left defines the start value
  5779. * @param right defines the end value
  5780. * @param amount defines the gradient factor
  5781. * @param result defines the Color3 object where to store the result
  5782. */
  5783. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5784. /**
  5785. * Returns a Color3 value containing a red color
  5786. * @returns a new Color3 object
  5787. */
  5788. static Red(): Color3;
  5789. /**
  5790. * Returns a Color3 value containing a green color
  5791. * @returns a new Color3 object
  5792. */
  5793. static Green(): Color3;
  5794. /**
  5795. * Returns a Color3 value containing a blue color
  5796. * @returns a new Color3 object
  5797. */
  5798. static Blue(): Color3;
  5799. /**
  5800. * Returns a Color3 value containing a black color
  5801. * @returns a new Color3 object
  5802. */
  5803. static Black(): Color3;
  5804. /**
  5805. * Gets a Color3 value containing a black color that must not be updated
  5806. */
  5807. static get BlackReadOnly(): DeepImmutable<Color3>;
  5808. /**
  5809. * Returns a Color3 value containing a white color
  5810. * @returns a new Color3 object
  5811. */
  5812. static White(): Color3;
  5813. /**
  5814. * Returns a Color3 value containing a purple color
  5815. * @returns a new Color3 object
  5816. */
  5817. static Purple(): Color3;
  5818. /**
  5819. * Returns a Color3 value containing a magenta color
  5820. * @returns a new Color3 object
  5821. */
  5822. static Magenta(): Color3;
  5823. /**
  5824. * Returns a Color3 value containing a yellow color
  5825. * @returns a new Color3 object
  5826. */
  5827. static Yellow(): Color3;
  5828. /**
  5829. * Returns a Color3 value containing a gray color
  5830. * @returns a new Color3 object
  5831. */
  5832. static Gray(): Color3;
  5833. /**
  5834. * Returns a Color3 value containing a teal color
  5835. * @returns a new Color3 object
  5836. */
  5837. static Teal(): Color3;
  5838. /**
  5839. * Returns a Color3 value containing a random color
  5840. * @returns a new Color3 object
  5841. */
  5842. static Random(): Color3;
  5843. }
  5844. /**
  5845. * Class used to hold a RBGA color
  5846. */
  5847. export class Color4 {
  5848. /**
  5849. * Defines the red component (between 0 and 1, default is 0)
  5850. */
  5851. r: number;
  5852. /**
  5853. * Defines the green component (between 0 and 1, default is 0)
  5854. */
  5855. g: number;
  5856. /**
  5857. * Defines the blue component (between 0 and 1, default is 0)
  5858. */
  5859. b: number;
  5860. /**
  5861. * Defines the alpha component (between 0 and 1, default is 1)
  5862. */
  5863. a: number;
  5864. /**
  5865. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5866. * @param r defines the red component (between 0 and 1, default is 0)
  5867. * @param g defines the green component (between 0 and 1, default is 0)
  5868. * @param b defines the blue component (between 0 and 1, default is 0)
  5869. * @param a defines the alpha component (between 0 and 1, default is 1)
  5870. */
  5871. constructor(
  5872. /**
  5873. * Defines the red component (between 0 and 1, default is 0)
  5874. */
  5875. r?: number,
  5876. /**
  5877. * Defines the green component (between 0 and 1, default is 0)
  5878. */
  5879. g?: number,
  5880. /**
  5881. * Defines the blue component (between 0 and 1, default is 0)
  5882. */
  5883. b?: number,
  5884. /**
  5885. * Defines the alpha component (between 0 and 1, default is 1)
  5886. */
  5887. a?: number);
  5888. /**
  5889. * Adds in place the given Color4 values to the current Color4 object
  5890. * @param right defines the second operand
  5891. * @returns the current updated Color4 object
  5892. */
  5893. addInPlace(right: DeepImmutable<Color4>): Color4;
  5894. /**
  5895. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5896. * @returns the new array
  5897. */
  5898. asArray(): number[];
  5899. /**
  5900. * Stores from the starting index in the given array the Color4 successive values
  5901. * @param array defines the array where to store the r,g,b components
  5902. * @param index defines an optional index in the target array to define where to start storing values
  5903. * @returns the current Color4 object
  5904. */
  5905. toArray(array: number[], index?: number): Color4;
  5906. /**
  5907. * Update the current color with values stored in an array from the starting index of the given array
  5908. * @param array defines the source array
  5909. * @param offset defines an offset in the source array
  5910. * @returns the current Color4 object
  5911. */
  5912. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5913. /**
  5914. * Determines equality between Color4 objects
  5915. * @param otherColor defines the second operand
  5916. * @returns true if the rgba values are equal to the given ones
  5917. */
  5918. equals(otherColor: DeepImmutable<Color4>): boolean;
  5919. /**
  5920. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5921. * @param right defines the second operand
  5922. * @returns a new Color4 object
  5923. */
  5924. add(right: DeepImmutable<Color4>): Color4;
  5925. /**
  5926. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5927. * @param right defines the second operand
  5928. * @returns a new Color4 object
  5929. */
  5930. subtract(right: DeepImmutable<Color4>): Color4;
  5931. /**
  5932. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5933. * @param right defines the second operand
  5934. * @param result defines the Color4 object where to store the result
  5935. * @returns the current Color4 object
  5936. */
  5937. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5938. /**
  5939. * Creates a new Color4 with the current Color4 values multiplied by scale
  5940. * @param scale defines the scaling factor to apply
  5941. * @returns a new Color4 object
  5942. */
  5943. scale(scale: number): Color4;
  5944. /**
  5945. * Multiplies the current Color4 values by scale and stores the result in "result"
  5946. * @param scale defines the scaling factor to apply
  5947. * @param result defines the Color4 object where to store the result
  5948. * @returns the current unmodified Color4
  5949. */
  5950. scaleToRef(scale: number, result: Color4): Color4;
  5951. /**
  5952. * Scale the current Color4 values by a factor and add the result to a given Color4
  5953. * @param scale defines the scale factor
  5954. * @param result defines the Color4 object where to store the result
  5955. * @returns the unmodified current Color4
  5956. */
  5957. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5958. /**
  5959. * Clamps the rgb values by the min and max values and stores the result into "result"
  5960. * @param min defines minimum clamping value (default is 0)
  5961. * @param max defines maximum clamping value (default is 1)
  5962. * @param result defines color to store the result into.
  5963. * @returns the cuurent Color4
  5964. */
  5965. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5966. /**
  5967. * Multipy an Color4 value by another and return a new Color4 object
  5968. * @param color defines the Color4 value to multiply by
  5969. * @returns a new Color4 object
  5970. */
  5971. multiply(color: Color4): Color4;
  5972. /**
  5973. * Multipy a Color4 value by another and push the result in a reference value
  5974. * @param color defines the Color4 value to multiply by
  5975. * @param result defines the Color4 to fill the result in
  5976. * @returns the result Color4
  5977. */
  5978. multiplyToRef(color: Color4, result: Color4): Color4;
  5979. /**
  5980. * Creates a string with the Color4 current values
  5981. * @returns the string representation of the Color4 object
  5982. */
  5983. toString(): string;
  5984. /**
  5985. * Returns the string "Color4"
  5986. * @returns "Color4"
  5987. */
  5988. getClassName(): string;
  5989. /**
  5990. * Compute the Color4 hash code
  5991. * @returns an unique number that can be used to hash Color4 objects
  5992. */
  5993. getHashCode(): number;
  5994. /**
  5995. * Creates a new Color4 copied from the current one
  5996. * @returns a new Color4 object
  5997. */
  5998. clone(): Color4;
  5999. /**
  6000. * Copies the given Color4 values into the current one
  6001. * @param source defines the source Color4 object
  6002. * @returns the current updated Color4 object
  6003. */
  6004. copyFrom(source: Color4): Color4;
  6005. /**
  6006. * Copies the given float values into the current one
  6007. * @param r defines the red component to read from
  6008. * @param g defines the green component to read from
  6009. * @param b defines the blue component to read from
  6010. * @param a defines the alpha component to read from
  6011. * @returns the current updated Color4 object
  6012. */
  6013. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  6014. /**
  6015. * Copies the given float values into the current one
  6016. * @param r defines the red component to read from
  6017. * @param g defines the green component to read from
  6018. * @param b defines the blue component to read from
  6019. * @param a defines the alpha component to read from
  6020. * @returns the current updated Color4 object
  6021. */
  6022. set(r: number, g: number, b: number, a: number): Color4;
  6023. /**
  6024. * Compute the Color4 hexadecimal code as a string
  6025. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  6026. * @returns a string containing the hexadecimal representation of the Color4 object
  6027. */
  6028. toHexString(returnAsColor3?: boolean): string;
  6029. /**
  6030. * Computes a new Color4 converted from the current one to linear space
  6031. * @returns a new Color4 object
  6032. */
  6033. toLinearSpace(): Color4;
  6034. /**
  6035. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  6036. * @param convertedColor defines the Color4 object where to store the linear space version
  6037. * @returns the unmodified Color4
  6038. */
  6039. toLinearSpaceToRef(convertedColor: Color4): Color4;
  6040. /**
  6041. * Computes a new Color4 converted from the current one to gamma space
  6042. * @returns a new Color4 object
  6043. */
  6044. toGammaSpace(): Color4;
  6045. /**
  6046. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  6047. * @param convertedColor defines the Color4 object where to store the gamma space version
  6048. * @returns the unmodified Color4
  6049. */
  6050. toGammaSpaceToRef(convertedColor: Color4): Color4;
  6051. /**
  6052. * Creates a new Color4 from the string containing valid hexadecimal values
  6053. * @param hex defines a string containing valid hexadecimal values
  6054. * @returns a new Color4 object
  6055. */
  6056. static FromHexString(hex: string): Color4;
  6057. /**
  6058. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6059. * @param left defines the start value
  6060. * @param right defines the end value
  6061. * @param amount defines the gradient factor
  6062. * @returns a new Color4 object
  6063. */
  6064. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  6065. /**
  6066. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6067. * @param left defines the start value
  6068. * @param right defines the end value
  6069. * @param amount defines the gradient factor
  6070. * @param result defines the Color4 object where to store data
  6071. */
  6072. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  6073. /**
  6074. * Creates a new Color4 from a Color3 and an alpha value
  6075. * @param color3 defines the source Color3 to read from
  6076. * @param alpha defines the alpha component (1.0 by default)
  6077. * @returns a new Color4 object
  6078. */
  6079. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  6080. /**
  6081. * Creates a new Color4 from the starting index element of the given array
  6082. * @param array defines the source array to read from
  6083. * @param offset defines the offset in the source array
  6084. * @returns a new Color4 object
  6085. */
  6086. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6087. /**
  6088. * Creates a new Color4 from the starting index element of the given array
  6089. * @param array defines the source array to read from
  6090. * @param offset defines the offset in the source array
  6091. * @param result defines the target Color4 object
  6092. */
  6093. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  6094. /**
  6095. * Creates a new Color3 from integer values (< 256)
  6096. * @param r defines the red component to read from (value between 0 and 255)
  6097. * @param g defines the green component to read from (value between 0 and 255)
  6098. * @param b defines the blue component to read from (value between 0 and 255)
  6099. * @param a defines the alpha component to read from (value between 0 and 255)
  6100. * @returns a new Color3 object
  6101. */
  6102. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6103. /**
  6104. * Check the content of a given array and convert it to an array containing RGBA data
  6105. * If the original array was already containing count * 4 values then it is returned directly
  6106. * @param colors defines the array to check
  6107. * @param count defines the number of RGBA data to expect
  6108. * @returns an array containing count * 4 values (RGBA)
  6109. */
  6110. static CheckColors4(colors: number[], count: number): number[];
  6111. }
  6112. /**
  6113. * @hidden
  6114. */
  6115. export class TmpColors {
  6116. static Color3: Color3[];
  6117. static Color4: Color4[];
  6118. }
  6119. }
  6120. declare module BABYLON {
  6121. /**
  6122. * Defines an interface which represents an animation key frame
  6123. */
  6124. export interface IAnimationKey {
  6125. /**
  6126. * Frame of the key frame
  6127. */
  6128. frame: number;
  6129. /**
  6130. * Value at the specifies key frame
  6131. */
  6132. value: any;
  6133. /**
  6134. * The input tangent for the cubic hermite spline
  6135. */
  6136. inTangent?: any;
  6137. /**
  6138. * The output tangent for the cubic hermite spline
  6139. */
  6140. outTangent?: any;
  6141. /**
  6142. * The animation interpolation type
  6143. */
  6144. interpolation?: AnimationKeyInterpolation;
  6145. }
  6146. /**
  6147. * Enum for the animation key frame interpolation type
  6148. */
  6149. export enum AnimationKeyInterpolation {
  6150. /**
  6151. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6152. */
  6153. STEP = 1
  6154. }
  6155. }
  6156. declare module BABYLON {
  6157. /**
  6158. * Represents the range of an animation
  6159. */
  6160. export class AnimationRange {
  6161. /**The name of the animation range**/
  6162. name: string;
  6163. /**The starting frame of the animation */
  6164. from: number;
  6165. /**The ending frame of the animation*/
  6166. to: number;
  6167. /**
  6168. * Initializes the range of an animation
  6169. * @param name The name of the animation range
  6170. * @param from The starting frame of the animation
  6171. * @param to The ending frame of the animation
  6172. */
  6173. constructor(
  6174. /**The name of the animation range**/
  6175. name: string,
  6176. /**The starting frame of the animation */
  6177. from: number,
  6178. /**The ending frame of the animation*/
  6179. to: number);
  6180. /**
  6181. * Makes a copy of the animation range
  6182. * @returns A copy of the animation range
  6183. */
  6184. clone(): AnimationRange;
  6185. }
  6186. }
  6187. declare module BABYLON {
  6188. /**
  6189. * Composed of a frame, and an action function
  6190. */
  6191. export class AnimationEvent {
  6192. /** The frame for which the event is triggered **/
  6193. frame: number;
  6194. /** The event to perform when triggered **/
  6195. action: (currentFrame: number) => void;
  6196. /** Specifies if the event should be triggered only once**/
  6197. onlyOnce?: boolean | undefined;
  6198. /**
  6199. * Specifies if the animation event is done
  6200. */
  6201. isDone: boolean;
  6202. /**
  6203. * Initializes the animation event
  6204. * @param frame The frame for which the event is triggered
  6205. * @param action The event to perform when triggered
  6206. * @param onlyOnce Specifies if the event should be triggered only once
  6207. */
  6208. constructor(
  6209. /** The frame for which the event is triggered **/
  6210. frame: number,
  6211. /** The event to perform when triggered **/
  6212. action: (currentFrame: number) => void,
  6213. /** Specifies if the event should be triggered only once**/
  6214. onlyOnce?: boolean | undefined);
  6215. /** @hidden */
  6216. _clone(): AnimationEvent;
  6217. }
  6218. }
  6219. declare module BABYLON {
  6220. /**
  6221. * Interface used to define a behavior
  6222. */
  6223. export interface Behavior<T> {
  6224. /** gets or sets behavior's name */
  6225. name: string;
  6226. /**
  6227. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6228. */
  6229. init(): void;
  6230. /**
  6231. * Called when the behavior is attached to a target
  6232. * @param target defines the target where the behavior is attached to
  6233. */
  6234. attach(target: T): void;
  6235. /**
  6236. * Called when the behavior is detached from its target
  6237. */
  6238. detach(): void;
  6239. }
  6240. /**
  6241. * Interface implemented by classes supporting behaviors
  6242. */
  6243. export interface IBehaviorAware<T> {
  6244. /**
  6245. * Attach a behavior
  6246. * @param behavior defines the behavior to attach
  6247. * @returns the current host
  6248. */
  6249. addBehavior(behavior: Behavior<T>): T;
  6250. /**
  6251. * Remove a behavior from the current object
  6252. * @param behavior defines the behavior to detach
  6253. * @returns the current host
  6254. */
  6255. removeBehavior(behavior: Behavior<T>): T;
  6256. /**
  6257. * Gets a behavior using its name to search
  6258. * @param name defines the name to search
  6259. * @returns the behavior or null if not found
  6260. */
  6261. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6262. }
  6263. }
  6264. declare module BABYLON {
  6265. /**
  6266. * Defines an array and its length.
  6267. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6268. */
  6269. export interface ISmartArrayLike<T> {
  6270. /**
  6271. * The data of the array.
  6272. */
  6273. data: Array<T>;
  6274. /**
  6275. * The active length of the array.
  6276. */
  6277. length: number;
  6278. }
  6279. /**
  6280. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6281. */
  6282. export class SmartArray<T> implements ISmartArrayLike<T> {
  6283. /**
  6284. * The full set of data from the array.
  6285. */
  6286. data: Array<T>;
  6287. /**
  6288. * The active length of the array.
  6289. */
  6290. length: number;
  6291. protected _id: number;
  6292. /**
  6293. * Instantiates a Smart Array.
  6294. * @param capacity defines the default capacity of the array.
  6295. */
  6296. constructor(capacity: number);
  6297. /**
  6298. * Pushes a value at the end of the active data.
  6299. * @param value defines the object to push in the array.
  6300. */
  6301. push(value: T): void;
  6302. /**
  6303. * Iterates over the active data and apply the lambda to them.
  6304. * @param func defines the action to apply on each value.
  6305. */
  6306. forEach(func: (content: T) => void): void;
  6307. /**
  6308. * Sorts the full sets of data.
  6309. * @param compareFn defines the comparison function to apply.
  6310. */
  6311. sort(compareFn: (a: T, b: T) => number): void;
  6312. /**
  6313. * Resets the active data to an empty array.
  6314. */
  6315. reset(): void;
  6316. /**
  6317. * Releases all the data from the array as well as the array.
  6318. */
  6319. dispose(): void;
  6320. /**
  6321. * Concats the active data with a given array.
  6322. * @param array defines the data to concatenate with.
  6323. */
  6324. concat(array: any): void;
  6325. /**
  6326. * Returns the position of a value in the active data.
  6327. * @param value defines the value to find the index for
  6328. * @returns the index if found in the active data otherwise -1
  6329. */
  6330. indexOf(value: T): number;
  6331. /**
  6332. * Returns whether an element is part of the active data.
  6333. * @param value defines the value to look for
  6334. * @returns true if found in the active data otherwise false
  6335. */
  6336. contains(value: T): boolean;
  6337. private static _GlobalId;
  6338. }
  6339. /**
  6340. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6341. * The data in this array can only be present once
  6342. */
  6343. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6344. private _duplicateId;
  6345. /**
  6346. * Pushes a value at the end of the active data.
  6347. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6348. * @param value defines the object to push in the array.
  6349. */
  6350. push(value: T): void;
  6351. /**
  6352. * Pushes a value at the end of the active data.
  6353. * If the data is already present, it won t be added again
  6354. * @param value defines the object to push in the array.
  6355. * @returns true if added false if it was already present
  6356. */
  6357. pushNoDuplicate(value: T): boolean;
  6358. /**
  6359. * Resets the active data to an empty array.
  6360. */
  6361. reset(): void;
  6362. /**
  6363. * Concats the active data with a given array.
  6364. * This ensures no dupplicate will be present in the result.
  6365. * @param array defines the data to concatenate with.
  6366. */
  6367. concatWithNoDuplicate(array: any): void;
  6368. }
  6369. }
  6370. declare module BABYLON {
  6371. /**
  6372. * @ignore
  6373. * This is a list of all the different input types that are available in the application.
  6374. * Fo instance: ArcRotateCameraGamepadInput...
  6375. */
  6376. export var CameraInputTypes: {};
  6377. /**
  6378. * This is the contract to implement in order to create a new input class.
  6379. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6380. */
  6381. export interface ICameraInput<TCamera extends Camera> {
  6382. /**
  6383. * Defines the camera the input is attached to.
  6384. */
  6385. camera: Nullable<TCamera>;
  6386. /**
  6387. * Gets the class name of the current intput.
  6388. * @returns the class name
  6389. */
  6390. getClassName(): string;
  6391. /**
  6392. * Get the friendly name associated with the input class.
  6393. * @returns the input friendly name
  6394. */
  6395. getSimpleName(): string;
  6396. /**
  6397. * Attach the input controls to a specific dom element to get the input from.
  6398. * @param element Defines the element the controls should be listened from
  6399. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6400. */
  6401. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6402. /**
  6403. * Detach the current controls from the specified dom element.
  6404. * @param element Defines the element to stop listening the inputs from
  6405. */
  6406. detachControl(element: Nullable<HTMLElement>): void;
  6407. /**
  6408. * Update the current camera state depending on the inputs that have been used this frame.
  6409. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6410. */
  6411. checkInputs?: () => void;
  6412. }
  6413. /**
  6414. * Represents a map of input types to input instance or input index to input instance.
  6415. */
  6416. export interface CameraInputsMap<TCamera extends Camera> {
  6417. /**
  6418. * Accessor to the input by input type.
  6419. */
  6420. [name: string]: ICameraInput<TCamera>;
  6421. /**
  6422. * Accessor to the input by input index.
  6423. */
  6424. [idx: number]: ICameraInput<TCamera>;
  6425. }
  6426. /**
  6427. * This represents the input manager used within a camera.
  6428. * It helps dealing with all the different kind of input attached to a camera.
  6429. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6430. */
  6431. export class CameraInputsManager<TCamera extends Camera> {
  6432. /**
  6433. * Defines the list of inputs attahed to the camera.
  6434. */
  6435. attached: CameraInputsMap<TCamera>;
  6436. /**
  6437. * Defines the dom element the camera is collecting inputs from.
  6438. * This is null if the controls have not been attached.
  6439. */
  6440. attachedElement: Nullable<HTMLElement>;
  6441. /**
  6442. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6443. */
  6444. noPreventDefault: boolean;
  6445. /**
  6446. * Defined the camera the input manager belongs to.
  6447. */
  6448. camera: TCamera;
  6449. /**
  6450. * Update the current camera state depending on the inputs that have been used this frame.
  6451. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6452. */
  6453. checkInputs: () => void;
  6454. /**
  6455. * Instantiate a new Camera Input Manager.
  6456. * @param camera Defines the camera the input manager blongs to
  6457. */
  6458. constructor(camera: TCamera);
  6459. /**
  6460. * Add an input method to a camera
  6461. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6462. * @param input camera input method
  6463. */
  6464. add(input: ICameraInput<TCamera>): void;
  6465. /**
  6466. * Remove a specific input method from a camera
  6467. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6468. * @param inputToRemove camera input method
  6469. */
  6470. remove(inputToRemove: ICameraInput<TCamera>): void;
  6471. /**
  6472. * Remove a specific input type from a camera
  6473. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6474. * @param inputType the type of the input to remove
  6475. */
  6476. removeByType(inputType: string): void;
  6477. private _addCheckInputs;
  6478. /**
  6479. * Attach the input controls to the currently attached dom element to listen the events from.
  6480. * @param input Defines the input to attach
  6481. */
  6482. attachInput(input: ICameraInput<TCamera>): void;
  6483. /**
  6484. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6485. * @param element Defines the dom element to collect the events from
  6486. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6487. */
  6488. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6489. /**
  6490. * Detach the current manager inputs controls from a specific dom element.
  6491. * @param element Defines the dom element to collect the events from
  6492. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6493. */
  6494. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6495. /**
  6496. * Rebuild the dynamic inputCheck function from the current list of
  6497. * defined inputs in the manager.
  6498. */
  6499. rebuildInputCheck(): void;
  6500. /**
  6501. * Remove all attached input methods from a camera
  6502. */
  6503. clear(): void;
  6504. /**
  6505. * Serialize the current input manager attached to a camera.
  6506. * This ensures than once parsed,
  6507. * the input associated to the camera will be identical to the current ones
  6508. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6509. */
  6510. serialize(serializedCamera: any): void;
  6511. /**
  6512. * Parses an input manager serialized JSON to restore the previous list of inputs
  6513. * and states associated to a camera.
  6514. * @param parsedCamera Defines the JSON to parse
  6515. */
  6516. parse(parsedCamera: any): void;
  6517. }
  6518. }
  6519. declare module BABYLON {
  6520. /**
  6521. * Class used to store data that will be store in GPU memory
  6522. */
  6523. export class Buffer {
  6524. private _engine;
  6525. private _buffer;
  6526. /** @hidden */
  6527. _data: Nullable<DataArray>;
  6528. private _updatable;
  6529. private _instanced;
  6530. private _divisor;
  6531. /**
  6532. * Gets the byte stride.
  6533. */
  6534. readonly byteStride: number;
  6535. /**
  6536. * Constructor
  6537. * @param engine the engine
  6538. * @param data the data to use for this buffer
  6539. * @param updatable whether the data is updatable
  6540. * @param stride the stride (optional)
  6541. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6542. * @param instanced whether the buffer is instanced (optional)
  6543. * @param useBytes set to true if the stride in in bytes (optional)
  6544. * @param divisor sets an optional divisor for instances (1 by default)
  6545. */
  6546. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6547. /**
  6548. * Create a new VertexBuffer based on the current buffer
  6549. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6550. * @param offset defines offset in the buffer (0 by default)
  6551. * @param size defines the size in floats of attributes (position is 3 for instance)
  6552. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6553. * @param instanced defines if the vertex buffer contains indexed data
  6554. * @param useBytes defines if the offset and stride are in bytes *
  6555. * @param divisor sets an optional divisor for instances (1 by default)
  6556. * @returns the new vertex buffer
  6557. */
  6558. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6559. /**
  6560. * Gets a boolean indicating if the Buffer is updatable?
  6561. * @returns true if the buffer is updatable
  6562. */
  6563. isUpdatable(): boolean;
  6564. /**
  6565. * Gets current buffer's data
  6566. * @returns a DataArray or null
  6567. */
  6568. getData(): Nullable<DataArray>;
  6569. /**
  6570. * Gets underlying native buffer
  6571. * @returns underlying native buffer
  6572. */
  6573. getBuffer(): Nullable<DataBuffer>;
  6574. /**
  6575. * Gets the stride in float32 units (i.e. byte stride / 4).
  6576. * May not be an integer if the byte stride is not divisible by 4.
  6577. * @returns the stride in float32 units
  6578. * @deprecated Please use byteStride instead.
  6579. */
  6580. getStrideSize(): number;
  6581. /**
  6582. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6583. * @param data defines the data to store
  6584. */
  6585. create(data?: Nullable<DataArray>): void;
  6586. /** @hidden */
  6587. _rebuild(): void;
  6588. /**
  6589. * Update current buffer data
  6590. * @param data defines the data to store
  6591. */
  6592. update(data: DataArray): void;
  6593. /**
  6594. * Updates the data directly.
  6595. * @param data the new data
  6596. * @param offset the new offset
  6597. * @param vertexCount the vertex count (optional)
  6598. * @param useBytes set to true if the offset is in bytes
  6599. */
  6600. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6601. /**
  6602. * Release all resources
  6603. */
  6604. dispose(): void;
  6605. }
  6606. /**
  6607. * Specialized buffer used to store vertex data
  6608. */
  6609. export class VertexBuffer {
  6610. /** @hidden */
  6611. _buffer: Buffer;
  6612. private _kind;
  6613. private _size;
  6614. private _ownsBuffer;
  6615. private _instanced;
  6616. private _instanceDivisor;
  6617. /**
  6618. * The byte type.
  6619. */
  6620. static readonly BYTE: number;
  6621. /**
  6622. * The unsigned byte type.
  6623. */
  6624. static readonly UNSIGNED_BYTE: number;
  6625. /**
  6626. * The short type.
  6627. */
  6628. static readonly SHORT: number;
  6629. /**
  6630. * The unsigned short type.
  6631. */
  6632. static readonly UNSIGNED_SHORT: number;
  6633. /**
  6634. * The integer type.
  6635. */
  6636. static readonly INT: number;
  6637. /**
  6638. * The unsigned integer type.
  6639. */
  6640. static readonly UNSIGNED_INT: number;
  6641. /**
  6642. * The float type.
  6643. */
  6644. static readonly FLOAT: number;
  6645. /**
  6646. * Gets or sets the instance divisor when in instanced mode
  6647. */
  6648. get instanceDivisor(): number;
  6649. set instanceDivisor(value: number);
  6650. /**
  6651. * Gets the byte stride.
  6652. */
  6653. readonly byteStride: number;
  6654. /**
  6655. * Gets the byte offset.
  6656. */
  6657. readonly byteOffset: number;
  6658. /**
  6659. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6660. */
  6661. readonly normalized: boolean;
  6662. /**
  6663. * Gets the data type of each component in the array.
  6664. */
  6665. readonly type: number;
  6666. /**
  6667. * Constructor
  6668. * @param engine the engine
  6669. * @param data the data to use for this vertex buffer
  6670. * @param kind the vertex buffer kind
  6671. * @param updatable whether the data is updatable
  6672. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6673. * @param stride the stride (optional)
  6674. * @param instanced whether the buffer is instanced (optional)
  6675. * @param offset the offset of the data (optional)
  6676. * @param size the number of components (optional)
  6677. * @param type the type of the component (optional)
  6678. * @param normalized whether the data contains normalized data (optional)
  6679. * @param useBytes set to true if stride and offset are in bytes (optional)
  6680. * @param divisor defines the instance divisor to use (1 by default)
  6681. */
  6682. 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);
  6683. /** @hidden */
  6684. _rebuild(): void;
  6685. /**
  6686. * Returns the kind of the VertexBuffer (string)
  6687. * @returns a string
  6688. */
  6689. getKind(): string;
  6690. /**
  6691. * Gets a boolean indicating if the VertexBuffer is updatable?
  6692. * @returns true if the buffer is updatable
  6693. */
  6694. isUpdatable(): boolean;
  6695. /**
  6696. * Gets current buffer's data
  6697. * @returns a DataArray or null
  6698. */
  6699. getData(): Nullable<DataArray>;
  6700. /**
  6701. * Gets underlying native buffer
  6702. * @returns underlying native buffer
  6703. */
  6704. getBuffer(): Nullable<DataBuffer>;
  6705. /**
  6706. * Gets the stride in float32 units (i.e. byte stride / 4).
  6707. * May not be an integer if the byte stride is not divisible by 4.
  6708. * @returns the stride in float32 units
  6709. * @deprecated Please use byteStride instead.
  6710. */
  6711. getStrideSize(): number;
  6712. /**
  6713. * Returns the offset as a multiple of the type byte length.
  6714. * @returns the offset in bytes
  6715. * @deprecated Please use byteOffset instead.
  6716. */
  6717. getOffset(): number;
  6718. /**
  6719. * Returns the number of components per vertex attribute (integer)
  6720. * @returns the size in float
  6721. */
  6722. getSize(): number;
  6723. /**
  6724. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6725. * @returns true if this buffer is instanced
  6726. */
  6727. getIsInstanced(): boolean;
  6728. /**
  6729. * Returns the instancing divisor, zero for non-instanced (integer).
  6730. * @returns a number
  6731. */
  6732. getInstanceDivisor(): number;
  6733. /**
  6734. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6735. * @param data defines the data to store
  6736. */
  6737. create(data?: DataArray): void;
  6738. /**
  6739. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6740. * This function will create a new buffer if the current one is not updatable
  6741. * @param data defines the data to store
  6742. */
  6743. update(data: DataArray): void;
  6744. /**
  6745. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6746. * Returns the directly updated WebGLBuffer.
  6747. * @param data the new data
  6748. * @param offset the new offset
  6749. * @param useBytes set to true if the offset is in bytes
  6750. */
  6751. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6752. /**
  6753. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6754. */
  6755. dispose(): void;
  6756. /**
  6757. * Enumerates each value of this vertex buffer as numbers.
  6758. * @param count the number of values to enumerate
  6759. * @param callback the callback function called for each value
  6760. */
  6761. forEach(count: number, callback: (value: number, index: number) => void): void;
  6762. /**
  6763. * Positions
  6764. */
  6765. static readonly PositionKind: string;
  6766. /**
  6767. * Normals
  6768. */
  6769. static readonly NormalKind: string;
  6770. /**
  6771. * Tangents
  6772. */
  6773. static readonly TangentKind: string;
  6774. /**
  6775. * Texture coordinates
  6776. */
  6777. static readonly UVKind: string;
  6778. /**
  6779. * Texture coordinates 2
  6780. */
  6781. static readonly UV2Kind: string;
  6782. /**
  6783. * Texture coordinates 3
  6784. */
  6785. static readonly UV3Kind: string;
  6786. /**
  6787. * Texture coordinates 4
  6788. */
  6789. static readonly UV4Kind: string;
  6790. /**
  6791. * Texture coordinates 5
  6792. */
  6793. static readonly UV5Kind: string;
  6794. /**
  6795. * Texture coordinates 6
  6796. */
  6797. static readonly UV6Kind: string;
  6798. /**
  6799. * Colors
  6800. */
  6801. static readonly ColorKind: string;
  6802. /**
  6803. * Matrix indices (for bones)
  6804. */
  6805. static readonly MatricesIndicesKind: string;
  6806. /**
  6807. * Matrix weights (for bones)
  6808. */
  6809. static readonly MatricesWeightsKind: string;
  6810. /**
  6811. * Additional matrix indices (for bones)
  6812. */
  6813. static readonly MatricesIndicesExtraKind: string;
  6814. /**
  6815. * Additional matrix weights (for bones)
  6816. */
  6817. static readonly MatricesWeightsExtraKind: string;
  6818. /**
  6819. * Deduces the stride given a kind.
  6820. * @param kind The kind string to deduce
  6821. * @returns The deduced stride
  6822. */
  6823. static DeduceStride(kind: string): number;
  6824. /**
  6825. * Gets the byte length of the given type.
  6826. * @param type the type
  6827. * @returns the number of bytes
  6828. */
  6829. static GetTypeByteLength(type: number): number;
  6830. /**
  6831. * Enumerates each value of the given parameters as numbers.
  6832. * @param data the data to enumerate
  6833. * @param byteOffset the byte offset of the data
  6834. * @param byteStride the byte stride of the data
  6835. * @param componentCount the number of components per element
  6836. * @param componentType the type of the component
  6837. * @param count the number of values to enumerate
  6838. * @param normalized whether the data is normalized
  6839. * @param callback the callback function called for each value
  6840. */
  6841. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6842. private static _GetFloatValue;
  6843. }
  6844. }
  6845. declare module BABYLON {
  6846. /**
  6847. * The options Interface for creating a Capsule Mesh
  6848. */
  6849. export interface ICreateCapsuleOptions {
  6850. /** The Orientation of the capsule. Default : Vector3.Up() */
  6851. orientation?: Vector3;
  6852. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  6853. subdivisions: number;
  6854. /** Number of cylindrical segments on the capsule. */
  6855. tessellation: number;
  6856. /** Height or Length of the capsule. */
  6857. height: number;
  6858. /** Radius of the capsule. */
  6859. radius: number;
  6860. /** Number of sub segments on the cap sections of the capsule running parallel to orientation. */
  6861. capSubdivisions: number;
  6862. /** Overwrite for the top radius. */
  6863. radiusTop?: number;
  6864. /** Overwrite for the bottom radius. */
  6865. radiusBottom?: number;
  6866. /** Overwrite for the top capSubdivisions. */
  6867. topCapSubdivisions?: number;
  6868. /** Overwrite for the bottom capSubdivisions. */
  6869. bottomCapSubdivisions?: number;
  6870. }
  6871. /**
  6872. * Class containing static functions to help procedurally build meshes
  6873. */
  6874. export class CapsuleBuilder {
  6875. /**
  6876. * Creates a capsule or a pill mesh
  6877. * @param name defines the name of the mesh
  6878. * @param options The constructors options.
  6879. * @param scene The scene the mesh is scoped to.
  6880. * @returns Capsule Mesh
  6881. */
  6882. static CreateCapsule(name: string, options: ICreateCapsuleOptions | undefined, scene: any): Mesh;
  6883. }
  6884. }
  6885. declare module BABYLON {
  6886. /**
  6887. * @hidden
  6888. */
  6889. export class IntersectionInfo {
  6890. bu: Nullable<number>;
  6891. bv: Nullable<number>;
  6892. distance: number;
  6893. faceId: number;
  6894. subMeshId: number;
  6895. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6896. }
  6897. }
  6898. declare module BABYLON {
  6899. /**
  6900. * Class used to store bounding sphere information
  6901. */
  6902. export class BoundingSphere {
  6903. /**
  6904. * Gets the center of the bounding sphere in local space
  6905. */
  6906. readonly center: Vector3;
  6907. /**
  6908. * Radius of the bounding sphere in local space
  6909. */
  6910. radius: number;
  6911. /**
  6912. * Gets the center of the bounding sphere in world space
  6913. */
  6914. readonly centerWorld: Vector3;
  6915. /**
  6916. * Radius of the bounding sphere in world space
  6917. */
  6918. radiusWorld: number;
  6919. /**
  6920. * Gets the minimum vector in local space
  6921. */
  6922. readonly minimum: Vector3;
  6923. /**
  6924. * Gets the maximum vector in local space
  6925. */
  6926. readonly maximum: Vector3;
  6927. private _worldMatrix;
  6928. private static readonly TmpVector3;
  6929. /**
  6930. * Creates a new bounding sphere
  6931. * @param min defines the minimum vector (in local space)
  6932. * @param max defines the maximum vector (in local space)
  6933. * @param worldMatrix defines the new world matrix
  6934. */
  6935. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6936. /**
  6937. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6938. * @param min defines the new minimum vector (in local space)
  6939. * @param max defines the new maximum vector (in local space)
  6940. * @param worldMatrix defines the new world matrix
  6941. */
  6942. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6943. /**
  6944. * Scale the current bounding sphere by applying a scale factor
  6945. * @param factor defines the scale factor to apply
  6946. * @returns the current bounding box
  6947. */
  6948. scale(factor: number): BoundingSphere;
  6949. /**
  6950. * Gets the world matrix of the bounding box
  6951. * @returns a matrix
  6952. */
  6953. getWorldMatrix(): DeepImmutable<Matrix>;
  6954. /** @hidden */
  6955. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6956. /**
  6957. * Tests if the bounding sphere is intersecting the frustum planes
  6958. * @param frustumPlanes defines the frustum planes to test
  6959. * @returns true if there is an intersection
  6960. */
  6961. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6962. /**
  6963. * Tests if the bounding sphere center is in between the frustum planes.
  6964. * Used for optimistic fast inclusion.
  6965. * @param frustumPlanes defines the frustum planes to test
  6966. * @returns true if the sphere center is in between the frustum planes
  6967. */
  6968. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6969. /**
  6970. * Tests if a point is inside the bounding sphere
  6971. * @param point defines the point to test
  6972. * @returns true if the point is inside the bounding sphere
  6973. */
  6974. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6975. /**
  6976. * Checks if two sphere intersct
  6977. * @param sphere0 sphere 0
  6978. * @param sphere1 sphere 1
  6979. * @returns true if the speres intersect
  6980. */
  6981. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6982. }
  6983. }
  6984. declare module BABYLON {
  6985. /**
  6986. * Class used to store bounding box information
  6987. */
  6988. export class BoundingBox implements ICullable {
  6989. /**
  6990. * Gets the 8 vectors representing the bounding box in local space
  6991. */
  6992. readonly vectors: Vector3[];
  6993. /**
  6994. * Gets the center of the bounding box in local space
  6995. */
  6996. readonly center: Vector3;
  6997. /**
  6998. * Gets the center of the bounding box in world space
  6999. */
  7000. readonly centerWorld: Vector3;
  7001. /**
  7002. * Gets the extend size in local space
  7003. */
  7004. readonly extendSize: Vector3;
  7005. /**
  7006. * Gets the extend size in world space
  7007. */
  7008. readonly extendSizeWorld: Vector3;
  7009. /**
  7010. * Gets the OBB (object bounding box) directions
  7011. */
  7012. readonly directions: Vector3[];
  7013. /**
  7014. * Gets the 8 vectors representing the bounding box in world space
  7015. */
  7016. readonly vectorsWorld: Vector3[];
  7017. /**
  7018. * Gets the minimum vector in world space
  7019. */
  7020. readonly minimumWorld: Vector3;
  7021. /**
  7022. * Gets the maximum vector in world space
  7023. */
  7024. readonly maximumWorld: Vector3;
  7025. /**
  7026. * Gets the minimum vector in local space
  7027. */
  7028. readonly minimum: Vector3;
  7029. /**
  7030. * Gets the maximum vector in local space
  7031. */
  7032. readonly maximum: Vector3;
  7033. private _worldMatrix;
  7034. private static readonly TmpVector3;
  7035. /**
  7036. * @hidden
  7037. */
  7038. _tag: number;
  7039. /**
  7040. * Creates a new bounding box
  7041. * @param min defines the minimum vector (in local space)
  7042. * @param max defines the maximum vector (in local space)
  7043. * @param worldMatrix defines the new world matrix
  7044. */
  7045. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7046. /**
  7047. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7048. * @param min defines the new minimum vector (in local space)
  7049. * @param max defines the new maximum vector (in local space)
  7050. * @param worldMatrix defines the new world matrix
  7051. */
  7052. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7053. /**
  7054. * Scale the current bounding box by applying a scale factor
  7055. * @param factor defines the scale factor to apply
  7056. * @returns the current bounding box
  7057. */
  7058. scale(factor: number): BoundingBox;
  7059. /**
  7060. * Gets the world matrix of the bounding box
  7061. * @returns a matrix
  7062. */
  7063. getWorldMatrix(): DeepImmutable<Matrix>;
  7064. /** @hidden */
  7065. _update(world: DeepImmutable<Matrix>): void;
  7066. /**
  7067. * Tests if the bounding box is intersecting the frustum planes
  7068. * @param frustumPlanes defines the frustum planes to test
  7069. * @returns true if there is an intersection
  7070. */
  7071. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7072. /**
  7073. * Tests if the bounding box is entirely inside the frustum planes
  7074. * @param frustumPlanes defines the frustum planes to test
  7075. * @returns true if there is an inclusion
  7076. */
  7077. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7078. /**
  7079. * Tests if a point is inside the bounding box
  7080. * @param point defines the point to test
  7081. * @returns true if the point is inside the bounding box
  7082. */
  7083. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7084. /**
  7085. * Tests if the bounding box intersects with a bounding sphere
  7086. * @param sphere defines the sphere to test
  7087. * @returns true if there is an intersection
  7088. */
  7089. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7090. /**
  7091. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7092. * @param min defines the min vector to use
  7093. * @param max defines the max vector to use
  7094. * @returns true if there is an intersection
  7095. */
  7096. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7097. /**
  7098. * Tests if two bounding boxes are intersections
  7099. * @param box0 defines the first box to test
  7100. * @param box1 defines the second box to test
  7101. * @returns true if there is an intersection
  7102. */
  7103. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7104. /**
  7105. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7106. * @param minPoint defines the minimum vector of the bounding box
  7107. * @param maxPoint defines the maximum vector of the bounding box
  7108. * @param sphereCenter defines the sphere center
  7109. * @param sphereRadius defines the sphere radius
  7110. * @returns true if there is an intersection
  7111. */
  7112. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7113. /**
  7114. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7115. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7116. * @param frustumPlanes defines the frustum planes to test
  7117. * @return true if there is an inclusion
  7118. */
  7119. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7120. /**
  7121. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7122. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7123. * @param frustumPlanes defines the frustum planes to test
  7124. * @return true if there is an intersection
  7125. */
  7126. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7127. }
  7128. }
  7129. declare module BABYLON {
  7130. /** @hidden */
  7131. export class Collider {
  7132. /** Define if a collision was found */
  7133. collisionFound: boolean;
  7134. /**
  7135. * Define last intersection point in local space
  7136. */
  7137. intersectionPoint: Vector3;
  7138. /**
  7139. * Define last collided mesh
  7140. */
  7141. collidedMesh: Nullable<AbstractMesh>;
  7142. private _collisionPoint;
  7143. private _planeIntersectionPoint;
  7144. private _tempVector;
  7145. private _tempVector2;
  7146. private _tempVector3;
  7147. private _tempVector4;
  7148. private _edge;
  7149. private _baseToVertex;
  7150. private _destinationPoint;
  7151. private _slidePlaneNormal;
  7152. private _displacementVector;
  7153. /** @hidden */
  7154. _radius: Vector3;
  7155. /** @hidden */
  7156. _retry: number;
  7157. private _velocity;
  7158. private _basePoint;
  7159. private _epsilon;
  7160. /** @hidden */
  7161. _velocityWorldLength: number;
  7162. /** @hidden */
  7163. _basePointWorld: Vector3;
  7164. private _velocityWorld;
  7165. private _normalizedVelocity;
  7166. /** @hidden */
  7167. _initialVelocity: Vector3;
  7168. /** @hidden */
  7169. _initialPosition: Vector3;
  7170. private _nearestDistance;
  7171. private _collisionMask;
  7172. get collisionMask(): number;
  7173. set collisionMask(mask: number);
  7174. /**
  7175. * Gets the plane normal used to compute the sliding response (in local space)
  7176. */
  7177. get slidePlaneNormal(): Vector3;
  7178. /** @hidden */
  7179. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7180. /** @hidden */
  7181. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7182. /** @hidden */
  7183. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7184. /** @hidden */
  7185. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7186. /** @hidden */
  7187. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7188. /** @hidden */
  7189. _getResponse(pos: Vector3, vel: Vector3): void;
  7190. }
  7191. }
  7192. declare module BABYLON {
  7193. /**
  7194. * Interface for cullable objects
  7195. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7196. */
  7197. export interface ICullable {
  7198. /**
  7199. * Checks if the object or part of the object is in the frustum
  7200. * @param frustumPlanes Camera near/planes
  7201. * @returns true if the object is in frustum otherwise false
  7202. */
  7203. isInFrustum(frustumPlanes: Plane[]): boolean;
  7204. /**
  7205. * Checks if a cullable object (mesh...) is in the camera frustum
  7206. * Unlike isInFrustum this cheks the full bounding box
  7207. * @param frustumPlanes Camera near/planes
  7208. * @returns true if the object is in frustum otherwise false
  7209. */
  7210. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7211. }
  7212. /**
  7213. * Info for a bounding data of a mesh
  7214. */
  7215. export class BoundingInfo implements ICullable {
  7216. /**
  7217. * Bounding box for the mesh
  7218. */
  7219. readonly boundingBox: BoundingBox;
  7220. /**
  7221. * Bounding sphere for the mesh
  7222. */
  7223. readonly boundingSphere: BoundingSphere;
  7224. private _isLocked;
  7225. private static readonly TmpVector3;
  7226. /**
  7227. * Constructs bounding info
  7228. * @param minimum min vector of the bounding box/sphere
  7229. * @param maximum max vector of the bounding box/sphere
  7230. * @param worldMatrix defines the new world matrix
  7231. */
  7232. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7233. /**
  7234. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7235. * @param min defines the new minimum vector (in local space)
  7236. * @param max defines the new maximum vector (in local space)
  7237. * @param worldMatrix defines the new world matrix
  7238. */
  7239. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7240. /**
  7241. * min vector of the bounding box/sphere
  7242. */
  7243. get minimum(): Vector3;
  7244. /**
  7245. * max vector of the bounding box/sphere
  7246. */
  7247. get maximum(): Vector3;
  7248. /**
  7249. * If the info is locked and won't be updated to avoid perf overhead
  7250. */
  7251. get isLocked(): boolean;
  7252. set isLocked(value: boolean);
  7253. /**
  7254. * Updates the bounding sphere and box
  7255. * @param world world matrix to be used to update
  7256. */
  7257. update(world: DeepImmutable<Matrix>): void;
  7258. /**
  7259. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7260. * @param center New center of the bounding info
  7261. * @param extend New extend of the bounding info
  7262. * @returns the current bounding info
  7263. */
  7264. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7265. /**
  7266. * Scale the current bounding info by applying a scale factor
  7267. * @param factor defines the scale factor to apply
  7268. * @returns the current bounding info
  7269. */
  7270. scale(factor: number): BoundingInfo;
  7271. /**
  7272. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7273. * @param frustumPlanes defines the frustum to test
  7274. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7275. * @returns true if the bounding info is in the frustum planes
  7276. */
  7277. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7278. /**
  7279. * Gets the world distance between the min and max points of the bounding box
  7280. */
  7281. get diagonalLength(): number;
  7282. /**
  7283. * Checks if a cullable object (mesh...) is in the camera frustum
  7284. * Unlike isInFrustum this cheks the full bounding box
  7285. * @param frustumPlanes Camera near/planes
  7286. * @returns true if the object is in frustum otherwise false
  7287. */
  7288. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7289. /** @hidden */
  7290. _checkCollision(collider: Collider): boolean;
  7291. /**
  7292. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7293. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7294. * @param point the point to check intersection with
  7295. * @returns if the point intersects
  7296. */
  7297. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7298. /**
  7299. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7300. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7301. * @param boundingInfo the bounding info to check intersection with
  7302. * @param precise if the intersection should be done using OBB
  7303. * @returns if the bounding info intersects
  7304. */
  7305. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7306. }
  7307. }
  7308. declare module BABYLON {
  7309. /**
  7310. * Extracts minimum and maximum values from a list of indexed positions
  7311. * @param positions defines the positions to use
  7312. * @param indices defines the indices to the positions
  7313. * @param indexStart defines the start index
  7314. * @param indexCount defines the end index
  7315. * @param bias defines bias value to add to the result
  7316. * @return minimum and maximum values
  7317. */
  7318. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7319. minimum: Vector3;
  7320. maximum: Vector3;
  7321. };
  7322. /**
  7323. * Extracts minimum and maximum values from a list of positions
  7324. * @param positions defines the positions to use
  7325. * @param start defines the start index in the positions array
  7326. * @param count defines the number of positions to handle
  7327. * @param bias defines bias value to add to the result
  7328. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7329. * @return minimum and maximum values
  7330. */
  7331. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7332. minimum: Vector3;
  7333. maximum: Vector3;
  7334. };
  7335. }
  7336. declare module BABYLON {
  7337. /** @hidden */
  7338. export class WebGLDataBuffer extends DataBuffer {
  7339. private _buffer;
  7340. constructor(resource: WebGLBuffer);
  7341. get underlyingResource(): any;
  7342. }
  7343. }
  7344. declare module BABYLON {
  7345. /** @hidden */
  7346. export class WebGLPipelineContext implements IPipelineContext {
  7347. engine: ThinEngine;
  7348. program: Nullable<WebGLProgram>;
  7349. context?: WebGLRenderingContext;
  7350. vertexShader?: WebGLShader;
  7351. fragmentShader?: WebGLShader;
  7352. isParallelCompiled: boolean;
  7353. onCompiled?: () => void;
  7354. transformFeedback?: WebGLTransformFeedback | null;
  7355. vertexCompilationError: Nullable<string>;
  7356. fragmentCompilationError: Nullable<string>;
  7357. programLinkError: Nullable<string>;
  7358. programValidationError: Nullable<string>;
  7359. get isAsync(): boolean;
  7360. get isReady(): boolean;
  7361. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7362. _getVertexShaderCode(): string | null;
  7363. _getFragmentShaderCode(): string | null;
  7364. }
  7365. }
  7366. declare module BABYLON {
  7367. interface ThinEngine {
  7368. /**
  7369. * Create an uniform buffer
  7370. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7371. * @param elements defines the content of the uniform buffer
  7372. * @returns the webGL uniform buffer
  7373. */
  7374. createUniformBuffer(elements: FloatArray): DataBuffer;
  7375. /**
  7376. * Create a dynamic uniform buffer
  7377. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7378. * @param elements defines the content of the uniform buffer
  7379. * @returns the webGL uniform buffer
  7380. */
  7381. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7382. /**
  7383. * Update an existing uniform buffer
  7384. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7385. * @param uniformBuffer defines the target uniform buffer
  7386. * @param elements defines the content to update
  7387. * @param offset defines the offset in the uniform buffer where update should start
  7388. * @param count defines the size of the data to update
  7389. */
  7390. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7391. /**
  7392. * Bind an uniform buffer to the current webGL context
  7393. * @param buffer defines the buffer to bind
  7394. */
  7395. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7396. /**
  7397. * Bind a buffer to the current webGL context at a given location
  7398. * @param buffer defines the buffer to bind
  7399. * @param location defines the index where to bind the buffer
  7400. */
  7401. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7402. /**
  7403. * Bind a specific block at a given index in a specific shader program
  7404. * @param pipelineContext defines the pipeline context to use
  7405. * @param blockName defines the block name
  7406. * @param index defines the index where to bind the block
  7407. */
  7408. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7409. }
  7410. }
  7411. declare module BABYLON {
  7412. /**
  7413. * Uniform buffer objects.
  7414. *
  7415. * Handles blocks of uniform on the GPU.
  7416. *
  7417. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7418. *
  7419. * For more information, please refer to :
  7420. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7421. */
  7422. export class UniformBuffer {
  7423. private _engine;
  7424. private _buffer;
  7425. private _data;
  7426. private _bufferData;
  7427. private _dynamic?;
  7428. private _uniformLocations;
  7429. private _uniformSizes;
  7430. private _uniformLocationPointer;
  7431. private _needSync;
  7432. private _noUBO;
  7433. private _currentEffect;
  7434. /** @hidden */
  7435. _alreadyBound: boolean;
  7436. private static _MAX_UNIFORM_SIZE;
  7437. private static _tempBuffer;
  7438. /**
  7439. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7440. * This is dynamic to allow compat with webgl 1 and 2.
  7441. * You will need to pass the name of the uniform as well as the value.
  7442. */
  7443. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7444. /**
  7445. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7446. * This is dynamic to allow compat with webgl 1 and 2.
  7447. * You will need to pass the name of the uniform as well as the value.
  7448. */
  7449. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7450. /**
  7451. * Lambda to Update a single float in a uniform buffer.
  7452. * This is dynamic to allow compat with webgl 1 and 2.
  7453. * You will need to pass the name of the uniform as well as the value.
  7454. */
  7455. updateFloat: (name: string, x: number) => void;
  7456. /**
  7457. * Lambda to Update a vec2 of float in a uniform buffer.
  7458. * This is dynamic to allow compat with webgl 1 and 2.
  7459. * You will need to pass the name of the uniform as well as the value.
  7460. */
  7461. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7462. /**
  7463. * Lambda to Update a vec3 of float in a uniform buffer.
  7464. * This is dynamic to allow compat with webgl 1 and 2.
  7465. * You will need to pass the name of the uniform as well as the value.
  7466. */
  7467. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7468. /**
  7469. * Lambda to Update a vec4 of float in a uniform buffer.
  7470. * This is dynamic to allow compat with webgl 1 and 2.
  7471. * You will need to pass the name of the uniform as well as the value.
  7472. */
  7473. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7474. /**
  7475. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7476. * This is dynamic to allow compat with webgl 1 and 2.
  7477. * You will need to pass the name of the uniform as well as the value.
  7478. */
  7479. updateMatrix: (name: string, mat: Matrix) => void;
  7480. /**
  7481. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7482. * This is dynamic to allow compat with webgl 1 and 2.
  7483. * You will need to pass the name of the uniform as well as the value.
  7484. */
  7485. updateVector3: (name: string, vector: Vector3) => void;
  7486. /**
  7487. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7488. * This is dynamic to allow compat with webgl 1 and 2.
  7489. * You will need to pass the name of the uniform as well as the value.
  7490. */
  7491. updateVector4: (name: string, vector: Vector4) => void;
  7492. /**
  7493. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7494. * This is dynamic to allow compat with webgl 1 and 2.
  7495. * You will need to pass the name of the uniform as well as the value.
  7496. */
  7497. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7498. /**
  7499. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7500. * This is dynamic to allow compat with webgl 1 and 2.
  7501. * You will need to pass the name of the uniform as well as the value.
  7502. */
  7503. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7504. /**
  7505. * Instantiates a new Uniform buffer objects.
  7506. *
  7507. * Handles blocks of uniform on the GPU.
  7508. *
  7509. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7510. *
  7511. * For more information, please refer to :
  7512. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7513. * @param engine Define the engine the buffer is associated with
  7514. * @param data Define the data contained in the buffer
  7515. * @param dynamic Define if the buffer is updatable
  7516. */
  7517. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7518. /**
  7519. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7520. * or just falling back on setUniformXXX calls.
  7521. */
  7522. get useUbo(): boolean;
  7523. /**
  7524. * Indicates if the WebGL underlying uniform buffer is in sync
  7525. * with the javascript cache data.
  7526. */
  7527. get isSync(): boolean;
  7528. /**
  7529. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7530. * Also, a dynamic UniformBuffer will disable cache verification and always
  7531. * update the underlying WebGL uniform buffer to the GPU.
  7532. * @returns if Dynamic, otherwise false
  7533. */
  7534. isDynamic(): boolean;
  7535. /**
  7536. * The data cache on JS side.
  7537. * @returns the underlying data as a float array
  7538. */
  7539. getData(): Float32Array;
  7540. /**
  7541. * The underlying WebGL Uniform buffer.
  7542. * @returns the webgl buffer
  7543. */
  7544. getBuffer(): Nullable<DataBuffer>;
  7545. /**
  7546. * std140 layout specifies how to align data within an UBO structure.
  7547. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7548. * for specs.
  7549. */
  7550. private _fillAlignment;
  7551. /**
  7552. * Adds an uniform in the buffer.
  7553. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7554. * for the layout to be correct !
  7555. * @param name Name of the uniform, as used in the uniform block in the shader.
  7556. * @param size Data size, or data directly.
  7557. */
  7558. addUniform(name: string, size: number | number[]): void;
  7559. /**
  7560. * Adds a Matrix 4x4 to the uniform buffer.
  7561. * @param name Name of the uniform, as used in the uniform block in the shader.
  7562. * @param mat A 4x4 matrix.
  7563. */
  7564. addMatrix(name: string, mat: Matrix): void;
  7565. /**
  7566. * Adds a vec2 to the uniform buffer.
  7567. * @param name Name of the uniform, as used in the uniform block in the shader.
  7568. * @param x Define the x component value of the vec2
  7569. * @param y Define the y component value of the vec2
  7570. */
  7571. addFloat2(name: string, x: number, y: number): void;
  7572. /**
  7573. * Adds a vec3 to the uniform buffer.
  7574. * @param name Name of the uniform, as used in the uniform block in the shader.
  7575. * @param x Define the x component value of the vec3
  7576. * @param y Define the y component value of the vec3
  7577. * @param z Define the z component value of the vec3
  7578. */
  7579. addFloat3(name: string, x: number, y: number, z: number): void;
  7580. /**
  7581. * Adds a vec3 to the uniform buffer.
  7582. * @param name Name of the uniform, as used in the uniform block in the shader.
  7583. * @param color Define the vec3 from a Color
  7584. */
  7585. addColor3(name: string, color: Color3): void;
  7586. /**
  7587. * Adds a vec4 to the uniform buffer.
  7588. * @param name Name of the uniform, as used in the uniform block in the shader.
  7589. * @param color Define the rgb components from a Color
  7590. * @param alpha Define the a component of the vec4
  7591. */
  7592. addColor4(name: string, color: Color3, alpha: number): void;
  7593. /**
  7594. * Adds a vec3 to the uniform buffer.
  7595. * @param name Name of the uniform, as used in the uniform block in the shader.
  7596. * @param vector Define the vec3 components from a Vector
  7597. */
  7598. addVector3(name: string, vector: Vector3): void;
  7599. /**
  7600. * Adds a Matrix 3x3 to the uniform buffer.
  7601. * @param name Name of the uniform, as used in the uniform block in the shader.
  7602. */
  7603. addMatrix3x3(name: string): void;
  7604. /**
  7605. * Adds a Matrix 2x2 to the uniform buffer.
  7606. * @param name Name of the uniform, as used in the uniform block in the shader.
  7607. */
  7608. addMatrix2x2(name: string): void;
  7609. /**
  7610. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7611. */
  7612. create(): void;
  7613. /** @hidden */
  7614. _rebuild(): void;
  7615. /**
  7616. * Updates the WebGL Uniform Buffer on the GPU.
  7617. * If the `dynamic` flag is set to true, no cache comparison is done.
  7618. * Otherwise, the buffer will be updated only if the cache differs.
  7619. */
  7620. update(): void;
  7621. /**
  7622. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7623. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7624. * @param data Define the flattened data
  7625. * @param size Define the size of the data.
  7626. */
  7627. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7628. private _valueCache;
  7629. private _cacheMatrix;
  7630. private _updateMatrix3x3ForUniform;
  7631. private _updateMatrix3x3ForEffect;
  7632. private _updateMatrix2x2ForEffect;
  7633. private _updateMatrix2x2ForUniform;
  7634. private _updateFloatForEffect;
  7635. private _updateFloatForUniform;
  7636. private _updateFloat2ForEffect;
  7637. private _updateFloat2ForUniform;
  7638. private _updateFloat3ForEffect;
  7639. private _updateFloat3ForUniform;
  7640. private _updateFloat4ForEffect;
  7641. private _updateFloat4ForUniform;
  7642. private _updateMatrixForEffect;
  7643. private _updateMatrixForUniform;
  7644. private _updateVector3ForEffect;
  7645. private _updateVector3ForUniform;
  7646. private _updateVector4ForEffect;
  7647. private _updateVector4ForUniform;
  7648. private _updateColor3ForEffect;
  7649. private _updateColor3ForUniform;
  7650. private _updateColor4ForEffect;
  7651. private _updateColor4ForUniform;
  7652. /**
  7653. * Sets a sampler uniform on the effect.
  7654. * @param name Define the name of the sampler.
  7655. * @param texture Define the texture to set in the sampler
  7656. */
  7657. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7658. /**
  7659. * Directly updates the value of the uniform in the cache AND on the GPU.
  7660. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7661. * @param data Define the flattened data
  7662. */
  7663. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7664. /**
  7665. * Binds this uniform buffer to an effect.
  7666. * @param effect Define the effect to bind the buffer to
  7667. * @param name Name of the uniform block in the shader.
  7668. */
  7669. bindToEffect(effect: Effect, name: string): void;
  7670. /**
  7671. * Disposes the uniform buffer.
  7672. */
  7673. dispose(): void;
  7674. }
  7675. }
  7676. declare module BABYLON {
  7677. /**
  7678. * Enum that determines the text-wrapping mode to use.
  7679. */
  7680. export enum InspectableType {
  7681. /**
  7682. * Checkbox for booleans
  7683. */
  7684. Checkbox = 0,
  7685. /**
  7686. * Sliders for numbers
  7687. */
  7688. Slider = 1,
  7689. /**
  7690. * Vector3
  7691. */
  7692. Vector3 = 2,
  7693. /**
  7694. * Quaternions
  7695. */
  7696. Quaternion = 3,
  7697. /**
  7698. * Color3
  7699. */
  7700. Color3 = 4,
  7701. /**
  7702. * String
  7703. */
  7704. String = 5
  7705. }
  7706. /**
  7707. * Interface used to define custom inspectable properties.
  7708. * This interface is used by the inspector to display custom property grids
  7709. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7710. */
  7711. export interface IInspectable {
  7712. /**
  7713. * Gets the label to display
  7714. */
  7715. label: string;
  7716. /**
  7717. * Gets the name of the property to edit
  7718. */
  7719. propertyName: string;
  7720. /**
  7721. * Gets the type of the editor to use
  7722. */
  7723. type: InspectableType;
  7724. /**
  7725. * Gets the minimum value of the property when using in "slider" mode
  7726. */
  7727. min?: number;
  7728. /**
  7729. * Gets the maximum value of the property when using in "slider" mode
  7730. */
  7731. max?: number;
  7732. /**
  7733. * Gets the setp to use when using in "slider" mode
  7734. */
  7735. step?: number;
  7736. }
  7737. }
  7738. declare module BABYLON {
  7739. /**
  7740. * Class used to provide helper for timing
  7741. */
  7742. export class TimingTools {
  7743. /**
  7744. * Polyfill for setImmediate
  7745. * @param action defines the action to execute after the current execution block
  7746. */
  7747. static SetImmediate(action: () => void): void;
  7748. }
  7749. }
  7750. declare module BABYLON {
  7751. /**
  7752. * Class used to enable instatition of objects by class name
  7753. */
  7754. export class InstantiationTools {
  7755. /**
  7756. * Use this object to register external classes like custom textures or material
  7757. * to allow the laoders to instantiate them
  7758. */
  7759. static RegisteredExternalClasses: {
  7760. [key: string]: Object;
  7761. };
  7762. /**
  7763. * Tries to instantiate a new object from a given class name
  7764. * @param className defines the class name to instantiate
  7765. * @returns the new object or null if the system was not able to do the instantiation
  7766. */
  7767. static Instantiate(className: string): any;
  7768. }
  7769. }
  7770. declare module BABYLON {
  7771. /**
  7772. * Define options used to create a depth texture
  7773. */
  7774. export class DepthTextureCreationOptions {
  7775. /** Specifies whether or not a stencil should be allocated in the texture */
  7776. generateStencil?: boolean;
  7777. /** Specifies whether or not bilinear filtering is enable on the texture */
  7778. bilinearFiltering?: boolean;
  7779. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7780. comparisonFunction?: number;
  7781. /** Specifies if the created texture is a cube texture */
  7782. isCube?: boolean;
  7783. }
  7784. }
  7785. declare module BABYLON {
  7786. interface ThinEngine {
  7787. /**
  7788. * Creates a depth stencil cube texture.
  7789. * This is only available in WebGL 2.
  7790. * @param size The size of face edge in the cube texture.
  7791. * @param options The options defining the cube texture.
  7792. * @returns The cube texture
  7793. */
  7794. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7795. /**
  7796. * Creates a cube texture
  7797. * @param rootUrl defines the url where the files to load is located
  7798. * @param scene defines the current scene
  7799. * @param files defines the list of files to load (1 per face)
  7800. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7801. * @param onLoad defines an optional callback raised when the texture is loaded
  7802. * @param onError defines an optional callback raised if there is an issue to load the texture
  7803. * @param format defines the format of the data
  7804. * @param forcedExtension defines the extension to use to pick the right loader
  7805. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7806. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7807. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7808. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7809. * @returns the cube texture as an InternalTexture
  7810. */
  7811. 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;
  7812. /**
  7813. * Creates a cube texture
  7814. * @param rootUrl defines the url where the files to load is located
  7815. * @param scene defines the current scene
  7816. * @param files defines the list of files to load (1 per face)
  7817. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7818. * @param onLoad defines an optional callback raised when the texture is loaded
  7819. * @param onError defines an optional callback raised if there is an issue to load the texture
  7820. * @param format defines the format of the data
  7821. * @param forcedExtension defines the extension to use to pick the right loader
  7822. * @returns the cube texture as an InternalTexture
  7823. */
  7824. 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;
  7825. /**
  7826. * Creates a cube texture
  7827. * @param rootUrl defines the url where the files to load is located
  7828. * @param scene defines the current scene
  7829. * @param files defines the list of files to load (1 per face)
  7830. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7831. * @param onLoad defines an optional callback raised when the texture is loaded
  7832. * @param onError defines an optional callback raised if there is an issue to load the texture
  7833. * @param format defines the format of the data
  7834. * @param forcedExtension defines the extension to use to pick the right loader
  7835. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7836. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7837. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7838. * @returns the cube texture as an InternalTexture
  7839. */
  7840. 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;
  7841. /** @hidden */
  7842. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7843. /** @hidden */
  7844. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7845. /** @hidden */
  7846. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7847. /** @hidden */
  7848. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7849. /**
  7850. * @hidden
  7851. */
  7852. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7853. }
  7854. }
  7855. declare module BABYLON {
  7856. /**
  7857. * Class for creating a cube texture
  7858. */
  7859. export class CubeTexture extends BaseTexture {
  7860. private _delayedOnLoad;
  7861. /**
  7862. * Observable triggered once the texture has been loaded.
  7863. */
  7864. onLoadObservable: Observable<CubeTexture>;
  7865. /**
  7866. * The url of the texture
  7867. */
  7868. url: string;
  7869. /**
  7870. * Gets or sets the center of the bounding box associated with the cube texture.
  7871. * It must define where the camera used to render the texture was set
  7872. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7873. */
  7874. boundingBoxPosition: Vector3;
  7875. private _boundingBoxSize;
  7876. /**
  7877. * Gets or sets the size of the bounding box associated with the cube texture
  7878. * When defined, the cubemap will switch to local mode
  7879. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7880. * @example https://www.babylonjs-playground.com/#RNASML
  7881. */
  7882. set boundingBoxSize(value: Vector3);
  7883. /**
  7884. * Returns the bounding box size
  7885. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7886. */
  7887. get boundingBoxSize(): Vector3;
  7888. protected _rotationY: number;
  7889. /**
  7890. * Sets texture matrix rotation angle around Y axis in radians.
  7891. */
  7892. set rotationY(value: number);
  7893. /**
  7894. * Gets texture matrix rotation angle around Y axis radians.
  7895. */
  7896. get rotationY(): number;
  7897. /**
  7898. * Are mip maps generated for this texture or not.
  7899. */
  7900. get noMipmap(): boolean;
  7901. private _noMipmap;
  7902. private _files;
  7903. protected _forcedExtension: Nullable<string>;
  7904. private _extensions;
  7905. private _textureMatrix;
  7906. private _format;
  7907. private _createPolynomials;
  7908. /**
  7909. * Creates a cube texture from an array of image urls
  7910. * @param files defines an array of image urls
  7911. * @param scene defines the hosting scene
  7912. * @param noMipmap specifies if mip maps are not used
  7913. * @returns a cube texture
  7914. */
  7915. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7916. /**
  7917. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7918. * @param url defines the url of the prefiltered texture
  7919. * @param scene defines the scene the texture is attached to
  7920. * @param forcedExtension defines the extension of the file if different from the url
  7921. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7922. * @return the prefiltered texture
  7923. */
  7924. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7925. /**
  7926. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7927. * as prefiltered data.
  7928. * @param rootUrl defines the url of the texture or the root name of the six images
  7929. * @param null defines the scene or engine the texture is attached to
  7930. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7931. * @param noMipmap defines if mipmaps should be created or not
  7932. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7933. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7934. * @param onError defines a callback triggered in case of error during load
  7935. * @param format defines the internal format to use for the texture once loaded
  7936. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7937. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7938. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7939. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7940. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7941. * @return the cube texture
  7942. */
  7943. 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);
  7944. /**
  7945. * Get the current class name of the texture useful for serialization or dynamic coding.
  7946. * @returns "CubeTexture"
  7947. */
  7948. getClassName(): string;
  7949. /**
  7950. * Update the url (and optional buffer) of this texture if url was null during construction.
  7951. * @param url the url of the texture
  7952. * @param forcedExtension defines the extension to use
  7953. * @param onLoad callback called when the texture is loaded (defaults to null)
  7954. * @param prefiltered Defines whether the updated texture is prefiltered or not
  7955. */
  7956. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  7957. /**
  7958. * Delays loading of the cube texture
  7959. * @param forcedExtension defines the extension to use
  7960. */
  7961. delayLoad(forcedExtension?: string): void;
  7962. /**
  7963. * Returns the reflection texture matrix
  7964. * @returns the reflection texture matrix
  7965. */
  7966. getReflectionTextureMatrix(): Matrix;
  7967. /**
  7968. * Sets the reflection texture matrix
  7969. * @param value Reflection texture matrix
  7970. */
  7971. setReflectionTextureMatrix(value: Matrix): void;
  7972. /**
  7973. * Parses text to create a cube texture
  7974. * @param parsedTexture define the serialized text to read from
  7975. * @param scene defines the hosting scene
  7976. * @param rootUrl defines the root url of the cube texture
  7977. * @returns a cube texture
  7978. */
  7979. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7980. /**
  7981. * Makes a clone, or deep copy, of the cube texture
  7982. * @returns a new cube texture
  7983. */
  7984. clone(): CubeTexture;
  7985. }
  7986. }
  7987. declare module BABYLON {
  7988. /**
  7989. * Manages the defines for the Material
  7990. */
  7991. export class MaterialDefines {
  7992. /** @hidden */
  7993. protected _keys: string[];
  7994. private _isDirty;
  7995. /** @hidden */
  7996. _renderId: number;
  7997. /** @hidden */
  7998. _areLightsDirty: boolean;
  7999. /** @hidden */
  8000. _areLightsDisposed: boolean;
  8001. /** @hidden */
  8002. _areAttributesDirty: boolean;
  8003. /** @hidden */
  8004. _areTexturesDirty: boolean;
  8005. /** @hidden */
  8006. _areFresnelDirty: boolean;
  8007. /** @hidden */
  8008. _areMiscDirty: boolean;
  8009. /** @hidden */
  8010. _arePrePassDirty: boolean;
  8011. /** @hidden */
  8012. _areImageProcessingDirty: boolean;
  8013. /** @hidden */
  8014. _normals: boolean;
  8015. /** @hidden */
  8016. _uvs: boolean;
  8017. /** @hidden */
  8018. _needNormals: boolean;
  8019. /** @hidden */
  8020. _needUVs: boolean;
  8021. [id: string]: any;
  8022. /**
  8023. * Specifies if the material needs to be re-calculated
  8024. */
  8025. get isDirty(): boolean;
  8026. /**
  8027. * Marks the material to indicate that it has been re-calculated
  8028. */
  8029. markAsProcessed(): void;
  8030. /**
  8031. * Marks the material to indicate that it needs to be re-calculated
  8032. */
  8033. markAsUnprocessed(): void;
  8034. /**
  8035. * Marks the material to indicate all of its defines need to be re-calculated
  8036. */
  8037. markAllAsDirty(): void;
  8038. /**
  8039. * Marks the material to indicate that image processing needs to be re-calculated
  8040. */
  8041. markAsImageProcessingDirty(): void;
  8042. /**
  8043. * Marks the material to indicate the lights need to be re-calculated
  8044. * @param disposed Defines whether the light is dirty due to dispose or not
  8045. */
  8046. markAsLightDirty(disposed?: boolean): void;
  8047. /**
  8048. * Marks the attribute state as changed
  8049. */
  8050. markAsAttributesDirty(): void;
  8051. /**
  8052. * Marks the texture state as changed
  8053. */
  8054. markAsTexturesDirty(): void;
  8055. /**
  8056. * Marks the fresnel state as changed
  8057. */
  8058. markAsFresnelDirty(): void;
  8059. /**
  8060. * Marks the misc state as changed
  8061. */
  8062. markAsMiscDirty(): void;
  8063. /**
  8064. * Marks the prepass state as changed
  8065. */
  8066. markAsPrePassDirty(): void;
  8067. /**
  8068. * Rebuilds the material defines
  8069. */
  8070. rebuild(): void;
  8071. /**
  8072. * Specifies if two material defines are equal
  8073. * @param other - A material define instance to compare to
  8074. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8075. */
  8076. isEqual(other: MaterialDefines): boolean;
  8077. /**
  8078. * Clones this instance's defines to another instance
  8079. * @param other - material defines to clone values to
  8080. */
  8081. cloneTo(other: MaterialDefines): void;
  8082. /**
  8083. * Resets the material define values
  8084. */
  8085. reset(): void;
  8086. /**
  8087. * Converts the material define values to a string
  8088. * @returns - String of material define information
  8089. */
  8090. toString(): string;
  8091. }
  8092. }
  8093. declare module BABYLON {
  8094. /**
  8095. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  8096. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  8097. * 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;
  8098. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  8099. */
  8100. export class ColorCurves {
  8101. private _dirty;
  8102. private _tempColor;
  8103. private _globalCurve;
  8104. private _highlightsCurve;
  8105. private _midtonesCurve;
  8106. private _shadowsCurve;
  8107. private _positiveCurve;
  8108. private _negativeCurve;
  8109. private _globalHue;
  8110. private _globalDensity;
  8111. private _globalSaturation;
  8112. private _globalExposure;
  8113. /**
  8114. * Gets the global Hue value.
  8115. * 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).
  8116. */
  8117. get globalHue(): number;
  8118. /**
  8119. * Sets the global Hue value.
  8120. * 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).
  8121. */
  8122. set globalHue(value: number);
  8123. /**
  8124. * Gets the global Density value.
  8125. * 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.
  8126. * Values less than zero provide a filter of opposite hue.
  8127. */
  8128. get globalDensity(): number;
  8129. /**
  8130. * Sets the global Density value.
  8131. * 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.
  8132. * Values less than zero provide a filter of opposite hue.
  8133. */
  8134. set globalDensity(value: number);
  8135. /**
  8136. * Gets the global Saturation value.
  8137. * 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.
  8138. */
  8139. get globalSaturation(): number;
  8140. /**
  8141. * Sets the global Saturation value.
  8142. * 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.
  8143. */
  8144. set globalSaturation(value: number);
  8145. /**
  8146. * Gets the global Exposure value.
  8147. * 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.
  8148. */
  8149. get globalExposure(): number;
  8150. /**
  8151. * Sets the global Exposure value.
  8152. * 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.
  8153. */
  8154. set globalExposure(value: number);
  8155. private _highlightsHue;
  8156. private _highlightsDensity;
  8157. private _highlightsSaturation;
  8158. private _highlightsExposure;
  8159. /**
  8160. * Gets the highlights Hue value.
  8161. * 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).
  8162. */
  8163. get highlightsHue(): number;
  8164. /**
  8165. * Sets the highlights Hue value.
  8166. * 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).
  8167. */
  8168. set highlightsHue(value: number);
  8169. /**
  8170. * Gets the highlights Density value.
  8171. * 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.
  8172. * Values less than zero provide a filter of opposite hue.
  8173. */
  8174. get highlightsDensity(): number;
  8175. /**
  8176. * Sets the highlights Density value.
  8177. * 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.
  8178. * Values less than zero provide a filter of opposite hue.
  8179. */
  8180. set highlightsDensity(value: number);
  8181. /**
  8182. * Gets the highlights Saturation value.
  8183. * 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.
  8184. */
  8185. get highlightsSaturation(): number;
  8186. /**
  8187. * Sets the highlights Saturation value.
  8188. * 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.
  8189. */
  8190. set highlightsSaturation(value: number);
  8191. /**
  8192. * Gets the highlights Exposure value.
  8193. * 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.
  8194. */
  8195. get highlightsExposure(): number;
  8196. /**
  8197. * Sets the highlights Exposure value.
  8198. * 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.
  8199. */
  8200. set highlightsExposure(value: number);
  8201. private _midtonesHue;
  8202. private _midtonesDensity;
  8203. private _midtonesSaturation;
  8204. private _midtonesExposure;
  8205. /**
  8206. * Gets the midtones Hue value.
  8207. * 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).
  8208. */
  8209. get midtonesHue(): number;
  8210. /**
  8211. * Sets the midtones Hue value.
  8212. * 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).
  8213. */
  8214. set midtonesHue(value: number);
  8215. /**
  8216. * Gets the midtones Density value.
  8217. * 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.
  8218. * Values less than zero provide a filter of opposite hue.
  8219. */
  8220. get midtonesDensity(): number;
  8221. /**
  8222. * Sets the midtones Density value.
  8223. * 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.
  8224. * Values less than zero provide a filter of opposite hue.
  8225. */
  8226. set midtonesDensity(value: number);
  8227. /**
  8228. * Gets the midtones Saturation value.
  8229. * 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.
  8230. */
  8231. get midtonesSaturation(): number;
  8232. /**
  8233. * Sets the midtones Saturation value.
  8234. * 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.
  8235. */
  8236. set midtonesSaturation(value: number);
  8237. /**
  8238. * Gets the midtones Exposure value.
  8239. * 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.
  8240. */
  8241. get midtonesExposure(): number;
  8242. /**
  8243. * Sets the midtones Exposure value.
  8244. * 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.
  8245. */
  8246. set midtonesExposure(value: number);
  8247. private _shadowsHue;
  8248. private _shadowsDensity;
  8249. private _shadowsSaturation;
  8250. private _shadowsExposure;
  8251. /**
  8252. * Gets the shadows Hue value.
  8253. * 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).
  8254. */
  8255. get shadowsHue(): number;
  8256. /**
  8257. * Sets the shadows Hue value.
  8258. * 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).
  8259. */
  8260. set shadowsHue(value: number);
  8261. /**
  8262. * Gets the shadows Density value.
  8263. * 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.
  8264. * Values less than zero provide a filter of opposite hue.
  8265. */
  8266. get shadowsDensity(): number;
  8267. /**
  8268. * Sets the shadows Density value.
  8269. * 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.
  8270. * Values less than zero provide a filter of opposite hue.
  8271. */
  8272. set shadowsDensity(value: number);
  8273. /**
  8274. * Gets the shadows Saturation value.
  8275. * 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.
  8276. */
  8277. get shadowsSaturation(): number;
  8278. /**
  8279. * Sets the shadows Saturation value.
  8280. * 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.
  8281. */
  8282. set shadowsSaturation(value: number);
  8283. /**
  8284. * Gets the shadows Exposure value.
  8285. * 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.
  8286. */
  8287. get shadowsExposure(): number;
  8288. /**
  8289. * Sets the shadows Exposure value.
  8290. * 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.
  8291. */
  8292. set shadowsExposure(value: number);
  8293. /**
  8294. * Returns the class name
  8295. * @returns The class name
  8296. */
  8297. getClassName(): string;
  8298. /**
  8299. * Binds the color curves to the shader.
  8300. * @param colorCurves The color curve to bind
  8301. * @param effect The effect to bind to
  8302. * @param positiveUniform The positive uniform shader parameter
  8303. * @param neutralUniform The neutral uniform shader parameter
  8304. * @param negativeUniform The negative uniform shader parameter
  8305. */
  8306. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8307. /**
  8308. * Prepare the list of uniforms associated with the ColorCurves effects.
  8309. * @param uniformsList The list of uniforms used in the effect
  8310. */
  8311. static PrepareUniforms(uniformsList: string[]): void;
  8312. /**
  8313. * Returns color grading data based on a hue, density, saturation and exposure value.
  8314. * @param filterHue The hue of the color filter.
  8315. * @param filterDensity The density of the color filter.
  8316. * @param saturation The saturation.
  8317. * @param exposure The exposure.
  8318. * @param result The result data container.
  8319. */
  8320. private getColorGradingDataToRef;
  8321. /**
  8322. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8323. * @param value The input slider value in range [-100,100].
  8324. * @returns Adjusted value.
  8325. */
  8326. private static applyColorGradingSliderNonlinear;
  8327. /**
  8328. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8329. * @param hue The hue (H) input.
  8330. * @param saturation The saturation (S) input.
  8331. * @param brightness The brightness (B) input.
  8332. * @result An RGBA color represented as Vector4.
  8333. */
  8334. private static fromHSBToRef;
  8335. /**
  8336. * Returns a value clamped between min and max
  8337. * @param value The value to clamp
  8338. * @param min The minimum of value
  8339. * @param max The maximum of value
  8340. * @returns The clamped value.
  8341. */
  8342. private static clamp;
  8343. /**
  8344. * Clones the current color curve instance.
  8345. * @return The cloned curves
  8346. */
  8347. clone(): ColorCurves;
  8348. /**
  8349. * Serializes the current color curve instance to a json representation.
  8350. * @return a JSON representation
  8351. */
  8352. serialize(): any;
  8353. /**
  8354. * Parses the color curve from a json representation.
  8355. * @param source the JSON source to parse
  8356. * @return The parsed curves
  8357. */
  8358. static Parse(source: any): ColorCurves;
  8359. }
  8360. }
  8361. declare module BABYLON {
  8362. /**
  8363. * Interface to follow in your material defines to integrate easily the
  8364. * Image proccessing functions.
  8365. * @hidden
  8366. */
  8367. export interface IImageProcessingConfigurationDefines {
  8368. IMAGEPROCESSING: boolean;
  8369. VIGNETTE: boolean;
  8370. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8371. VIGNETTEBLENDMODEOPAQUE: boolean;
  8372. TONEMAPPING: boolean;
  8373. TONEMAPPING_ACES: boolean;
  8374. CONTRAST: boolean;
  8375. EXPOSURE: boolean;
  8376. COLORCURVES: boolean;
  8377. COLORGRADING: boolean;
  8378. COLORGRADING3D: boolean;
  8379. SAMPLER3DGREENDEPTH: boolean;
  8380. SAMPLER3DBGRMAP: boolean;
  8381. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8382. }
  8383. /**
  8384. * @hidden
  8385. */
  8386. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8387. IMAGEPROCESSING: boolean;
  8388. VIGNETTE: boolean;
  8389. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8390. VIGNETTEBLENDMODEOPAQUE: boolean;
  8391. TONEMAPPING: boolean;
  8392. TONEMAPPING_ACES: boolean;
  8393. CONTRAST: boolean;
  8394. COLORCURVES: boolean;
  8395. COLORGRADING: boolean;
  8396. COLORGRADING3D: boolean;
  8397. SAMPLER3DGREENDEPTH: boolean;
  8398. SAMPLER3DBGRMAP: boolean;
  8399. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8400. EXPOSURE: boolean;
  8401. constructor();
  8402. }
  8403. /**
  8404. * This groups together the common properties used for image processing either in direct forward pass
  8405. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8406. * or not.
  8407. */
  8408. export class ImageProcessingConfiguration {
  8409. /**
  8410. * Default tone mapping applied in BabylonJS.
  8411. */
  8412. static readonly TONEMAPPING_STANDARD: number;
  8413. /**
  8414. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8415. * to other engines rendering to increase portability.
  8416. */
  8417. static readonly TONEMAPPING_ACES: number;
  8418. /**
  8419. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8420. */
  8421. colorCurves: Nullable<ColorCurves>;
  8422. private _colorCurvesEnabled;
  8423. /**
  8424. * Gets wether the color curves effect is enabled.
  8425. */
  8426. get colorCurvesEnabled(): boolean;
  8427. /**
  8428. * Sets wether the color curves effect is enabled.
  8429. */
  8430. set colorCurvesEnabled(value: boolean);
  8431. private _colorGradingTexture;
  8432. /**
  8433. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8434. */
  8435. get colorGradingTexture(): Nullable<BaseTexture>;
  8436. /**
  8437. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8438. */
  8439. set colorGradingTexture(value: Nullable<BaseTexture>);
  8440. private _colorGradingEnabled;
  8441. /**
  8442. * Gets wether the color grading effect is enabled.
  8443. */
  8444. get colorGradingEnabled(): boolean;
  8445. /**
  8446. * Sets wether the color grading effect is enabled.
  8447. */
  8448. set colorGradingEnabled(value: boolean);
  8449. private _colorGradingWithGreenDepth;
  8450. /**
  8451. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8452. */
  8453. get colorGradingWithGreenDepth(): boolean;
  8454. /**
  8455. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8456. */
  8457. set colorGradingWithGreenDepth(value: boolean);
  8458. private _colorGradingBGR;
  8459. /**
  8460. * Gets wether the color grading texture contains BGR values.
  8461. */
  8462. get colorGradingBGR(): boolean;
  8463. /**
  8464. * Sets wether the color grading texture contains BGR values.
  8465. */
  8466. set colorGradingBGR(value: boolean);
  8467. /** @hidden */
  8468. _exposure: number;
  8469. /**
  8470. * Gets the Exposure used in the effect.
  8471. */
  8472. get exposure(): number;
  8473. /**
  8474. * Sets the Exposure used in the effect.
  8475. */
  8476. set exposure(value: number);
  8477. private _toneMappingEnabled;
  8478. /**
  8479. * Gets wether the tone mapping effect is enabled.
  8480. */
  8481. get toneMappingEnabled(): boolean;
  8482. /**
  8483. * Sets wether the tone mapping effect is enabled.
  8484. */
  8485. set toneMappingEnabled(value: boolean);
  8486. private _toneMappingType;
  8487. /**
  8488. * Gets the type of tone mapping effect.
  8489. */
  8490. get toneMappingType(): number;
  8491. /**
  8492. * Sets the type of tone mapping effect used in BabylonJS.
  8493. */
  8494. set toneMappingType(value: number);
  8495. protected _contrast: number;
  8496. /**
  8497. * Gets the contrast used in the effect.
  8498. */
  8499. get contrast(): number;
  8500. /**
  8501. * Sets the contrast used in the effect.
  8502. */
  8503. set contrast(value: number);
  8504. /**
  8505. * Vignette stretch size.
  8506. */
  8507. vignetteStretch: number;
  8508. /**
  8509. * Vignette centre X Offset.
  8510. */
  8511. vignetteCentreX: number;
  8512. /**
  8513. * Vignette centre Y Offset.
  8514. */
  8515. vignetteCentreY: number;
  8516. /**
  8517. * Vignette weight or intensity of the vignette effect.
  8518. */
  8519. vignetteWeight: number;
  8520. /**
  8521. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8522. * if vignetteEnabled is set to true.
  8523. */
  8524. vignetteColor: Color4;
  8525. /**
  8526. * Camera field of view used by the Vignette effect.
  8527. */
  8528. vignetteCameraFov: number;
  8529. private _vignetteBlendMode;
  8530. /**
  8531. * Gets the vignette blend mode allowing different kind of effect.
  8532. */
  8533. get vignetteBlendMode(): number;
  8534. /**
  8535. * Sets the vignette blend mode allowing different kind of effect.
  8536. */
  8537. set vignetteBlendMode(value: number);
  8538. private _vignetteEnabled;
  8539. /**
  8540. * Gets wether the vignette effect is enabled.
  8541. */
  8542. get vignetteEnabled(): boolean;
  8543. /**
  8544. * Sets wether the vignette effect is enabled.
  8545. */
  8546. set vignetteEnabled(value: boolean);
  8547. private _applyByPostProcess;
  8548. /**
  8549. * Gets wether the image processing is applied through a post process or not.
  8550. */
  8551. get applyByPostProcess(): boolean;
  8552. /**
  8553. * Sets wether the image processing is applied through a post process or not.
  8554. */
  8555. set applyByPostProcess(value: boolean);
  8556. private _isEnabled;
  8557. /**
  8558. * Gets wether the image processing is enabled or not.
  8559. */
  8560. get isEnabled(): boolean;
  8561. /**
  8562. * Sets wether the image processing is enabled or not.
  8563. */
  8564. set isEnabled(value: boolean);
  8565. /**
  8566. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8567. */
  8568. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8569. /**
  8570. * Method called each time the image processing information changes requires to recompile the effect.
  8571. */
  8572. protected _updateParameters(): void;
  8573. /**
  8574. * Gets the current class name.
  8575. * @return "ImageProcessingConfiguration"
  8576. */
  8577. getClassName(): string;
  8578. /**
  8579. * Prepare the list of uniforms associated with the Image Processing effects.
  8580. * @param uniforms The list of uniforms used in the effect
  8581. * @param defines the list of defines currently in use
  8582. */
  8583. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8584. /**
  8585. * Prepare the list of samplers associated with the Image Processing effects.
  8586. * @param samplersList The list of uniforms used in the effect
  8587. * @param defines the list of defines currently in use
  8588. */
  8589. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8590. /**
  8591. * Prepare the list of defines associated to the shader.
  8592. * @param defines the list of defines to complete
  8593. * @param forPostProcess Define if we are currently in post process mode or not
  8594. */
  8595. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8596. /**
  8597. * Returns true if all the image processing information are ready.
  8598. * @returns True if ready, otherwise, false
  8599. */
  8600. isReady(): boolean;
  8601. /**
  8602. * Binds the image processing to the shader.
  8603. * @param effect The effect to bind to
  8604. * @param overrideAspectRatio Override the aspect ratio of the effect
  8605. */
  8606. bind(effect: Effect, overrideAspectRatio?: number): void;
  8607. /**
  8608. * Clones the current image processing instance.
  8609. * @return The cloned image processing
  8610. */
  8611. clone(): ImageProcessingConfiguration;
  8612. /**
  8613. * Serializes the current image processing instance to a json representation.
  8614. * @return a JSON representation
  8615. */
  8616. serialize(): any;
  8617. /**
  8618. * Parses the image processing from a json representation.
  8619. * @param source the JSON source to parse
  8620. * @return The parsed image processing
  8621. */
  8622. static Parse(source: any): ImageProcessingConfiguration;
  8623. private static _VIGNETTEMODE_MULTIPLY;
  8624. private static _VIGNETTEMODE_OPAQUE;
  8625. /**
  8626. * Used to apply the vignette as a mix with the pixel color.
  8627. */
  8628. static get VIGNETTEMODE_MULTIPLY(): number;
  8629. /**
  8630. * Used to apply the vignette as a replacement of the pixel color.
  8631. */
  8632. static get VIGNETTEMODE_OPAQUE(): number;
  8633. }
  8634. }
  8635. declare module BABYLON {
  8636. /** @hidden */
  8637. export var postprocessVertexShader: {
  8638. name: string;
  8639. shader: string;
  8640. };
  8641. }
  8642. declare module BABYLON {
  8643. /**
  8644. * Type used to define a render target texture size (either with a number or with a rect width and height)
  8645. */
  8646. export type RenderTargetTextureSize = number | {
  8647. width: number;
  8648. height: number;
  8649. layers?: number;
  8650. };
  8651. interface ThinEngine {
  8652. /**
  8653. * Creates a new render target texture
  8654. * @param size defines the size of the texture
  8655. * @param options defines the options used to create the texture
  8656. * @returns a new render target texture stored in an InternalTexture
  8657. */
  8658. createRenderTargetTexture(size: RenderTargetTextureSize, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8659. /**
  8660. * Creates a depth stencil texture.
  8661. * This is only available in WebGL 2 or with the depth texture extension available.
  8662. * @param size The size of face edge in the texture.
  8663. * @param options The options defining the texture.
  8664. * @returns The texture
  8665. */
  8666. createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  8667. /** @hidden */
  8668. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  8669. }
  8670. }
  8671. declare module BABYLON {
  8672. /**
  8673. * Defines the kind of connection point for node based material
  8674. */
  8675. export enum NodeMaterialBlockConnectionPointTypes {
  8676. /** Float */
  8677. Float = 1,
  8678. /** Int */
  8679. Int = 2,
  8680. /** Vector2 */
  8681. Vector2 = 4,
  8682. /** Vector3 */
  8683. Vector3 = 8,
  8684. /** Vector4 */
  8685. Vector4 = 16,
  8686. /** Color3 */
  8687. Color3 = 32,
  8688. /** Color4 */
  8689. Color4 = 64,
  8690. /** Matrix */
  8691. Matrix = 128,
  8692. /** Custom object */
  8693. Object = 256,
  8694. /** Detect type based on connection */
  8695. AutoDetect = 1024,
  8696. /** Output type that will be defined by input type */
  8697. BasedOnInput = 2048
  8698. }
  8699. }
  8700. declare module BABYLON {
  8701. /**
  8702. * Enum used to define the target of a block
  8703. */
  8704. export enum NodeMaterialBlockTargets {
  8705. /** Vertex shader */
  8706. Vertex = 1,
  8707. /** Fragment shader */
  8708. Fragment = 2,
  8709. /** Neutral */
  8710. Neutral = 4,
  8711. /** Vertex and Fragment */
  8712. VertexAndFragment = 3
  8713. }
  8714. }
  8715. declare module BABYLON {
  8716. /**
  8717. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  8718. */
  8719. export enum NodeMaterialBlockConnectionPointMode {
  8720. /** Value is an uniform */
  8721. Uniform = 0,
  8722. /** Value is a mesh attribute */
  8723. Attribute = 1,
  8724. /** Value is a varying between vertex and fragment shaders */
  8725. Varying = 2,
  8726. /** Mode is undefined */
  8727. Undefined = 3
  8728. }
  8729. }
  8730. declare module BABYLON {
  8731. /**
  8732. * Enum used to define system values e.g. values automatically provided by the system
  8733. */
  8734. export enum NodeMaterialSystemValues {
  8735. /** World */
  8736. World = 1,
  8737. /** View */
  8738. View = 2,
  8739. /** Projection */
  8740. Projection = 3,
  8741. /** ViewProjection */
  8742. ViewProjection = 4,
  8743. /** WorldView */
  8744. WorldView = 5,
  8745. /** WorldViewProjection */
  8746. WorldViewProjection = 6,
  8747. /** CameraPosition */
  8748. CameraPosition = 7,
  8749. /** Fog Color */
  8750. FogColor = 8,
  8751. /** Delta time */
  8752. DeltaTime = 9
  8753. }
  8754. }
  8755. declare module BABYLON {
  8756. /** Defines supported spaces */
  8757. export enum Space {
  8758. /** Local (object) space */
  8759. LOCAL = 0,
  8760. /** World space */
  8761. WORLD = 1,
  8762. /** Bone space */
  8763. BONE = 2
  8764. }
  8765. /** Defines the 3 main axes */
  8766. export class Axis {
  8767. /** X axis */
  8768. static X: Vector3;
  8769. /** Y axis */
  8770. static Y: Vector3;
  8771. /** Z axis */
  8772. static Z: Vector3;
  8773. }
  8774. }
  8775. declare module BABYLON {
  8776. /**
  8777. * Represents a camera frustum
  8778. */
  8779. export class Frustum {
  8780. /**
  8781. * Gets the planes representing the frustum
  8782. * @param transform matrix to be applied to the returned planes
  8783. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  8784. */
  8785. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  8786. /**
  8787. * Gets the near frustum plane transformed by the transform matrix
  8788. * @param transform transformation matrix to be applied to the resulting frustum plane
  8789. * @param frustumPlane the resuling frustum plane
  8790. */
  8791. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8792. /**
  8793. * Gets the far frustum plane transformed by the transform matrix
  8794. * @param transform transformation matrix to be applied to the resulting frustum plane
  8795. * @param frustumPlane the resuling frustum plane
  8796. */
  8797. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8798. /**
  8799. * Gets the left frustum plane transformed by the transform matrix
  8800. * @param transform transformation matrix to be applied to the resulting frustum plane
  8801. * @param frustumPlane the resuling frustum plane
  8802. */
  8803. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8804. /**
  8805. * Gets the right frustum plane transformed by the transform matrix
  8806. * @param transform transformation matrix to be applied to the resulting frustum plane
  8807. * @param frustumPlane the resuling frustum plane
  8808. */
  8809. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8810. /**
  8811. * Gets the top frustum plane transformed by the transform matrix
  8812. * @param transform transformation matrix to be applied to the resulting frustum plane
  8813. * @param frustumPlane the resuling frustum plane
  8814. */
  8815. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8816. /**
  8817. * Gets the bottom frustum plane transformed by the transform matrix
  8818. * @param transform transformation matrix to be applied to the resulting frustum plane
  8819. * @param frustumPlane the resuling frustum plane
  8820. */
  8821. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8822. /**
  8823. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  8824. * @param transform transformation matrix to be applied to the resulting frustum planes
  8825. * @param frustumPlanes the resuling frustum planes
  8826. */
  8827. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  8828. }
  8829. }
  8830. declare module BABYLON {
  8831. /**
  8832. * Interface for the size containing width and height
  8833. */
  8834. export interface ISize {
  8835. /**
  8836. * Width
  8837. */
  8838. width: number;
  8839. /**
  8840. * Heighht
  8841. */
  8842. height: number;
  8843. }
  8844. /**
  8845. * Size containing widht and height
  8846. */
  8847. export class Size implements ISize {
  8848. /**
  8849. * Width
  8850. */
  8851. width: number;
  8852. /**
  8853. * Height
  8854. */
  8855. height: number;
  8856. /**
  8857. * Creates a Size object from the given width and height (floats).
  8858. * @param width width of the new size
  8859. * @param height height of the new size
  8860. */
  8861. constructor(width: number, height: number);
  8862. /**
  8863. * Returns a string with the Size width and height
  8864. * @returns a string with the Size width and height
  8865. */
  8866. toString(): string;
  8867. /**
  8868. * "Size"
  8869. * @returns the string "Size"
  8870. */
  8871. getClassName(): string;
  8872. /**
  8873. * Returns the Size hash code.
  8874. * @returns a hash code for a unique width and height
  8875. */
  8876. getHashCode(): number;
  8877. /**
  8878. * Updates the current size from the given one.
  8879. * @param src the given size
  8880. */
  8881. copyFrom(src: Size): void;
  8882. /**
  8883. * Updates in place the current Size from the given floats.
  8884. * @param width width of the new size
  8885. * @param height height of the new size
  8886. * @returns the updated Size.
  8887. */
  8888. copyFromFloats(width: number, height: number): Size;
  8889. /**
  8890. * Updates in place the current Size from the given floats.
  8891. * @param width width to set
  8892. * @param height height to set
  8893. * @returns the updated Size.
  8894. */
  8895. set(width: number, height: number): Size;
  8896. /**
  8897. * Multiplies the width and height by numbers
  8898. * @param w factor to multiple the width by
  8899. * @param h factor to multiple the height by
  8900. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  8901. */
  8902. multiplyByFloats(w: number, h: number): Size;
  8903. /**
  8904. * Clones the size
  8905. * @returns a new Size copied from the given one.
  8906. */
  8907. clone(): Size;
  8908. /**
  8909. * True if the current Size and the given one width and height are strictly equal.
  8910. * @param other the other size to compare against
  8911. * @returns True if the current Size and the given one width and height are strictly equal.
  8912. */
  8913. equals(other: Size): boolean;
  8914. /**
  8915. * The surface of the Size : width * height (float).
  8916. */
  8917. get surface(): number;
  8918. /**
  8919. * Create a new size of zero
  8920. * @returns a new Size set to (0.0, 0.0)
  8921. */
  8922. static Zero(): Size;
  8923. /**
  8924. * Sums the width and height of two sizes
  8925. * @param otherSize size to add to this size
  8926. * @returns a new Size set as the addition result of the current Size and the given one.
  8927. */
  8928. add(otherSize: Size): Size;
  8929. /**
  8930. * Subtracts the width and height of two
  8931. * @param otherSize size to subtract to this size
  8932. * @returns a new Size set as the subtraction result of the given one from the current Size.
  8933. */
  8934. subtract(otherSize: Size): Size;
  8935. /**
  8936. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  8937. * @param start starting size to lerp between
  8938. * @param end end size to lerp between
  8939. * @param amount amount to lerp between the start and end values
  8940. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  8941. */
  8942. static Lerp(start: Size, end: Size, amount: number): Size;
  8943. }
  8944. }
  8945. declare module BABYLON {
  8946. /**
  8947. * Contains position and normal vectors for a vertex
  8948. */
  8949. export class PositionNormalVertex {
  8950. /** the position of the vertex (defaut: 0,0,0) */
  8951. position: Vector3;
  8952. /** the normal of the vertex (defaut: 0,1,0) */
  8953. normal: Vector3;
  8954. /**
  8955. * Creates a PositionNormalVertex
  8956. * @param position the position of the vertex (defaut: 0,0,0)
  8957. * @param normal the normal of the vertex (defaut: 0,1,0)
  8958. */
  8959. constructor(
  8960. /** the position of the vertex (defaut: 0,0,0) */
  8961. position?: Vector3,
  8962. /** the normal of the vertex (defaut: 0,1,0) */
  8963. normal?: Vector3);
  8964. /**
  8965. * Clones the PositionNormalVertex
  8966. * @returns the cloned PositionNormalVertex
  8967. */
  8968. clone(): PositionNormalVertex;
  8969. }
  8970. /**
  8971. * Contains position, normal and uv vectors for a vertex
  8972. */
  8973. export class PositionNormalTextureVertex {
  8974. /** the position of the vertex (defaut: 0,0,0) */
  8975. position: Vector3;
  8976. /** the normal of the vertex (defaut: 0,1,0) */
  8977. normal: Vector3;
  8978. /** the uv of the vertex (default: 0,0) */
  8979. uv: Vector2;
  8980. /**
  8981. * Creates a PositionNormalTextureVertex
  8982. * @param position the position of the vertex (defaut: 0,0,0)
  8983. * @param normal the normal of the vertex (defaut: 0,1,0)
  8984. * @param uv the uv of the vertex (default: 0,0)
  8985. */
  8986. constructor(
  8987. /** the position of the vertex (defaut: 0,0,0) */
  8988. position?: Vector3,
  8989. /** the normal of the vertex (defaut: 0,1,0) */
  8990. normal?: Vector3,
  8991. /** the uv of the vertex (default: 0,0) */
  8992. uv?: Vector2);
  8993. /**
  8994. * Clones the PositionNormalTextureVertex
  8995. * @returns the cloned PositionNormalTextureVertex
  8996. */
  8997. clone(): PositionNormalTextureVertex;
  8998. }
  8999. }
  9000. declare module BABYLON {
  9001. /**
  9002. * Enum defining the type of animations supported by InputBlock
  9003. */
  9004. export enum AnimatedInputBlockTypes {
  9005. /** No animation */
  9006. None = 0,
  9007. /** Time based animation. Will only work for floats */
  9008. Time = 1
  9009. }
  9010. }
  9011. declare module BABYLON {
  9012. /**
  9013. * Interface describing all the common properties and methods a shadow light needs to implement.
  9014. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  9015. * as well as binding the different shadow properties to the effects.
  9016. */
  9017. export interface IShadowLight extends Light {
  9018. /**
  9019. * The light id in the scene (used in scene.findLighById for instance)
  9020. */
  9021. id: string;
  9022. /**
  9023. * The position the shdow will be casted from.
  9024. */
  9025. position: Vector3;
  9026. /**
  9027. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9028. */
  9029. direction: Vector3;
  9030. /**
  9031. * The transformed position. Position of the light in world space taking parenting in account.
  9032. */
  9033. transformedPosition: Vector3;
  9034. /**
  9035. * The transformed direction. Direction of the light in world space taking parenting in account.
  9036. */
  9037. transformedDirection: Vector3;
  9038. /**
  9039. * The friendly name of the light in the scene.
  9040. */
  9041. name: string;
  9042. /**
  9043. * Defines the shadow projection clipping minimum z value.
  9044. */
  9045. shadowMinZ: number;
  9046. /**
  9047. * Defines the shadow projection clipping maximum z value.
  9048. */
  9049. shadowMaxZ: number;
  9050. /**
  9051. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9052. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9053. */
  9054. computeTransformedInformation(): boolean;
  9055. /**
  9056. * Gets the scene the light belongs to.
  9057. * @returns The scene
  9058. */
  9059. getScene(): Scene;
  9060. /**
  9061. * Callback defining a custom Projection Matrix Builder.
  9062. * This can be used to override the default projection matrix computation.
  9063. */
  9064. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9065. /**
  9066. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9067. * @param matrix The materix to updated with the projection information
  9068. * @param viewMatrix The transform matrix of the light
  9069. * @param renderList The list of mesh to render in the map
  9070. * @returns The current light
  9071. */
  9072. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9073. /**
  9074. * Gets the current depth scale used in ESM.
  9075. * @returns The scale
  9076. */
  9077. getDepthScale(): number;
  9078. /**
  9079. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9080. * @returns true if a cube texture needs to be use
  9081. */
  9082. needCube(): boolean;
  9083. /**
  9084. * Detects if the projection matrix requires to be recomputed this frame.
  9085. * @returns true if it requires to be recomputed otherwise, false.
  9086. */
  9087. needProjectionMatrixCompute(): boolean;
  9088. /**
  9089. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9090. */
  9091. forceProjectionMatrixCompute(): void;
  9092. /**
  9093. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9094. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9095. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9096. */
  9097. getShadowDirection(faceIndex?: number): Vector3;
  9098. /**
  9099. * Gets the minZ used for shadow according to both the scene and the light.
  9100. * @param activeCamera The camera we are returning the min for
  9101. * @returns the depth min z
  9102. */
  9103. getDepthMinZ(activeCamera: Camera): number;
  9104. /**
  9105. * Gets the maxZ used for shadow according to both the scene and the light.
  9106. * @param activeCamera The camera we are returning the max for
  9107. * @returns the depth max z
  9108. */
  9109. getDepthMaxZ(activeCamera: Camera): number;
  9110. }
  9111. /**
  9112. * Base implementation IShadowLight
  9113. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9114. */
  9115. export abstract class ShadowLight extends Light implements IShadowLight {
  9116. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9117. protected _position: Vector3;
  9118. protected _setPosition(value: Vector3): void;
  9119. /**
  9120. * Sets the position the shadow will be casted from. Also use as the light position for both
  9121. * point and spot lights.
  9122. */
  9123. get position(): Vector3;
  9124. /**
  9125. * Sets the position the shadow will be casted from. Also use as the light position for both
  9126. * point and spot lights.
  9127. */
  9128. set position(value: Vector3);
  9129. protected _direction: Vector3;
  9130. protected _setDirection(value: Vector3): void;
  9131. /**
  9132. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9133. * Also use as the light direction on spot and directional lights.
  9134. */
  9135. get direction(): Vector3;
  9136. /**
  9137. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9138. * Also use as the light direction on spot and directional lights.
  9139. */
  9140. set direction(value: Vector3);
  9141. protected _shadowMinZ: number;
  9142. /**
  9143. * Gets the shadow projection clipping minimum z value.
  9144. */
  9145. get shadowMinZ(): number;
  9146. /**
  9147. * Sets the shadow projection clipping minimum z value.
  9148. */
  9149. set shadowMinZ(value: number);
  9150. protected _shadowMaxZ: number;
  9151. /**
  9152. * Sets the shadow projection clipping maximum z value.
  9153. */
  9154. get shadowMaxZ(): number;
  9155. /**
  9156. * Gets the shadow projection clipping maximum z value.
  9157. */
  9158. set shadowMaxZ(value: number);
  9159. /**
  9160. * Callback defining a custom Projection Matrix Builder.
  9161. * This can be used to override the default projection matrix computation.
  9162. */
  9163. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9164. /**
  9165. * The transformed position. Position of the light in world space taking parenting in account.
  9166. */
  9167. transformedPosition: Vector3;
  9168. /**
  9169. * The transformed direction. Direction of the light in world space taking parenting in account.
  9170. */
  9171. transformedDirection: Vector3;
  9172. private _needProjectionMatrixCompute;
  9173. /**
  9174. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9175. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9176. */
  9177. computeTransformedInformation(): boolean;
  9178. /**
  9179. * Return the depth scale used for the shadow map.
  9180. * @returns the depth scale.
  9181. */
  9182. getDepthScale(): number;
  9183. /**
  9184. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9185. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9186. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9187. */
  9188. getShadowDirection(faceIndex?: number): Vector3;
  9189. /**
  9190. * Returns the ShadowLight absolute position in the World.
  9191. * @returns the position vector in world space
  9192. */
  9193. getAbsolutePosition(): Vector3;
  9194. /**
  9195. * Sets the ShadowLight direction toward the passed target.
  9196. * @param target The point to target in local space
  9197. * @returns the updated ShadowLight direction
  9198. */
  9199. setDirectionToTarget(target: Vector3): Vector3;
  9200. /**
  9201. * Returns the light rotation in euler definition.
  9202. * @returns the x y z rotation in local space.
  9203. */
  9204. getRotation(): Vector3;
  9205. /**
  9206. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9207. * @returns true if a cube texture needs to be use
  9208. */
  9209. needCube(): boolean;
  9210. /**
  9211. * Detects if the projection matrix requires to be recomputed this frame.
  9212. * @returns true if it requires to be recomputed otherwise, false.
  9213. */
  9214. needProjectionMatrixCompute(): boolean;
  9215. /**
  9216. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9217. */
  9218. forceProjectionMatrixCompute(): void;
  9219. /** @hidden */
  9220. _initCache(): void;
  9221. /** @hidden */
  9222. _isSynchronized(): boolean;
  9223. /**
  9224. * Computes the world matrix of the node
  9225. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9226. * @returns the world matrix
  9227. */
  9228. computeWorldMatrix(force?: boolean): Matrix;
  9229. /**
  9230. * Gets the minZ used for shadow according to both the scene and the light.
  9231. * @param activeCamera The camera we are returning the min for
  9232. * @returns the depth min z
  9233. */
  9234. getDepthMinZ(activeCamera: Camera): number;
  9235. /**
  9236. * Gets the maxZ used for shadow according to both the scene and the light.
  9237. * @param activeCamera The camera we are returning the max for
  9238. * @returns the depth max z
  9239. */
  9240. getDepthMaxZ(activeCamera: Camera): number;
  9241. /**
  9242. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9243. * @param matrix The materix to updated with the projection information
  9244. * @param viewMatrix The transform matrix of the light
  9245. * @param renderList The list of mesh to render in the map
  9246. * @returns The current light
  9247. */
  9248. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9249. }
  9250. }
  9251. declare module BABYLON {
  9252. /** @hidden */
  9253. export var packingFunctions: {
  9254. name: string;
  9255. shader: string;
  9256. };
  9257. }
  9258. declare module BABYLON {
  9259. /** @hidden */
  9260. export var bayerDitherFunctions: {
  9261. name: string;
  9262. shader: string;
  9263. };
  9264. }
  9265. declare module BABYLON {
  9266. /** @hidden */
  9267. export var shadowMapFragmentDeclaration: {
  9268. name: string;
  9269. shader: string;
  9270. };
  9271. }
  9272. declare module BABYLON {
  9273. /** @hidden */
  9274. export var clipPlaneFragmentDeclaration: {
  9275. name: string;
  9276. shader: string;
  9277. };
  9278. }
  9279. declare module BABYLON {
  9280. /** @hidden */
  9281. export var clipPlaneFragment: {
  9282. name: string;
  9283. shader: string;
  9284. };
  9285. }
  9286. declare module BABYLON {
  9287. /** @hidden */
  9288. export var shadowMapFragment: {
  9289. name: string;
  9290. shader: string;
  9291. };
  9292. }
  9293. declare module BABYLON {
  9294. /** @hidden */
  9295. export var shadowMapPixelShader: {
  9296. name: string;
  9297. shader: string;
  9298. };
  9299. }
  9300. declare module BABYLON {
  9301. /** @hidden */
  9302. export var bonesDeclaration: {
  9303. name: string;
  9304. shader: string;
  9305. };
  9306. }
  9307. declare module BABYLON {
  9308. /** @hidden */
  9309. export var morphTargetsVertexGlobalDeclaration: {
  9310. name: string;
  9311. shader: string;
  9312. };
  9313. }
  9314. declare module BABYLON {
  9315. /** @hidden */
  9316. export var morphTargetsVertexDeclaration: {
  9317. name: string;
  9318. shader: string;
  9319. };
  9320. }
  9321. declare module BABYLON {
  9322. /** @hidden */
  9323. export var instancesDeclaration: {
  9324. name: string;
  9325. shader: string;
  9326. };
  9327. }
  9328. declare module BABYLON {
  9329. /** @hidden */
  9330. export var helperFunctions: {
  9331. name: string;
  9332. shader: string;
  9333. };
  9334. }
  9335. declare module BABYLON {
  9336. /** @hidden */
  9337. export var shadowMapVertexDeclaration: {
  9338. name: string;
  9339. shader: string;
  9340. };
  9341. }
  9342. declare module BABYLON {
  9343. /** @hidden */
  9344. export var clipPlaneVertexDeclaration: {
  9345. name: string;
  9346. shader: string;
  9347. };
  9348. }
  9349. declare module BABYLON {
  9350. /** @hidden */
  9351. export var morphTargetsVertex: {
  9352. name: string;
  9353. shader: string;
  9354. };
  9355. }
  9356. declare module BABYLON {
  9357. /** @hidden */
  9358. export var instancesVertex: {
  9359. name: string;
  9360. shader: string;
  9361. };
  9362. }
  9363. declare module BABYLON {
  9364. /** @hidden */
  9365. export var bonesVertex: {
  9366. name: string;
  9367. shader: string;
  9368. };
  9369. }
  9370. declare module BABYLON {
  9371. /** @hidden */
  9372. export var shadowMapVertexNormalBias: {
  9373. name: string;
  9374. shader: string;
  9375. };
  9376. }
  9377. declare module BABYLON {
  9378. /** @hidden */
  9379. export var shadowMapVertexMetric: {
  9380. name: string;
  9381. shader: string;
  9382. };
  9383. }
  9384. declare module BABYLON {
  9385. /** @hidden */
  9386. export var clipPlaneVertex: {
  9387. name: string;
  9388. shader: string;
  9389. };
  9390. }
  9391. declare module BABYLON {
  9392. /** @hidden */
  9393. export var shadowMapVertexShader: {
  9394. name: string;
  9395. shader: string;
  9396. };
  9397. }
  9398. declare module BABYLON {
  9399. /** @hidden */
  9400. export var depthBoxBlurPixelShader: {
  9401. name: string;
  9402. shader: string;
  9403. };
  9404. }
  9405. declare module BABYLON {
  9406. /** @hidden */
  9407. export var shadowMapFragmentSoftTransparentShadow: {
  9408. name: string;
  9409. shader: string;
  9410. };
  9411. }
  9412. declare module BABYLON {
  9413. /**
  9414. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9415. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9416. */
  9417. export class EffectFallbacks implements IEffectFallbacks {
  9418. private _defines;
  9419. private _currentRank;
  9420. private _maxRank;
  9421. private _mesh;
  9422. /**
  9423. * Removes the fallback from the bound mesh.
  9424. */
  9425. unBindMesh(): void;
  9426. /**
  9427. * Adds a fallback on the specified property.
  9428. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9429. * @param define The name of the define in the shader
  9430. */
  9431. addFallback(rank: number, define: string): void;
  9432. /**
  9433. * Sets the mesh to use CPU skinning when needing to fallback.
  9434. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9435. * @param mesh The mesh to use the fallbacks.
  9436. */
  9437. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9438. /**
  9439. * Checks to see if more fallbacks are still availible.
  9440. */
  9441. get hasMoreFallbacks(): boolean;
  9442. /**
  9443. * Removes the defines that should be removed when falling back.
  9444. * @param currentDefines defines the current define statements for the shader.
  9445. * @param effect defines the current effect we try to compile
  9446. * @returns The resulting defines with defines of the current rank removed.
  9447. */
  9448. reduce(currentDefines: string, effect: Effect): string;
  9449. }
  9450. }
  9451. declare module BABYLON {
  9452. /**
  9453. * Interface used to define Action
  9454. */
  9455. export interface IAction {
  9456. /**
  9457. * Trigger for the action
  9458. */
  9459. trigger: number;
  9460. /** Options of the trigger */
  9461. triggerOptions: any;
  9462. /**
  9463. * Gets the trigger parameters
  9464. * @returns the trigger parameters
  9465. */
  9466. getTriggerParameter(): any;
  9467. /**
  9468. * Internal only - executes current action event
  9469. * @hidden
  9470. */
  9471. _executeCurrent(evt?: ActionEvent): void;
  9472. /**
  9473. * Serialize placeholder for child classes
  9474. * @param parent of child
  9475. * @returns the serialized object
  9476. */
  9477. serialize(parent: any): any;
  9478. /**
  9479. * Internal only
  9480. * @hidden
  9481. */
  9482. _prepare(): void;
  9483. /**
  9484. * Internal only - manager for action
  9485. * @hidden
  9486. */
  9487. _actionManager: Nullable<AbstractActionManager>;
  9488. /**
  9489. * Adds action to chain of actions, may be a DoNothingAction
  9490. * @param action defines the next action to execute
  9491. * @returns The action passed in
  9492. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9493. */
  9494. then(action: IAction): IAction;
  9495. }
  9496. /**
  9497. * The action to be carried out following a trigger
  9498. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9499. */
  9500. export class Action implements IAction {
  9501. /** the trigger, with or without parameters, for the action */
  9502. triggerOptions: any;
  9503. /**
  9504. * Trigger for the action
  9505. */
  9506. trigger: number;
  9507. /**
  9508. * Internal only - manager for action
  9509. * @hidden
  9510. */
  9511. _actionManager: ActionManager;
  9512. private _nextActiveAction;
  9513. private _child;
  9514. private _condition?;
  9515. private _triggerParameter;
  9516. /**
  9517. * An event triggered prior to action being executed.
  9518. */
  9519. onBeforeExecuteObservable: Observable<Action>;
  9520. /**
  9521. * Creates a new Action
  9522. * @param triggerOptions the trigger, with or without parameters, for the action
  9523. * @param condition an optional determinant of action
  9524. */
  9525. constructor(
  9526. /** the trigger, with or without parameters, for the action */
  9527. triggerOptions: any, condition?: Condition);
  9528. /**
  9529. * Internal only
  9530. * @hidden
  9531. */
  9532. _prepare(): void;
  9533. /**
  9534. * Gets the trigger parameters
  9535. * @returns the trigger parameters
  9536. */
  9537. getTriggerParameter(): any;
  9538. /**
  9539. * Internal only - executes current action event
  9540. * @hidden
  9541. */
  9542. _executeCurrent(evt?: ActionEvent): void;
  9543. /**
  9544. * Execute placeholder for child classes
  9545. * @param evt optional action event
  9546. */
  9547. execute(evt?: ActionEvent): void;
  9548. /**
  9549. * Skips to next active action
  9550. */
  9551. skipToNextActiveAction(): void;
  9552. /**
  9553. * Adds action to chain of actions, may be a DoNothingAction
  9554. * @param action defines the next action to execute
  9555. * @returns The action passed in
  9556. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9557. */
  9558. then(action: Action): Action;
  9559. /**
  9560. * Internal only
  9561. * @hidden
  9562. */
  9563. _getProperty(propertyPath: string): string;
  9564. /**
  9565. * Internal only
  9566. * @hidden
  9567. */
  9568. _getEffectiveTarget(target: any, propertyPath: string): any;
  9569. /**
  9570. * Serialize placeholder for child classes
  9571. * @param parent of child
  9572. * @returns the serialized object
  9573. */
  9574. serialize(parent: any): any;
  9575. /**
  9576. * Internal only called by serialize
  9577. * @hidden
  9578. */
  9579. protected _serialize(serializedAction: any, parent?: any): any;
  9580. /**
  9581. * Internal only
  9582. * @hidden
  9583. */
  9584. static _SerializeValueAsString: (value: any) => string;
  9585. /**
  9586. * Internal only
  9587. * @hidden
  9588. */
  9589. static _GetTargetProperty: (target: Scene | Node) => {
  9590. name: string;
  9591. targetType: string;
  9592. value: string;
  9593. };
  9594. }
  9595. }
  9596. declare module BABYLON {
  9597. /**
  9598. * A Condition applied to an Action
  9599. */
  9600. export class Condition {
  9601. /**
  9602. * Internal only - manager for action
  9603. * @hidden
  9604. */
  9605. _actionManager: ActionManager;
  9606. /**
  9607. * Internal only
  9608. * @hidden
  9609. */
  9610. _evaluationId: number;
  9611. /**
  9612. * Internal only
  9613. * @hidden
  9614. */
  9615. _currentResult: boolean;
  9616. /**
  9617. * Creates a new Condition
  9618. * @param actionManager the manager of the action the condition is applied to
  9619. */
  9620. constructor(actionManager: ActionManager);
  9621. /**
  9622. * Check if the current condition is valid
  9623. * @returns a boolean
  9624. */
  9625. isValid(): boolean;
  9626. /**
  9627. * Internal only
  9628. * @hidden
  9629. */
  9630. _getProperty(propertyPath: string): string;
  9631. /**
  9632. * Internal only
  9633. * @hidden
  9634. */
  9635. _getEffectiveTarget(target: any, propertyPath: string): any;
  9636. /**
  9637. * Serialize placeholder for child classes
  9638. * @returns the serialized object
  9639. */
  9640. serialize(): any;
  9641. /**
  9642. * Internal only
  9643. * @hidden
  9644. */
  9645. protected _serialize(serializedCondition: any): any;
  9646. }
  9647. /**
  9648. * Defines specific conditional operators as extensions of Condition
  9649. */
  9650. export class ValueCondition extends Condition {
  9651. /** path to specify the property of the target the conditional operator uses */
  9652. propertyPath: string;
  9653. /** the value compared by the conditional operator against the current value of the property */
  9654. value: any;
  9655. /** the conditional operator, default ValueCondition.IsEqual */
  9656. operator: number;
  9657. /**
  9658. * Internal only
  9659. * @hidden
  9660. */
  9661. private static _IsEqual;
  9662. /**
  9663. * Internal only
  9664. * @hidden
  9665. */
  9666. private static _IsDifferent;
  9667. /**
  9668. * Internal only
  9669. * @hidden
  9670. */
  9671. private static _IsGreater;
  9672. /**
  9673. * Internal only
  9674. * @hidden
  9675. */
  9676. private static _IsLesser;
  9677. /**
  9678. * returns the number for IsEqual
  9679. */
  9680. static get IsEqual(): number;
  9681. /**
  9682. * Returns the number for IsDifferent
  9683. */
  9684. static get IsDifferent(): number;
  9685. /**
  9686. * Returns the number for IsGreater
  9687. */
  9688. static get IsGreater(): number;
  9689. /**
  9690. * Returns the number for IsLesser
  9691. */
  9692. static get IsLesser(): number;
  9693. /**
  9694. * Internal only The action manager for the condition
  9695. * @hidden
  9696. */
  9697. _actionManager: ActionManager;
  9698. /**
  9699. * Internal only
  9700. * @hidden
  9701. */
  9702. private _target;
  9703. /**
  9704. * Internal only
  9705. * @hidden
  9706. */
  9707. private _effectiveTarget;
  9708. /**
  9709. * Internal only
  9710. * @hidden
  9711. */
  9712. private _property;
  9713. /**
  9714. * Creates a new ValueCondition
  9715. * @param actionManager manager for the action the condition applies to
  9716. * @param target for the action
  9717. * @param propertyPath path to specify the property of the target the conditional operator uses
  9718. * @param value the value compared by the conditional operator against the current value of the property
  9719. * @param operator the conditional operator, default ValueCondition.IsEqual
  9720. */
  9721. constructor(actionManager: ActionManager, target: any,
  9722. /** path to specify the property of the target the conditional operator uses */
  9723. propertyPath: string,
  9724. /** the value compared by the conditional operator against the current value of the property */
  9725. value: any,
  9726. /** the conditional operator, default ValueCondition.IsEqual */
  9727. operator?: number);
  9728. /**
  9729. * Compares the given value with the property value for the specified conditional operator
  9730. * @returns the result of the comparison
  9731. */
  9732. isValid(): boolean;
  9733. /**
  9734. * Serialize the ValueCondition into a JSON compatible object
  9735. * @returns serialization object
  9736. */
  9737. serialize(): any;
  9738. /**
  9739. * Gets the name of the conditional operator for the ValueCondition
  9740. * @param operator the conditional operator
  9741. * @returns the name
  9742. */
  9743. static GetOperatorName(operator: number): string;
  9744. }
  9745. /**
  9746. * Defines a predicate condition as an extension of Condition
  9747. */
  9748. export class PredicateCondition extends Condition {
  9749. /** defines the predicate function used to validate the condition */
  9750. predicate: () => boolean;
  9751. /**
  9752. * Internal only - manager for action
  9753. * @hidden
  9754. */
  9755. _actionManager: ActionManager;
  9756. /**
  9757. * Creates a new PredicateCondition
  9758. * @param actionManager manager for the action the condition applies to
  9759. * @param predicate defines the predicate function used to validate the condition
  9760. */
  9761. constructor(actionManager: ActionManager,
  9762. /** defines the predicate function used to validate the condition */
  9763. predicate: () => boolean);
  9764. /**
  9765. * @returns the validity of the predicate condition
  9766. */
  9767. isValid(): boolean;
  9768. }
  9769. /**
  9770. * Defines a state condition as an extension of Condition
  9771. */
  9772. export class StateCondition extends Condition {
  9773. /** Value to compare with target state */
  9774. value: string;
  9775. /**
  9776. * Internal only - manager for action
  9777. * @hidden
  9778. */
  9779. _actionManager: ActionManager;
  9780. /**
  9781. * Internal only
  9782. * @hidden
  9783. */
  9784. private _target;
  9785. /**
  9786. * Creates a new StateCondition
  9787. * @param actionManager manager for the action the condition applies to
  9788. * @param target of the condition
  9789. * @param value to compare with target state
  9790. */
  9791. constructor(actionManager: ActionManager, target: any,
  9792. /** Value to compare with target state */
  9793. value: string);
  9794. /**
  9795. * Gets a boolean indicating if the current condition is met
  9796. * @returns the validity of the state
  9797. */
  9798. isValid(): boolean;
  9799. /**
  9800. * Serialize the StateCondition into a JSON compatible object
  9801. * @returns serialization object
  9802. */
  9803. serialize(): any;
  9804. }
  9805. }
  9806. declare module BABYLON {
  9807. /**
  9808. * This defines an action responsible to toggle a boolean once triggered.
  9809. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9810. */
  9811. export class SwitchBooleanAction extends Action {
  9812. /**
  9813. * The path to the boolean property in the target object
  9814. */
  9815. propertyPath: string;
  9816. private _target;
  9817. private _effectiveTarget;
  9818. private _property;
  9819. /**
  9820. * Instantiate the action
  9821. * @param triggerOptions defines the trigger options
  9822. * @param target defines the object containing the boolean
  9823. * @param propertyPath defines the path to the boolean property in the target object
  9824. * @param condition defines the trigger related conditions
  9825. */
  9826. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  9827. /** @hidden */
  9828. _prepare(): void;
  9829. /**
  9830. * Execute the action toggle the boolean value.
  9831. */
  9832. execute(): void;
  9833. /**
  9834. * Serializes the actions and its related information.
  9835. * @param parent defines the object to serialize in
  9836. * @returns the serialized object
  9837. */
  9838. serialize(parent: any): any;
  9839. }
  9840. /**
  9841. * This defines an action responsible to set a the state field of the target
  9842. * to a desired value once triggered.
  9843. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9844. */
  9845. export class SetStateAction extends Action {
  9846. /**
  9847. * The value to store in the state field.
  9848. */
  9849. value: string;
  9850. private _target;
  9851. /**
  9852. * Instantiate the action
  9853. * @param triggerOptions defines the trigger options
  9854. * @param target defines the object containing the state property
  9855. * @param value defines the value to store in the state field
  9856. * @param condition defines the trigger related conditions
  9857. */
  9858. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  9859. /**
  9860. * Execute the action and store the value on the target state property.
  9861. */
  9862. execute(): void;
  9863. /**
  9864. * Serializes the actions and its related information.
  9865. * @param parent defines the object to serialize in
  9866. * @returns the serialized object
  9867. */
  9868. serialize(parent: any): any;
  9869. }
  9870. /**
  9871. * This defines an action responsible to set a property of the target
  9872. * to a desired value once triggered.
  9873. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9874. */
  9875. export class SetValueAction extends Action {
  9876. /**
  9877. * The path of the property to set in the target.
  9878. */
  9879. propertyPath: string;
  9880. /**
  9881. * The value to set in the property
  9882. */
  9883. value: any;
  9884. private _target;
  9885. private _effectiveTarget;
  9886. private _property;
  9887. /**
  9888. * Instantiate the action
  9889. * @param triggerOptions defines the trigger options
  9890. * @param target defines the object containing the property
  9891. * @param propertyPath defines the path of the property to set in the target
  9892. * @param value defines the value to set in the property
  9893. * @param condition defines the trigger related conditions
  9894. */
  9895. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9896. /** @hidden */
  9897. _prepare(): void;
  9898. /**
  9899. * Execute the action and set the targetted property to the desired value.
  9900. */
  9901. execute(): void;
  9902. /**
  9903. * Serializes the actions and its related information.
  9904. * @param parent defines the object to serialize in
  9905. * @returns the serialized object
  9906. */
  9907. serialize(parent: any): any;
  9908. }
  9909. /**
  9910. * This defines an action responsible to increment the target value
  9911. * to a desired value once triggered.
  9912. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9913. */
  9914. export class IncrementValueAction extends Action {
  9915. /**
  9916. * The path of the property to increment in the target.
  9917. */
  9918. propertyPath: string;
  9919. /**
  9920. * The value we should increment the property by.
  9921. */
  9922. value: any;
  9923. private _target;
  9924. private _effectiveTarget;
  9925. private _property;
  9926. /**
  9927. * Instantiate the action
  9928. * @param triggerOptions defines the trigger options
  9929. * @param target defines the object containing the property
  9930. * @param propertyPath defines the path of the property to increment in the target
  9931. * @param value defines the value value we should increment the property by
  9932. * @param condition defines the trigger related conditions
  9933. */
  9934. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  9935. /** @hidden */
  9936. _prepare(): void;
  9937. /**
  9938. * Execute the action and increment the target of the value amount.
  9939. */
  9940. execute(): void;
  9941. /**
  9942. * Serializes the actions and its related information.
  9943. * @param parent defines the object to serialize in
  9944. * @returns the serialized object
  9945. */
  9946. serialize(parent: any): any;
  9947. }
  9948. /**
  9949. * This defines an action responsible to start an animation once triggered.
  9950. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9951. */
  9952. export class PlayAnimationAction extends Action {
  9953. /**
  9954. * Where the animation should start (animation frame)
  9955. */
  9956. from: number;
  9957. /**
  9958. * Where the animation should stop (animation frame)
  9959. */
  9960. to: number;
  9961. /**
  9962. * Define if the animation should loop or stop after the first play.
  9963. */
  9964. loop?: boolean;
  9965. private _target;
  9966. /**
  9967. * Instantiate the action
  9968. * @param triggerOptions defines the trigger options
  9969. * @param target defines the target animation or animation name
  9970. * @param from defines from where the animation should start (animation frame)
  9971. * @param end defines where the animation should stop (animation frame)
  9972. * @param loop defines if the animation should loop or stop after the first play
  9973. * @param condition defines the trigger related conditions
  9974. */
  9975. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  9976. /** @hidden */
  9977. _prepare(): void;
  9978. /**
  9979. * Execute the action and play the animation.
  9980. */
  9981. execute(): void;
  9982. /**
  9983. * Serializes the actions and its related information.
  9984. * @param parent defines the object to serialize in
  9985. * @returns the serialized object
  9986. */
  9987. serialize(parent: any): any;
  9988. }
  9989. /**
  9990. * This defines an action responsible to stop an animation once triggered.
  9991. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9992. */
  9993. export class StopAnimationAction extends Action {
  9994. private _target;
  9995. /**
  9996. * Instantiate the action
  9997. * @param triggerOptions defines the trigger options
  9998. * @param target defines the target animation or animation name
  9999. * @param condition defines the trigger related conditions
  10000. */
  10001. constructor(triggerOptions: any, target: any, condition?: Condition);
  10002. /** @hidden */
  10003. _prepare(): void;
  10004. /**
  10005. * Execute the action and stop the animation.
  10006. */
  10007. execute(): void;
  10008. /**
  10009. * Serializes the actions and its related information.
  10010. * @param parent defines the object to serialize in
  10011. * @returns the serialized object
  10012. */
  10013. serialize(parent: any): any;
  10014. }
  10015. /**
  10016. * This defines an action responsible that does nothing once triggered.
  10017. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10018. */
  10019. export class DoNothingAction extends Action {
  10020. /**
  10021. * Instantiate the action
  10022. * @param triggerOptions defines the trigger options
  10023. * @param condition defines the trigger related conditions
  10024. */
  10025. constructor(triggerOptions?: any, condition?: Condition);
  10026. /**
  10027. * Execute the action and do nothing.
  10028. */
  10029. execute(): void;
  10030. /**
  10031. * Serializes the actions and its related information.
  10032. * @param parent defines the object to serialize in
  10033. * @returns the serialized object
  10034. */
  10035. serialize(parent: any): any;
  10036. }
  10037. /**
  10038. * This defines an action responsible to trigger several actions once triggered.
  10039. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10040. */
  10041. export class CombineAction extends Action {
  10042. /**
  10043. * The list of aggregated animations to run.
  10044. */
  10045. children: Action[];
  10046. /**
  10047. * Instantiate the action
  10048. * @param triggerOptions defines the trigger options
  10049. * @param children defines the list of aggregated animations to run
  10050. * @param condition defines the trigger related conditions
  10051. */
  10052. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10053. /** @hidden */
  10054. _prepare(): void;
  10055. /**
  10056. * Execute the action and executes all the aggregated actions.
  10057. */
  10058. execute(evt: ActionEvent): void;
  10059. /**
  10060. * Serializes the actions and its related information.
  10061. * @param parent defines the object to serialize in
  10062. * @returns the serialized object
  10063. */
  10064. serialize(parent: any): any;
  10065. }
  10066. /**
  10067. * This defines an action responsible to run code (external event) once triggered.
  10068. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10069. */
  10070. export class ExecuteCodeAction extends Action {
  10071. /**
  10072. * The callback function to run.
  10073. */
  10074. func: (evt: ActionEvent) => void;
  10075. /**
  10076. * Instantiate the action
  10077. * @param triggerOptions defines the trigger options
  10078. * @param func defines the callback function to run
  10079. * @param condition defines the trigger related conditions
  10080. */
  10081. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10082. /**
  10083. * Execute the action and run the attached code.
  10084. */
  10085. execute(evt: ActionEvent): void;
  10086. }
  10087. /**
  10088. * This defines an action responsible to set the parent property of the target once triggered.
  10089. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10090. */
  10091. export class SetParentAction extends Action {
  10092. private _parent;
  10093. private _target;
  10094. /**
  10095. * Instantiate the action
  10096. * @param triggerOptions defines the trigger options
  10097. * @param target defines the target containing the parent property
  10098. * @param parent defines from where the animation should start (animation frame)
  10099. * @param condition defines the trigger related conditions
  10100. */
  10101. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10102. /** @hidden */
  10103. _prepare(): void;
  10104. /**
  10105. * Execute the action and set the parent property.
  10106. */
  10107. execute(): void;
  10108. /**
  10109. * Serializes the actions and its related information.
  10110. * @param parent defines the object to serialize in
  10111. * @returns the serialized object
  10112. */
  10113. serialize(parent: any): any;
  10114. }
  10115. }
  10116. declare module BABYLON {
  10117. /**
  10118. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10119. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10120. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10121. */
  10122. export class ActionManager extends AbstractActionManager {
  10123. /**
  10124. * Nothing
  10125. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10126. */
  10127. static readonly NothingTrigger: number;
  10128. /**
  10129. * On pick
  10130. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10131. */
  10132. static readonly OnPickTrigger: number;
  10133. /**
  10134. * On left pick
  10135. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10136. */
  10137. static readonly OnLeftPickTrigger: number;
  10138. /**
  10139. * On right pick
  10140. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10141. */
  10142. static readonly OnRightPickTrigger: number;
  10143. /**
  10144. * On center pick
  10145. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10146. */
  10147. static readonly OnCenterPickTrigger: number;
  10148. /**
  10149. * On pick down
  10150. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10151. */
  10152. static readonly OnPickDownTrigger: number;
  10153. /**
  10154. * On double pick
  10155. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10156. */
  10157. static readonly OnDoublePickTrigger: number;
  10158. /**
  10159. * On pick up
  10160. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10161. */
  10162. static readonly OnPickUpTrigger: number;
  10163. /**
  10164. * On pick out.
  10165. * This trigger will only be raised if you also declared a OnPickDown
  10166. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10167. */
  10168. static readonly OnPickOutTrigger: number;
  10169. /**
  10170. * On long press
  10171. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10172. */
  10173. static readonly OnLongPressTrigger: number;
  10174. /**
  10175. * On pointer over
  10176. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10177. */
  10178. static readonly OnPointerOverTrigger: number;
  10179. /**
  10180. * On pointer out
  10181. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10182. */
  10183. static readonly OnPointerOutTrigger: number;
  10184. /**
  10185. * On every frame
  10186. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10187. */
  10188. static readonly OnEveryFrameTrigger: number;
  10189. /**
  10190. * On intersection enter
  10191. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10192. */
  10193. static readonly OnIntersectionEnterTrigger: number;
  10194. /**
  10195. * On intersection exit
  10196. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10197. */
  10198. static readonly OnIntersectionExitTrigger: number;
  10199. /**
  10200. * On key down
  10201. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10202. */
  10203. static readonly OnKeyDownTrigger: number;
  10204. /**
  10205. * On key up
  10206. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10207. */
  10208. static readonly OnKeyUpTrigger: number;
  10209. private _scene;
  10210. /**
  10211. * Creates a new action manager
  10212. * @param scene defines the hosting scene
  10213. */
  10214. constructor(scene: Scene);
  10215. /**
  10216. * Releases all associated resources
  10217. */
  10218. dispose(): void;
  10219. /**
  10220. * Gets hosting scene
  10221. * @returns the hosting scene
  10222. */
  10223. getScene(): Scene;
  10224. /**
  10225. * Does this action manager handles actions of any of the given triggers
  10226. * @param triggers defines the triggers to be tested
  10227. * @return a boolean indicating whether one (or more) of the triggers is handled
  10228. */
  10229. hasSpecificTriggers(triggers: number[]): boolean;
  10230. /**
  10231. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10232. * speed.
  10233. * @param triggerA defines the trigger to be tested
  10234. * @param triggerB defines the trigger to be tested
  10235. * @return a boolean indicating whether one (or more) of the triggers is handled
  10236. */
  10237. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10238. /**
  10239. * Does this action manager handles actions of a given trigger
  10240. * @param trigger defines the trigger to be tested
  10241. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10242. * @return whether the trigger is handled
  10243. */
  10244. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10245. /**
  10246. * Does this action manager has pointer triggers
  10247. */
  10248. get hasPointerTriggers(): boolean;
  10249. /**
  10250. * Does this action manager has pick triggers
  10251. */
  10252. get hasPickTriggers(): boolean;
  10253. /**
  10254. * Registers an action to this action manager
  10255. * @param action defines the action to be registered
  10256. * @return the action amended (prepared) after registration
  10257. */
  10258. registerAction(action: IAction): Nullable<IAction>;
  10259. /**
  10260. * Unregisters an action to this action manager
  10261. * @param action defines the action to be unregistered
  10262. * @return a boolean indicating whether the action has been unregistered
  10263. */
  10264. unregisterAction(action: IAction): Boolean;
  10265. /**
  10266. * Process a specific trigger
  10267. * @param trigger defines the trigger to process
  10268. * @param evt defines the event details to be processed
  10269. */
  10270. processTrigger(trigger: number, evt?: IActionEvent): void;
  10271. /** @hidden */
  10272. _getEffectiveTarget(target: any, propertyPath: string): any;
  10273. /** @hidden */
  10274. _getProperty(propertyPath: string): string;
  10275. /**
  10276. * Serialize this manager to a JSON object
  10277. * @param name defines the property name to store this manager
  10278. * @returns a JSON representation of this manager
  10279. */
  10280. serialize(name: string): any;
  10281. /**
  10282. * Creates a new ActionManager from a JSON data
  10283. * @param parsedActions defines the JSON data to read from
  10284. * @param object defines the hosting mesh
  10285. * @param scene defines the hosting scene
  10286. */
  10287. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10288. /**
  10289. * Get a trigger name by index
  10290. * @param trigger defines the trigger index
  10291. * @returns a trigger name
  10292. */
  10293. static GetTriggerName(trigger: number): string;
  10294. }
  10295. }
  10296. declare module BABYLON {
  10297. /**
  10298. * Class used to represent a sprite
  10299. * @see https://doc.babylonjs.com/babylon101/sprites
  10300. */
  10301. export class Sprite implements IAnimatable {
  10302. /** defines the name */
  10303. name: string;
  10304. /** Gets or sets the current world position */
  10305. position: Vector3;
  10306. /** Gets or sets the main color */
  10307. color: Color4;
  10308. /** Gets or sets the width */
  10309. width: number;
  10310. /** Gets or sets the height */
  10311. height: number;
  10312. /** Gets or sets rotation angle */
  10313. angle: number;
  10314. /** Gets or sets the cell index in the sprite sheet */
  10315. cellIndex: number;
  10316. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  10317. cellRef: string;
  10318. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  10319. invertU: boolean;
  10320. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  10321. invertV: boolean;
  10322. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  10323. disposeWhenFinishedAnimating: boolean;
  10324. /** Gets the list of attached animations */
  10325. animations: Nullable<Array<Animation>>;
  10326. /** Gets or sets a boolean indicating if the sprite can be picked */
  10327. isPickable: boolean;
  10328. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  10329. useAlphaForPicking: boolean;
  10330. /** @hidden */
  10331. _xOffset: number;
  10332. /** @hidden */
  10333. _yOffset: number;
  10334. /** @hidden */
  10335. _xSize: number;
  10336. /** @hidden */
  10337. _ySize: number;
  10338. /**
  10339. * Gets or sets the associated action manager
  10340. */
  10341. actionManager: Nullable<ActionManager>;
  10342. /**
  10343. * An event triggered when the control has been disposed
  10344. */
  10345. onDisposeObservable: Observable<Sprite>;
  10346. private _animationStarted;
  10347. private _loopAnimation;
  10348. private _fromIndex;
  10349. private _toIndex;
  10350. private _delay;
  10351. private _direction;
  10352. private _manager;
  10353. private _time;
  10354. private _onAnimationEnd;
  10355. /**
  10356. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  10357. */
  10358. isVisible: boolean;
  10359. /**
  10360. * Gets or sets the sprite size
  10361. */
  10362. get size(): number;
  10363. set size(value: number);
  10364. /**
  10365. * Returns a boolean indicating if the animation is started
  10366. */
  10367. get animationStarted(): boolean;
  10368. /**
  10369. * Gets or sets the unique id of the sprite
  10370. */
  10371. uniqueId: number;
  10372. /**
  10373. * Gets the manager of this sprite
  10374. */
  10375. get manager(): ISpriteManager;
  10376. /**
  10377. * Creates a new Sprite
  10378. * @param name defines the name
  10379. * @param manager defines the manager
  10380. */
  10381. constructor(
  10382. /** defines the name */
  10383. name: string, manager: ISpriteManager);
  10384. /**
  10385. * Returns the string "Sprite"
  10386. * @returns "Sprite"
  10387. */
  10388. getClassName(): string;
  10389. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  10390. get fromIndex(): number;
  10391. set fromIndex(value: number);
  10392. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  10393. get toIndex(): number;
  10394. set toIndex(value: number);
  10395. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  10396. get loopAnimation(): boolean;
  10397. set loopAnimation(value: boolean);
  10398. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  10399. get delay(): number;
  10400. set delay(value: number);
  10401. /**
  10402. * Starts an animation
  10403. * @param from defines the initial key
  10404. * @param to defines the end key
  10405. * @param loop defines if the animation must loop
  10406. * @param delay defines the start delay (in ms)
  10407. * @param onAnimationEnd defines a callback to call when animation ends
  10408. */
  10409. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  10410. /** Stops current animation (if any) */
  10411. stopAnimation(): void;
  10412. /** @hidden */
  10413. _animate(deltaTime: number): void;
  10414. /** Release associated resources */
  10415. dispose(): void;
  10416. /**
  10417. * Serializes the sprite to a JSON object
  10418. * @returns the JSON object
  10419. */
  10420. serialize(): any;
  10421. /**
  10422. * Parses a JSON object to create a new sprite
  10423. * @param parsedSprite The JSON object to parse
  10424. * @param manager defines the hosting manager
  10425. * @returns the new sprite
  10426. */
  10427. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  10428. }
  10429. }
  10430. declare module BABYLON {
  10431. /**
  10432. * Information about the result of picking within a scene
  10433. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  10434. */
  10435. export class PickingInfo {
  10436. /** @hidden */
  10437. _pickingUnavailable: boolean;
  10438. /**
  10439. * If the pick collided with an object
  10440. */
  10441. hit: boolean;
  10442. /**
  10443. * Distance away where the pick collided
  10444. */
  10445. distance: number;
  10446. /**
  10447. * The location of pick collision
  10448. */
  10449. pickedPoint: Nullable<Vector3>;
  10450. /**
  10451. * The mesh corresponding the the pick collision
  10452. */
  10453. pickedMesh: Nullable<AbstractMesh>;
  10454. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  10455. bu: number;
  10456. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  10457. bv: number;
  10458. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10459. faceId: number;
  10460. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10461. subMeshFaceId: number;
  10462. /** Id of the the submesh that was picked */
  10463. subMeshId: number;
  10464. /** If a sprite was picked, this will be the sprite the pick collided with */
  10465. pickedSprite: Nullable<Sprite>;
  10466. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  10467. thinInstanceIndex: number;
  10468. /**
  10469. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  10470. */
  10471. originMesh: Nullable<AbstractMesh>;
  10472. /**
  10473. * The ray that was used to perform the picking.
  10474. */
  10475. ray: Nullable<Ray>;
  10476. /**
  10477. * Gets the normal correspodning to the face the pick collided with
  10478. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  10479. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  10480. * @returns The normal correspodning to the face the pick collided with
  10481. */
  10482. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  10483. /**
  10484. * Gets the texture coordinates of where the pick occured
  10485. * @returns the vector containing the coordnates of the texture
  10486. */
  10487. getTextureCoordinates(): Nullable<Vector2>;
  10488. }
  10489. }
  10490. declare module BABYLON {
  10491. /**
  10492. * Class representing a ray with position and direction
  10493. */
  10494. export class Ray {
  10495. /** origin point */
  10496. origin: Vector3;
  10497. /** direction */
  10498. direction: Vector3;
  10499. /** length of the ray */
  10500. length: number;
  10501. private static readonly _TmpVector3;
  10502. private _tmpRay;
  10503. /**
  10504. * Creates a new ray
  10505. * @param origin origin point
  10506. * @param direction direction
  10507. * @param length length of the ray
  10508. */
  10509. constructor(
  10510. /** origin point */
  10511. origin: Vector3,
  10512. /** direction */
  10513. direction: Vector3,
  10514. /** length of the ray */
  10515. length?: number);
  10516. /**
  10517. * Checks if the ray intersects a box
  10518. * This does not account for the ray lenght by design to improve perfs.
  10519. * @param minimum bound of the box
  10520. * @param maximum bound of the box
  10521. * @param intersectionTreshold extra extend to be added to the box in all direction
  10522. * @returns if the box was hit
  10523. */
  10524. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10525. /**
  10526. * Checks if the ray intersects a box
  10527. * This does not account for the ray lenght by design to improve perfs.
  10528. * @param box the bounding box to check
  10529. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10530. * @returns if the box was hit
  10531. */
  10532. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10533. /**
  10534. * If the ray hits a sphere
  10535. * @param sphere the bounding sphere to check
  10536. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10537. * @returns true if it hits the sphere
  10538. */
  10539. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10540. /**
  10541. * If the ray hits a triange
  10542. * @param vertex0 triangle vertex
  10543. * @param vertex1 triangle vertex
  10544. * @param vertex2 triangle vertex
  10545. * @returns intersection information if hit
  10546. */
  10547. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10548. /**
  10549. * Checks if ray intersects a plane
  10550. * @param plane the plane to check
  10551. * @returns the distance away it was hit
  10552. */
  10553. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10554. /**
  10555. * Calculate the intercept of a ray on a given axis
  10556. * @param axis to check 'x' | 'y' | 'z'
  10557. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10558. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10559. */
  10560. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10561. /**
  10562. * Checks if ray intersects a mesh
  10563. * @param mesh the mesh to check
  10564. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10565. * @returns picking info of the intersecton
  10566. */
  10567. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10568. /**
  10569. * Checks if ray intersects a mesh
  10570. * @param meshes the meshes to check
  10571. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10572. * @param results array to store result in
  10573. * @returns Array of picking infos
  10574. */
  10575. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10576. private _comparePickingInfo;
  10577. private static smallnum;
  10578. private static rayl;
  10579. /**
  10580. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10581. * @param sega the first point of the segment to test the intersection against
  10582. * @param segb the second point of the segment to test the intersection against
  10583. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10584. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10585. */
  10586. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10587. /**
  10588. * Update the ray from viewport position
  10589. * @param x position
  10590. * @param y y position
  10591. * @param viewportWidth viewport width
  10592. * @param viewportHeight viewport height
  10593. * @param world world matrix
  10594. * @param view view matrix
  10595. * @param projection projection matrix
  10596. * @returns this ray updated
  10597. */
  10598. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10599. /**
  10600. * Creates a ray with origin and direction of 0,0,0
  10601. * @returns the new ray
  10602. */
  10603. static Zero(): Ray;
  10604. /**
  10605. * Creates a new ray from screen space and viewport
  10606. * @param x position
  10607. * @param y y position
  10608. * @param viewportWidth viewport width
  10609. * @param viewportHeight viewport height
  10610. * @param world world matrix
  10611. * @param view view matrix
  10612. * @param projection projection matrix
  10613. * @returns new ray
  10614. */
  10615. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10616. /**
  10617. * 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
  10618. * transformed to the given world matrix.
  10619. * @param origin The origin point
  10620. * @param end The end point
  10621. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10622. * @returns the new ray
  10623. */
  10624. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  10625. /**
  10626. * Transforms a ray by a matrix
  10627. * @param ray ray to transform
  10628. * @param matrix matrix to apply
  10629. * @returns the resulting new ray
  10630. */
  10631. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10632. /**
  10633. * Transforms a ray by a matrix
  10634. * @param ray ray to transform
  10635. * @param matrix matrix to apply
  10636. * @param result ray to store result in
  10637. */
  10638. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10639. /**
  10640. * Unproject a ray from screen space to object space
  10641. * @param sourceX defines the screen space x coordinate to use
  10642. * @param sourceY defines the screen space y coordinate to use
  10643. * @param viewportWidth defines the current width of the viewport
  10644. * @param viewportHeight defines the current height of the viewport
  10645. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10646. * @param view defines the view matrix to use
  10647. * @param projection defines the projection matrix to use
  10648. */
  10649. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10650. }
  10651. /**
  10652. * Type used to define predicate used to select faces when a mesh intersection is detected
  10653. */
  10654. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10655. interface Scene {
  10656. /** @hidden */
  10657. _tempPickingRay: Nullable<Ray>;
  10658. /** @hidden */
  10659. _cachedRayForTransform: Ray;
  10660. /** @hidden */
  10661. _pickWithRayInverseMatrix: Matrix;
  10662. /** @hidden */
  10663. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10664. /** @hidden */
  10665. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10666. /** @hidden */
  10667. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10668. }
  10669. }
  10670. declare module BABYLON {
  10671. /**
  10672. * Groups all the scene component constants in one place to ease maintenance.
  10673. * @hidden
  10674. */
  10675. export class SceneComponentConstants {
  10676. static readonly NAME_EFFECTLAYER: string;
  10677. static readonly NAME_LAYER: string;
  10678. static readonly NAME_LENSFLARESYSTEM: string;
  10679. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10680. static readonly NAME_PARTICLESYSTEM: string;
  10681. static readonly NAME_GAMEPAD: string;
  10682. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10683. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10684. static readonly NAME_PREPASSRENDERER: string;
  10685. static readonly NAME_DEPTHRENDERER: string;
  10686. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10687. static readonly NAME_SPRITE: string;
  10688. static readonly NAME_SUBSURFACE: string;
  10689. static readonly NAME_OUTLINERENDERER: string;
  10690. static readonly NAME_PROCEDURALTEXTURE: string;
  10691. static readonly NAME_SHADOWGENERATOR: string;
  10692. static readonly NAME_OCTREE: string;
  10693. static readonly NAME_PHYSICSENGINE: string;
  10694. static readonly NAME_AUDIO: string;
  10695. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10696. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10697. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10698. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10699. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10700. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10701. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10702. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  10703. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10704. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10705. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10706. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10707. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10708. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10709. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10710. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10711. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10712. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10713. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10714. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10715. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10716. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  10717. static readonly STEP_AFTERRENDER_AUDIO: number;
  10718. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10719. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10720. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10721. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10722. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10723. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  10724. static readonly STEP_POINTERMOVE_SPRITE: number;
  10725. static readonly STEP_POINTERDOWN_SPRITE: number;
  10726. static readonly STEP_POINTERUP_SPRITE: number;
  10727. }
  10728. /**
  10729. * This represents a scene component.
  10730. *
  10731. * This is used to decouple the dependency the scene is having on the different workloads like
  10732. * layers, post processes...
  10733. */
  10734. export interface ISceneComponent {
  10735. /**
  10736. * The name of the component. Each component must have a unique name.
  10737. */
  10738. name: string;
  10739. /**
  10740. * The scene the component belongs to.
  10741. */
  10742. scene: Scene;
  10743. /**
  10744. * Register the component to one instance of a scene.
  10745. */
  10746. register(): void;
  10747. /**
  10748. * Rebuilds the elements related to this component in case of
  10749. * context lost for instance.
  10750. */
  10751. rebuild(): void;
  10752. /**
  10753. * Disposes the component and the associated ressources.
  10754. */
  10755. dispose(): void;
  10756. }
  10757. /**
  10758. * This represents a SERIALIZABLE scene component.
  10759. *
  10760. * This extends Scene Component to add Serialization methods on top.
  10761. */
  10762. export interface ISceneSerializableComponent extends ISceneComponent {
  10763. /**
  10764. * Adds all the elements from the container to the scene
  10765. * @param container the container holding the elements
  10766. */
  10767. addFromContainer(container: AbstractScene): void;
  10768. /**
  10769. * Removes all the elements in the container from the scene
  10770. * @param container contains the elements to remove
  10771. * @param dispose if the removed element should be disposed (default: false)
  10772. */
  10773. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10774. /**
  10775. * Serializes the component data to the specified json object
  10776. * @param serializationObject The object to serialize to
  10777. */
  10778. serialize(serializationObject: any): void;
  10779. }
  10780. /**
  10781. * Strong typing of a Mesh related stage step action
  10782. */
  10783. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10784. /**
  10785. * Strong typing of a Evaluate Sub Mesh related stage step action
  10786. */
  10787. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10788. /**
  10789. * Strong typing of a Active Mesh related stage step action
  10790. */
  10791. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  10792. /**
  10793. * Strong typing of a Camera related stage step action
  10794. */
  10795. export type CameraStageAction = (camera: Camera) => void;
  10796. /**
  10797. * Strong typing of a Camera Frame buffer related stage step action
  10798. */
  10799. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  10800. /**
  10801. * Strong typing of a Render Target related stage step action
  10802. */
  10803. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  10804. /**
  10805. * Strong typing of a RenderingGroup related stage step action
  10806. */
  10807. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  10808. /**
  10809. * Strong typing of a Mesh Render related stage step action
  10810. */
  10811. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  10812. /**
  10813. * Strong typing of a simple stage step action
  10814. */
  10815. export type SimpleStageAction = () => void;
  10816. /**
  10817. * Strong typing of a render target action.
  10818. */
  10819. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  10820. /**
  10821. * Strong typing of a pointer move action.
  10822. */
  10823. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  10824. /**
  10825. * Strong typing of a pointer up/down action.
  10826. */
  10827. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  10828. /**
  10829. * Representation of a stage in the scene (Basically a list of ordered steps)
  10830. * @hidden
  10831. */
  10832. export class Stage<T extends Function> extends Array<{
  10833. index: number;
  10834. component: ISceneComponent;
  10835. action: T;
  10836. }> {
  10837. /**
  10838. * Hide ctor from the rest of the world.
  10839. * @param items The items to add.
  10840. */
  10841. private constructor();
  10842. /**
  10843. * Creates a new Stage.
  10844. * @returns A new instance of a Stage
  10845. */
  10846. static Create<T extends Function>(): Stage<T>;
  10847. /**
  10848. * Registers a step in an ordered way in the targeted stage.
  10849. * @param index Defines the position to register the step in
  10850. * @param component Defines the component attached to the step
  10851. * @param action Defines the action to launch during the step
  10852. */
  10853. registerStep(index: number, component: ISceneComponent, action: T): void;
  10854. /**
  10855. * Clears all the steps from the stage.
  10856. */
  10857. clear(): void;
  10858. }
  10859. }
  10860. declare module BABYLON {
  10861. interface Scene {
  10862. /** @hidden */
  10863. _pointerOverSprite: Nullable<Sprite>;
  10864. /** @hidden */
  10865. _pickedDownSprite: Nullable<Sprite>;
  10866. /** @hidden */
  10867. _tempSpritePickingRay: Nullable<Ray>;
  10868. /**
  10869. * All of the sprite managers added to this scene
  10870. * @see https://doc.babylonjs.com/babylon101/sprites
  10871. */
  10872. spriteManagers: Array<ISpriteManager>;
  10873. /**
  10874. * An event triggered when sprites rendering is about to start
  10875. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10876. */
  10877. onBeforeSpritesRenderingObservable: Observable<Scene>;
  10878. /**
  10879. * An event triggered when sprites rendering is done
  10880. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  10881. */
  10882. onAfterSpritesRenderingObservable: Observable<Scene>;
  10883. /** @hidden */
  10884. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10885. /** Launch a ray to try to pick a sprite in the scene
  10886. * @param x position on screen
  10887. * @param y position on screen
  10888. * @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
  10889. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10890. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10891. * @returns a PickingInfo
  10892. */
  10893. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10894. /** Use the given ray to pick a sprite in the scene
  10895. * @param ray The ray (in world space) to use to pick meshes
  10896. * @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
  10897. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10898. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10899. * @returns a PickingInfo
  10900. */
  10901. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  10902. /** @hidden */
  10903. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10904. /** Launch a ray to try to pick sprites in the scene
  10905. * @param x position on screen
  10906. * @param y position on screen
  10907. * @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
  10908. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  10909. * @returns a PickingInfo array
  10910. */
  10911. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10912. /** Use the given ray to pick sprites in the scene
  10913. * @param ray The ray (in world space) to use to pick meshes
  10914. * @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
  10915. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  10916. * @returns a PickingInfo array
  10917. */
  10918. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  10919. /**
  10920. * Force the sprite under the pointer
  10921. * @param sprite defines the sprite to use
  10922. */
  10923. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  10924. /**
  10925. * Gets the sprite under the pointer
  10926. * @returns a Sprite or null if no sprite is under the pointer
  10927. */
  10928. getPointerOverSprite(): Nullable<Sprite>;
  10929. }
  10930. /**
  10931. * Defines the sprite scene component responsible to manage sprites
  10932. * in a given scene.
  10933. */
  10934. export class SpriteSceneComponent implements ISceneComponent {
  10935. /**
  10936. * The component name helpfull to identify the component in the list of scene components.
  10937. */
  10938. readonly name: string;
  10939. /**
  10940. * The scene the component belongs to.
  10941. */
  10942. scene: Scene;
  10943. /** @hidden */
  10944. private _spritePredicate;
  10945. /**
  10946. * Creates a new instance of the component for the given scene
  10947. * @param scene Defines the scene to register the component in
  10948. */
  10949. constructor(scene: Scene);
  10950. /**
  10951. * Registers the component in a given scene
  10952. */
  10953. register(): void;
  10954. /**
  10955. * Rebuilds the elements related to this component in case of
  10956. * context lost for instance.
  10957. */
  10958. rebuild(): void;
  10959. /**
  10960. * Disposes the component and the associated ressources.
  10961. */
  10962. dispose(): void;
  10963. private _pickSpriteButKeepRay;
  10964. private _pointerMove;
  10965. private _pointerDown;
  10966. private _pointerUp;
  10967. }
  10968. }
  10969. declare module BABYLON {
  10970. /** @hidden */
  10971. export var fogFragmentDeclaration: {
  10972. name: string;
  10973. shader: string;
  10974. };
  10975. }
  10976. declare module BABYLON {
  10977. /** @hidden */
  10978. export var fogFragment: {
  10979. name: string;
  10980. shader: string;
  10981. };
  10982. }
  10983. declare module BABYLON {
  10984. /** @hidden */
  10985. export var imageProcessingCompatibility: {
  10986. name: string;
  10987. shader: string;
  10988. };
  10989. }
  10990. declare module BABYLON {
  10991. /** @hidden */
  10992. export var spritesPixelShader: {
  10993. name: string;
  10994. shader: string;
  10995. };
  10996. }
  10997. declare module BABYLON {
  10998. /** @hidden */
  10999. export var fogVertexDeclaration: {
  11000. name: string;
  11001. shader: string;
  11002. };
  11003. }
  11004. declare module BABYLON {
  11005. /** @hidden */
  11006. export var spritesVertexShader: {
  11007. name: string;
  11008. shader: string;
  11009. };
  11010. }
  11011. declare module BABYLON {
  11012. /**
  11013. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11014. */
  11015. export interface ISpriteManager extends IDisposable {
  11016. /**
  11017. * Gets manager's name
  11018. */
  11019. name: string;
  11020. /**
  11021. * Restricts the camera to viewing objects with the same layerMask.
  11022. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11023. */
  11024. layerMask: number;
  11025. /**
  11026. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11027. */
  11028. isPickable: boolean;
  11029. /**
  11030. * Gets the hosting scene
  11031. */
  11032. scene: Scene;
  11033. /**
  11034. * Specifies the rendering group id for this mesh (0 by default)
  11035. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11036. */
  11037. renderingGroupId: number;
  11038. /**
  11039. * Defines the list of sprites managed by the manager.
  11040. */
  11041. sprites: Array<Sprite>;
  11042. /**
  11043. * Gets or sets the spritesheet texture
  11044. */
  11045. texture: Texture;
  11046. /** Defines the default width of a cell in the spritesheet */
  11047. cellWidth: number;
  11048. /** Defines the default height of a cell in the spritesheet */
  11049. cellHeight: number;
  11050. /**
  11051. * Tests the intersection of a sprite with a specific ray.
  11052. * @param ray The ray we are sending to test the collision
  11053. * @param camera The camera space we are sending rays in
  11054. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11055. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11056. * @returns picking info or null.
  11057. */
  11058. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11059. /**
  11060. * Intersects the sprites with a ray
  11061. * @param ray defines the ray to intersect with
  11062. * @param camera defines the current active camera
  11063. * @param predicate defines a predicate used to select candidate sprites
  11064. * @returns null if no hit or a PickingInfo array
  11065. */
  11066. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11067. /**
  11068. * Renders the list of sprites on screen.
  11069. */
  11070. render(): void;
  11071. }
  11072. /**
  11073. * Class used to manage multiple sprites on the same spritesheet
  11074. * @see https://doc.babylonjs.com/babylon101/sprites
  11075. */
  11076. export class SpriteManager implements ISpriteManager {
  11077. /** defines the manager's name */
  11078. name: string;
  11079. /** Define the Url to load snippets */
  11080. static SnippetUrl: string;
  11081. /** Snippet ID if the manager was created from the snippet server */
  11082. snippetId: string;
  11083. /** Gets the list of sprites */
  11084. sprites: Sprite[];
  11085. /** Gets or sets the rendering group id (0 by default) */
  11086. renderingGroupId: number;
  11087. /** Gets or sets camera layer mask */
  11088. layerMask: number;
  11089. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11090. fogEnabled: boolean;
  11091. /** Gets or sets a boolean indicating if the sprites are pickable */
  11092. isPickable: boolean;
  11093. /** Defines the default width of a cell in the spritesheet */
  11094. cellWidth: number;
  11095. /** Defines the default height of a cell in the spritesheet */
  11096. cellHeight: number;
  11097. /** Associative array from JSON sprite data file */
  11098. private _cellData;
  11099. /** Array of sprite names from JSON sprite data file */
  11100. private _spriteMap;
  11101. /** True when packed cell data from JSON file is ready*/
  11102. private _packedAndReady;
  11103. private _textureContent;
  11104. private _useInstancing;
  11105. /**
  11106. * An event triggered when the manager is disposed.
  11107. */
  11108. onDisposeObservable: Observable<SpriteManager>;
  11109. private _onDisposeObserver;
  11110. /**
  11111. * Callback called when the manager is disposed
  11112. */
  11113. set onDispose(callback: () => void);
  11114. private _capacity;
  11115. private _fromPacked;
  11116. private _spriteTexture;
  11117. private _epsilon;
  11118. private _scene;
  11119. private _vertexData;
  11120. private _buffer;
  11121. private _vertexBuffers;
  11122. private _spriteBuffer;
  11123. private _indexBuffer;
  11124. private _effectBase;
  11125. private _effectFog;
  11126. private _vertexBufferSize;
  11127. /**
  11128. * Gets or sets the unique id of the sprite
  11129. */
  11130. uniqueId: number;
  11131. /**
  11132. * Gets the array of sprites
  11133. */
  11134. get children(): Sprite[];
  11135. /**
  11136. * Gets the hosting scene
  11137. */
  11138. get scene(): Scene;
  11139. /**
  11140. * Gets the capacity of the manager
  11141. */
  11142. get capacity(): number;
  11143. /**
  11144. * Gets or sets the spritesheet texture
  11145. */
  11146. get texture(): Texture;
  11147. set texture(value: Texture);
  11148. private _blendMode;
  11149. /**
  11150. * Blend mode use to render the particle, it can be any of
  11151. * the static Constants.ALPHA_x properties provided in this class.
  11152. * Default value is Constants.ALPHA_COMBINE
  11153. */
  11154. get blendMode(): number;
  11155. set blendMode(blendMode: number);
  11156. /** Disables writing to the depth buffer when rendering the sprites.
  11157. * It can be handy to disable depth writing when using textures without alpha channel
  11158. * and setting some specific blend modes.
  11159. */
  11160. disableDepthWrite: boolean;
  11161. /**
  11162. * Creates a new sprite manager
  11163. * @param name defines the manager's name
  11164. * @param imgUrl defines the sprite sheet url
  11165. * @param capacity defines the maximum allowed number of sprites
  11166. * @param cellSize defines the size of a sprite cell
  11167. * @param scene defines the hosting scene
  11168. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11169. * @param samplingMode defines the smapling mode to use with spritesheet
  11170. * @param fromPacked set to false; do not alter
  11171. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11172. */
  11173. constructor(
  11174. /** defines the manager's name */
  11175. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11176. /**
  11177. * Returns the string "SpriteManager"
  11178. * @returns "SpriteManager"
  11179. */
  11180. getClassName(): string;
  11181. private _makePacked;
  11182. private _appendSpriteVertex;
  11183. private _checkTextureAlpha;
  11184. /**
  11185. * Intersects the sprites with a ray
  11186. * @param ray defines the ray to intersect with
  11187. * @param camera defines the current active camera
  11188. * @param predicate defines a predicate used to select candidate sprites
  11189. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11190. * @returns null if no hit or a PickingInfo
  11191. */
  11192. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11193. /**
  11194. * Intersects the sprites with a ray
  11195. * @param ray defines the ray to intersect with
  11196. * @param camera defines the current active camera
  11197. * @param predicate defines a predicate used to select candidate sprites
  11198. * @returns null if no hit or a PickingInfo array
  11199. */
  11200. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11201. /**
  11202. * Render all child sprites
  11203. */
  11204. render(): void;
  11205. /**
  11206. * Release associated resources
  11207. */
  11208. dispose(): void;
  11209. /**
  11210. * Serializes the sprite manager to a JSON object
  11211. * @param serializeTexture defines if the texture must be serialized as well
  11212. * @returns the JSON object
  11213. */
  11214. serialize(serializeTexture?: boolean): any;
  11215. /**
  11216. * Parses a JSON object to create a new sprite manager.
  11217. * @param parsedManager The JSON object to parse
  11218. * @param scene The scene to create the sprite managerin
  11219. * @param rootUrl The root url to use to load external dependencies like texture
  11220. * @returns the new sprite manager
  11221. */
  11222. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  11223. /**
  11224. * Creates a sprite manager from a snippet saved in a remote file
  11225. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  11226. * @param url defines the url to load from
  11227. * @param scene defines the hosting scene
  11228. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11229. * @returns a promise that will resolve to the new sprite manager
  11230. */
  11231. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11232. /**
  11233. * Creates a sprite manager from a snippet saved by the sprite editor
  11234. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  11235. * @param scene defines the hosting scene
  11236. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11237. * @returns a promise that will resolve to the new sprite manager
  11238. */
  11239. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11240. }
  11241. }
  11242. declare module BABYLON {
  11243. /** Interface used by value gradients (color, factor, ...) */
  11244. export interface IValueGradient {
  11245. /**
  11246. * Gets or sets the gradient value (between 0 and 1)
  11247. */
  11248. gradient: number;
  11249. }
  11250. /** Class used to store color4 gradient */
  11251. export class ColorGradient implements IValueGradient {
  11252. /**
  11253. * Gets or sets the gradient value (between 0 and 1)
  11254. */
  11255. gradient: number;
  11256. /**
  11257. * Gets or sets first associated color
  11258. */
  11259. color1: Color4;
  11260. /**
  11261. * Gets or sets second associated color
  11262. */
  11263. color2?: Color4 | undefined;
  11264. /**
  11265. * Creates a new color4 gradient
  11266. * @param gradient gets or sets the gradient value (between 0 and 1)
  11267. * @param color1 gets or sets first associated color
  11268. * @param color2 gets or sets first second color
  11269. */
  11270. constructor(
  11271. /**
  11272. * Gets or sets the gradient value (between 0 and 1)
  11273. */
  11274. gradient: number,
  11275. /**
  11276. * Gets or sets first associated color
  11277. */
  11278. color1: Color4,
  11279. /**
  11280. * Gets or sets second associated color
  11281. */
  11282. color2?: Color4 | undefined);
  11283. /**
  11284. * Will get a color picked randomly between color1 and color2.
  11285. * If color2 is undefined then color1 will be used
  11286. * @param result defines the target Color4 to store the result in
  11287. */
  11288. getColorToRef(result: Color4): void;
  11289. }
  11290. /** Class used to store color 3 gradient */
  11291. export class Color3Gradient implements IValueGradient {
  11292. /**
  11293. * Gets or sets the gradient value (between 0 and 1)
  11294. */
  11295. gradient: number;
  11296. /**
  11297. * Gets or sets the associated color
  11298. */
  11299. color: Color3;
  11300. /**
  11301. * Creates a new color3 gradient
  11302. * @param gradient gets or sets the gradient value (between 0 and 1)
  11303. * @param color gets or sets associated color
  11304. */
  11305. constructor(
  11306. /**
  11307. * Gets or sets the gradient value (between 0 and 1)
  11308. */
  11309. gradient: number,
  11310. /**
  11311. * Gets or sets the associated color
  11312. */
  11313. color: Color3);
  11314. }
  11315. /** Class used to store factor gradient */
  11316. export class FactorGradient implements IValueGradient {
  11317. /**
  11318. * Gets or sets the gradient value (between 0 and 1)
  11319. */
  11320. gradient: number;
  11321. /**
  11322. * Gets or sets first associated factor
  11323. */
  11324. factor1: number;
  11325. /**
  11326. * Gets or sets second associated factor
  11327. */
  11328. factor2?: number | undefined;
  11329. /**
  11330. * Creates a new factor gradient
  11331. * @param gradient gets or sets the gradient value (between 0 and 1)
  11332. * @param factor1 gets or sets first associated factor
  11333. * @param factor2 gets or sets second associated factor
  11334. */
  11335. constructor(
  11336. /**
  11337. * Gets or sets the gradient value (between 0 and 1)
  11338. */
  11339. gradient: number,
  11340. /**
  11341. * Gets or sets first associated factor
  11342. */
  11343. factor1: number,
  11344. /**
  11345. * Gets or sets second associated factor
  11346. */
  11347. factor2?: number | undefined);
  11348. /**
  11349. * Will get a number picked randomly between factor1 and factor2.
  11350. * If factor2 is undefined then factor1 will be used
  11351. * @returns the picked number
  11352. */
  11353. getFactor(): number;
  11354. }
  11355. /**
  11356. * Helper used to simplify some generic gradient tasks
  11357. */
  11358. export class GradientHelper {
  11359. /**
  11360. * Gets the current gradient from an array of IValueGradient
  11361. * @param ratio defines the current ratio to get
  11362. * @param gradients defines the array of IValueGradient
  11363. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  11364. */
  11365. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  11366. }
  11367. }
  11368. declare module BABYLON {
  11369. interface ThinEngine {
  11370. /**
  11371. * Creates a raw texture
  11372. * @param data defines the data to store in the texture
  11373. * @param width defines the width of the texture
  11374. * @param height defines the height of the texture
  11375. * @param format defines the format of the data
  11376. * @param generateMipMaps defines if the engine should generate the mip levels
  11377. * @param invertY defines if data must be stored with Y axis inverted
  11378. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11379. * @param compression defines the compression used (null by default)
  11380. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11381. * @returns the raw texture inside an InternalTexture
  11382. */
  11383. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  11384. /**
  11385. * Update a raw texture
  11386. * @param texture defines the texture to update
  11387. * @param data defines the data to store in the texture
  11388. * @param format defines the format of the data
  11389. * @param invertY defines if data must be stored with Y axis inverted
  11390. */
  11391. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11392. /**
  11393. * Update a raw texture
  11394. * @param texture defines the texture to update
  11395. * @param data defines the data to store in the texture
  11396. * @param format defines the format of the data
  11397. * @param invertY defines if data must be stored with Y axis inverted
  11398. * @param compression defines the compression used (null by default)
  11399. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11400. */
  11401. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  11402. /**
  11403. * Creates a new raw cube texture
  11404. * @param data defines the array of data to use to create each face
  11405. * @param size defines the size of the textures
  11406. * @param format defines the format of the data
  11407. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11408. * @param generateMipMaps defines if the engine should generate the mip levels
  11409. * @param invertY defines if data must be stored with Y axis inverted
  11410. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11411. * @param compression defines the compression used (null by default)
  11412. * @returns the cube texture as an InternalTexture
  11413. */
  11414. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  11415. /**
  11416. * Update a raw cube texture
  11417. * @param texture defines the texture to udpdate
  11418. * @param data defines the data to store
  11419. * @param format defines the data format
  11420. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11421. * @param invertY defines if data must be stored with Y axis inverted
  11422. */
  11423. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  11424. /**
  11425. * Update a raw cube texture
  11426. * @param texture defines the texture to udpdate
  11427. * @param data defines the data to store
  11428. * @param format defines the data format
  11429. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11430. * @param invertY defines if data must be stored with Y axis inverted
  11431. * @param compression defines the compression used (null by default)
  11432. */
  11433. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  11434. /**
  11435. * Update a raw cube texture
  11436. * @param texture defines the texture to udpdate
  11437. * @param data defines the data to store
  11438. * @param format defines the data format
  11439. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11440. * @param invertY defines if data must be stored with Y axis inverted
  11441. * @param compression defines the compression used (null by default)
  11442. * @param level defines which level of the texture to update
  11443. */
  11444. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  11445. /**
  11446. * Creates a new raw cube texture from a specified url
  11447. * @param url defines the url where the data is located
  11448. * @param scene defines the current scene
  11449. * @param size defines the size of the textures
  11450. * @param format defines the format of the data
  11451. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11452. * @param noMipmap defines if the engine should avoid generating the mip levels
  11453. * @param callback defines a callback used to extract texture data from loaded data
  11454. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11455. * @param onLoad defines a callback called when texture is loaded
  11456. * @param onError defines a callback called if there is an error
  11457. * @returns the cube texture as an InternalTexture
  11458. */
  11459. 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;
  11460. /**
  11461. * Creates a new raw cube texture from a specified url
  11462. * @param url defines the url where the data is located
  11463. * @param scene defines the current scene
  11464. * @param size defines the size of the textures
  11465. * @param format defines the format of the data
  11466. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11467. * @param noMipmap defines if the engine should avoid generating the mip levels
  11468. * @param callback defines a callback used to extract texture data from loaded data
  11469. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11470. * @param onLoad defines a callback called when texture is loaded
  11471. * @param onError defines a callback called if there is an error
  11472. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11473. * @param invertY defines if data must be stored with Y axis inverted
  11474. * @returns the cube texture as an InternalTexture
  11475. */
  11476. 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;
  11477. /**
  11478. * Creates a new raw 3D texture
  11479. * @param data defines the data used to create the texture
  11480. * @param width defines the width of the texture
  11481. * @param height defines the height of the texture
  11482. * @param depth defines the depth of the texture
  11483. * @param format defines the format of the texture
  11484. * @param generateMipMaps defines if the engine must generate mip levels
  11485. * @param invertY defines if data must be stored with Y axis inverted
  11486. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11487. * @param compression defines the compressed used (can be null)
  11488. * @param textureType defines the compressed used (can be null)
  11489. * @returns a new raw 3D texture (stored in an InternalTexture)
  11490. */
  11491. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11492. /**
  11493. * Update a raw 3D texture
  11494. * @param texture defines the texture to update
  11495. * @param data defines the data to store
  11496. * @param format defines the data format
  11497. * @param invertY defines if data must be stored with Y axis inverted
  11498. */
  11499. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11500. /**
  11501. * Update a raw 3D texture
  11502. * @param texture defines the texture to update
  11503. * @param data defines the data to store
  11504. * @param format defines the data format
  11505. * @param invertY defines if data must be stored with Y axis inverted
  11506. * @param compression defines the used compression (can be null)
  11507. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11508. */
  11509. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11510. /**
  11511. * Creates a new raw 2D array texture
  11512. * @param data defines the data used to create the texture
  11513. * @param width defines the width of the texture
  11514. * @param height defines the height of the texture
  11515. * @param depth defines the number of layers of the texture
  11516. * @param format defines the format of the texture
  11517. * @param generateMipMaps defines if the engine must generate mip levels
  11518. * @param invertY defines if data must be stored with Y axis inverted
  11519. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11520. * @param compression defines the compressed used (can be null)
  11521. * @param textureType defines the compressed used (can be null)
  11522. * @returns a new raw 2D array texture (stored in an InternalTexture)
  11523. */
  11524. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11525. /**
  11526. * Update a raw 2D array texture
  11527. * @param texture defines the texture to update
  11528. * @param data defines the data to store
  11529. * @param format defines the data format
  11530. * @param invertY defines if data must be stored with Y axis inverted
  11531. */
  11532. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11533. /**
  11534. * Update a raw 2D array texture
  11535. * @param texture defines the texture to update
  11536. * @param data defines the data to store
  11537. * @param format defines the data format
  11538. * @param invertY defines if data must be stored with Y axis inverted
  11539. * @param compression defines the used compression (can be null)
  11540. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11541. */
  11542. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11543. }
  11544. }
  11545. declare module BABYLON {
  11546. /**
  11547. * Raw texture can help creating a texture directly from an array of data.
  11548. * This can be super useful if you either get the data from an uncompressed source or
  11549. * if you wish to create your texture pixel by pixel.
  11550. */
  11551. export class RawTexture extends Texture {
  11552. /**
  11553. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11554. */
  11555. format: number;
  11556. /**
  11557. * Instantiates a new RawTexture.
  11558. * Raw texture can help creating a texture directly from an array of data.
  11559. * This can be super useful if you either get the data from an uncompressed source or
  11560. * if you wish to create your texture pixel by pixel.
  11561. * @param data define the array of data to use to create the texture
  11562. * @param width define the width of the texture
  11563. * @param height define the height of the texture
  11564. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11565. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11566. * @param generateMipMaps define whether mip maps should be generated or not
  11567. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11568. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11569. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11570. */
  11571. constructor(data: ArrayBufferView, width: number, height: number,
  11572. /**
  11573. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11574. */
  11575. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  11576. /**
  11577. * Updates the texture underlying data.
  11578. * @param data Define the new data of the texture
  11579. */
  11580. update(data: ArrayBufferView): void;
  11581. /**
  11582. * Creates a luminance texture from some data.
  11583. * @param data Define the texture data
  11584. * @param width Define the width of the texture
  11585. * @param height Define the height of the texture
  11586. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11587. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11588. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11589. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11590. * @returns the luminance texture
  11591. */
  11592. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11593. /**
  11594. * Creates a luminance alpha texture from some data.
  11595. * @param data Define the texture data
  11596. * @param width Define the width of the texture
  11597. * @param height Define the height of the texture
  11598. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11599. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11600. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11601. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11602. * @returns the luminance alpha texture
  11603. */
  11604. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11605. /**
  11606. * Creates an alpha texture from some data.
  11607. * @param data Define the texture data
  11608. * @param width Define the width of the texture
  11609. * @param height Define the height of the texture
  11610. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11611. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11612. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11613. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11614. * @returns the alpha texture
  11615. */
  11616. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11617. /**
  11618. * Creates a RGB texture from some data.
  11619. * @param data Define the texture data
  11620. * @param width Define the width of the texture
  11621. * @param height Define the height of the texture
  11622. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11623. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11624. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11625. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11626. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11627. * @returns the RGB alpha texture
  11628. */
  11629. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11630. /**
  11631. * Creates a RGBA texture from some data.
  11632. * @param data Define the texture data
  11633. * @param width Define the width of the texture
  11634. * @param height Define the height of the texture
  11635. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11636. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11637. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11638. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11639. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11640. * @returns the RGBA texture
  11641. */
  11642. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11643. /**
  11644. * Creates a R texture from some data.
  11645. * @param data Define the texture data
  11646. * @param width Define the width of the texture
  11647. * @param height Define the height of the texture
  11648. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11649. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11650. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11651. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11652. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11653. * @returns the R texture
  11654. */
  11655. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11656. }
  11657. }
  11658. declare module BABYLON {
  11659. interface ThinEngine {
  11660. /**
  11661. * Update a dynamic index buffer
  11662. * @param indexBuffer defines the target index buffer
  11663. * @param indices defines the data to update
  11664. * @param offset defines the offset in the target index buffer where update should start
  11665. */
  11666. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  11667. /**
  11668. * Updates a dynamic vertex buffer.
  11669. * @param vertexBuffer the vertex buffer to update
  11670. * @param data the data used to update the vertex buffer
  11671. * @param byteOffset the byte offset of the data
  11672. * @param byteLength the byte length of the data
  11673. */
  11674. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  11675. }
  11676. }
  11677. declare module BABYLON {
  11678. interface AbstractScene {
  11679. /**
  11680. * The list of procedural textures added to the scene
  11681. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11682. */
  11683. proceduralTextures: Array<ProceduralTexture>;
  11684. }
  11685. /**
  11686. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  11687. * in a given scene.
  11688. */
  11689. export class ProceduralTextureSceneComponent implements ISceneComponent {
  11690. /**
  11691. * The component name helpfull to identify the component in the list of scene components.
  11692. */
  11693. readonly name: string;
  11694. /**
  11695. * The scene the component belongs to.
  11696. */
  11697. scene: Scene;
  11698. /**
  11699. * Creates a new instance of the component for the given scene
  11700. * @param scene Defines the scene to register the component in
  11701. */
  11702. constructor(scene: Scene);
  11703. /**
  11704. * Registers the component in a given scene
  11705. */
  11706. register(): void;
  11707. /**
  11708. * Rebuilds the elements related to this component in case of
  11709. * context lost for instance.
  11710. */
  11711. rebuild(): void;
  11712. /**
  11713. * Disposes the component and the associated ressources.
  11714. */
  11715. dispose(): void;
  11716. private _beforeClear;
  11717. }
  11718. }
  11719. declare module BABYLON {
  11720. interface ThinEngine {
  11721. /**
  11722. * Creates a new render target cube texture
  11723. * @param size defines the size of the texture
  11724. * @param options defines the options used to create the texture
  11725. * @returns a new render target cube texture stored in an InternalTexture
  11726. */
  11727. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11728. }
  11729. }
  11730. declare module BABYLON {
  11731. /** @hidden */
  11732. export var proceduralVertexShader: {
  11733. name: string;
  11734. shader: string;
  11735. };
  11736. }
  11737. declare module BABYLON {
  11738. /**
  11739. * 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.
  11740. * This is the base class of any Procedural texture and contains most of the shareable code.
  11741. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11742. */
  11743. export class ProceduralTexture extends Texture {
  11744. /**
  11745. * Define if the texture is enabled or not (disabled texture will not render)
  11746. */
  11747. isEnabled: boolean;
  11748. /**
  11749. * Define if the texture must be cleared before rendering (default is true)
  11750. */
  11751. autoClear: boolean;
  11752. /**
  11753. * Callback called when the texture is generated
  11754. */
  11755. onGenerated: () => void;
  11756. /**
  11757. * Event raised when the texture is generated
  11758. */
  11759. onGeneratedObservable: Observable<ProceduralTexture>;
  11760. /**
  11761. * Event raised before the texture is generated
  11762. */
  11763. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  11764. /**
  11765. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  11766. */
  11767. nodeMaterialSource: Nullable<NodeMaterial>;
  11768. /** @hidden */
  11769. _generateMipMaps: boolean;
  11770. /** @hidden **/
  11771. _effect: Effect;
  11772. /** @hidden */
  11773. _textures: {
  11774. [key: string]: Texture;
  11775. };
  11776. /** @hidden */
  11777. protected _fallbackTexture: Nullable<Texture>;
  11778. private _size;
  11779. private _currentRefreshId;
  11780. private _frameId;
  11781. private _refreshRate;
  11782. private _vertexBuffers;
  11783. private _indexBuffer;
  11784. private _uniforms;
  11785. private _samplers;
  11786. private _fragment;
  11787. private _floats;
  11788. private _ints;
  11789. private _floatsArrays;
  11790. private _colors3;
  11791. private _colors4;
  11792. private _vectors2;
  11793. private _vectors3;
  11794. private _matrices;
  11795. private _fallbackTextureUsed;
  11796. private _fullEngine;
  11797. private _cachedDefines;
  11798. private _contentUpdateId;
  11799. private _contentData;
  11800. /**
  11801. * Instantiates a new procedural texture.
  11802. * 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.
  11803. * This is the base class of any Procedural texture and contains most of the shareable code.
  11804. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11805. * @param name Define the name of the texture
  11806. * @param size Define the size of the texture to create
  11807. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  11808. * @param scene Define the scene the texture belongs to
  11809. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  11810. * @param generateMipMaps Define if the texture should creates mip maps or not
  11811. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  11812. * @param textureType The FBO internal texture type
  11813. */
  11814. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean, textureType?: number);
  11815. /**
  11816. * The effect that is created when initializing the post process.
  11817. * @returns The created effect corresponding the the postprocess.
  11818. */
  11819. getEffect(): Effect;
  11820. /**
  11821. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  11822. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  11823. */
  11824. getContent(): Nullable<ArrayBufferView>;
  11825. private _createIndexBuffer;
  11826. /** @hidden */
  11827. _rebuild(): void;
  11828. /**
  11829. * Resets the texture in order to recreate its associated resources.
  11830. * This can be called in case of context loss
  11831. */
  11832. reset(): void;
  11833. protected _getDefines(): string;
  11834. /**
  11835. * Is the texture ready to be used ? (rendered at least once)
  11836. * @returns true if ready, otherwise, false.
  11837. */
  11838. isReady(): boolean;
  11839. /**
  11840. * Resets the refresh counter of the texture and start bak from scratch.
  11841. * Could be useful to regenerate the texture if it is setup to render only once.
  11842. */
  11843. resetRefreshCounter(): void;
  11844. /**
  11845. * Set the fragment shader to use in order to render the texture.
  11846. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  11847. */
  11848. setFragment(fragment: any): void;
  11849. /**
  11850. * Define the refresh rate of the texture or the rendering frequency.
  11851. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  11852. */
  11853. get refreshRate(): number;
  11854. set refreshRate(value: number);
  11855. /** @hidden */
  11856. _shouldRender(): boolean;
  11857. /**
  11858. * Get the size the texture is rendering at.
  11859. * @returns the size (on cube texture it is always squared)
  11860. */
  11861. getRenderSize(): RenderTargetTextureSize;
  11862. /**
  11863. * Resize the texture to new value.
  11864. * @param size Define the new size the texture should have
  11865. * @param generateMipMaps Define whether the new texture should create mip maps
  11866. */
  11867. resize(size: number, generateMipMaps: boolean): void;
  11868. private _checkUniform;
  11869. /**
  11870. * Set a texture in the shader program used to render.
  11871. * @param name Define the name of the uniform samplers as defined in the shader
  11872. * @param texture Define the texture to bind to this sampler
  11873. * @return the texture itself allowing "fluent" like uniform updates
  11874. */
  11875. setTexture(name: string, texture: Texture): ProceduralTexture;
  11876. /**
  11877. * Set a float in the shader.
  11878. * @param name Define the name of the uniform as defined in the shader
  11879. * @param value Define the value to give to the uniform
  11880. * @return the texture itself allowing "fluent" like uniform updates
  11881. */
  11882. setFloat(name: string, value: number): ProceduralTexture;
  11883. /**
  11884. * Set a int in the shader.
  11885. * @param name Define the name of the uniform as defined in the shader
  11886. * @param value Define the value to give to the uniform
  11887. * @return the texture itself allowing "fluent" like uniform updates
  11888. */
  11889. setInt(name: string, value: number): ProceduralTexture;
  11890. /**
  11891. * Set an array of floats in the shader.
  11892. * @param name Define the name of the uniform as defined in the shader
  11893. * @param value Define the value to give to the uniform
  11894. * @return the texture itself allowing "fluent" like uniform updates
  11895. */
  11896. setFloats(name: string, value: number[]): ProceduralTexture;
  11897. /**
  11898. * Set a vec3 in the shader from a Color3.
  11899. * @param name Define the name of the uniform as defined in the shader
  11900. * @param value Define the value to give to the uniform
  11901. * @return the texture itself allowing "fluent" like uniform updates
  11902. */
  11903. setColor3(name: string, value: Color3): ProceduralTexture;
  11904. /**
  11905. * Set a vec4 in the shader from a Color4.
  11906. * @param name Define the name of the uniform as defined in the shader
  11907. * @param value Define the value to give to the uniform
  11908. * @return the texture itself allowing "fluent" like uniform updates
  11909. */
  11910. setColor4(name: string, value: Color4): ProceduralTexture;
  11911. /**
  11912. * Set a vec2 in the shader from a Vector2.
  11913. * @param name Define the name of the uniform as defined in the shader
  11914. * @param value Define the value to give to the uniform
  11915. * @return the texture itself allowing "fluent" like uniform updates
  11916. */
  11917. setVector2(name: string, value: Vector2): ProceduralTexture;
  11918. /**
  11919. * Set a vec3 in the shader from a Vector3.
  11920. * @param name Define the name of the uniform as defined in the shader
  11921. * @param value Define the value to give to the uniform
  11922. * @return the texture itself allowing "fluent" like uniform updates
  11923. */
  11924. setVector3(name: string, value: Vector3): ProceduralTexture;
  11925. /**
  11926. * Set a mat4 in the shader from a MAtrix.
  11927. * @param name Define the name of the uniform as defined in the shader
  11928. * @param value Define the value to give to the uniform
  11929. * @return the texture itself allowing "fluent" like uniform updates
  11930. */
  11931. setMatrix(name: string, value: Matrix): ProceduralTexture;
  11932. /**
  11933. * Render the texture to its associated render target.
  11934. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  11935. */
  11936. render(useCameraPostProcess?: boolean): void;
  11937. /**
  11938. * Clone the texture.
  11939. * @returns the cloned texture
  11940. */
  11941. clone(): ProceduralTexture;
  11942. /**
  11943. * Dispose the texture and release its asoociated resources.
  11944. */
  11945. dispose(): void;
  11946. }
  11947. }
  11948. declare module BABYLON {
  11949. /**
  11950. * This represents the base class for particle system in Babylon.
  11951. * 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.
  11952. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  11953. * @example https://doc.babylonjs.com/babylon101/particles
  11954. */
  11955. export class BaseParticleSystem {
  11956. /**
  11957. * Source color is added to the destination color without alpha affecting the result
  11958. */
  11959. static BLENDMODE_ONEONE: number;
  11960. /**
  11961. * Blend current color and particle color using particle’s alpha
  11962. */
  11963. static BLENDMODE_STANDARD: number;
  11964. /**
  11965. * Add current color and particle color multiplied by particle’s alpha
  11966. */
  11967. static BLENDMODE_ADD: number;
  11968. /**
  11969. * Multiply current color with particle color
  11970. */
  11971. static BLENDMODE_MULTIPLY: number;
  11972. /**
  11973. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  11974. */
  11975. static BLENDMODE_MULTIPLYADD: number;
  11976. /**
  11977. * List of animations used by the particle system.
  11978. */
  11979. animations: Animation[];
  11980. /**
  11981. * Gets or sets the unique id of the particle system
  11982. */
  11983. uniqueId: number;
  11984. /**
  11985. * The id of the Particle system.
  11986. */
  11987. id: string;
  11988. /**
  11989. * The friendly name of the Particle system.
  11990. */
  11991. name: string;
  11992. /**
  11993. * Snippet ID if the particle system was created from the snippet server
  11994. */
  11995. snippetId: string;
  11996. /**
  11997. * The rendering group used by the Particle system to chose when to render.
  11998. */
  11999. renderingGroupId: number;
  12000. /**
  12001. * The emitter represents the Mesh or position we are attaching the particle system to.
  12002. */
  12003. emitter: Nullable<AbstractMesh | Vector3>;
  12004. /**
  12005. * The maximum number of particles to emit per frame
  12006. */
  12007. emitRate: number;
  12008. /**
  12009. * If you want to launch only a few particles at once, that can be done, as well.
  12010. */
  12011. manualEmitCount: number;
  12012. /**
  12013. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  12014. */
  12015. updateSpeed: number;
  12016. /**
  12017. * The amount of time the particle system is running (depends of the overall update speed).
  12018. */
  12019. targetStopDuration: number;
  12020. /**
  12021. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  12022. */
  12023. disposeOnStop: boolean;
  12024. /**
  12025. * Minimum power of emitting particles.
  12026. */
  12027. minEmitPower: number;
  12028. /**
  12029. * Maximum power of emitting particles.
  12030. */
  12031. maxEmitPower: number;
  12032. /**
  12033. * Minimum life time of emitting particles.
  12034. */
  12035. minLifeTime: number;
  12036. /**
  12037. * Maximum life time of emitting particles.
  12038. */
  12039. maxLifeTime: number;
  12040. /**
  12041. * Minimum Size of emitting particles.
  12042. */
  12043. minSize: number;
  12044. /**
  12045. * Maximum Size of emitting particles.
  12046. */
  12047. maxSize: number;
  12048. /**
  12049. * Minimum scale of emitting particles on X axis.
  12050. */
  12051. minScaleX: number;
  12052. /**
  12053. * Maximum scale of emitting particles on X axis.
  12054. */
  12055. maxScaleX: number;
  12056. /**
  12057. * Minimum scale of emitting particles on Y axis.
  12058. */
  12059. minScaleY: number;
  12060. /**
  12061. * Maximum scale of emitting particles on Y axis.
  12062. */
  12063. maxScaleY: number;
  12064. /**
  12065. * Gets or sets the minimal initial rotation in radians.
  12066. */
  12067. minInitialRotation: number;
  12068. /**
  12069. * Gets or sets the maximal initial rotation in radians.
  12070. */
  12071. maxInitialRotation: number;
  12072. /**
  12073. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  12074. */
  12075. minAngularSpeed: number;
  12076. /**
  12077. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  12078. */
  12079. maxAngularSpeed: number;
  12080. /**
  12081. * The texture used to render each particle. (this can be a spritesheet)
  12082. */
  12083. particleTexture: Nullable<BaseTexture>;
  12084. /**
  12085. * The layer mask we are rendering the particles through.
  12086. */
  12087. layerMask: number;
  12088. /**
  12089. * This can help using your own shader to render the particle system.
  12090. * The according effect will be created
  12091. */
  12092. customShader: any;
  12093. /**
  12094. * By default particle system starts as soon as they are created. This prevents the
  12095. * automatic start to happen and let you decide when to start emitting particles.
  12096. */
  12097. preventAutoStart: boolean;
  12098. private _noiseTexture;
  12099. /**
  12100. * Gets or sets a texture used to add random noise to particle positions
  12101. */
  12102. get noiseTexture(): Nullable<ProceduralTexture>;
  12103. set noiseTexture(value: Nullable<ProceduralTexture>);
  12104. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  12105. noiseStrength: Vector3;
  12106. /**
  12107. * Callback triggered when the particle animation is ending.
  12108. */
  12109. onAnimationEnd: Nullable<() => void>;
  12110. /**
  12111. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  12112. */
  12113. blendMode: number;
  12114. /**
  12115. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  12116. * to override the particles.
  12117. */
  12118. forceDepthWrite: boolean;
  12119. /** 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 */
  12120. preWarmCycles: number;
  12121. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  12122. preWarmStepOffset: number;
  12123. /**
  12124. * 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)
  12125. */
  12126. spriteCellChangeSpeed: number;
  12127. /**
  12128. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  12129. */
  12130. startSpriteCellID: number;
  12131. /**
  12132. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  12133. */
  12134. endSpriteCellID: number;
  12135. /**
  12136. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  12137. */
  12138. spriteCellWidth: number;
  12139. /**
  12140. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  12141. */
  12142. spriteCellHeight: number;
  12143. /**
  12144. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  12145. */
  12146. spriteRandomStartCell: boolean;
  12147. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  12148. translationPivot: Vector2;
  12149. /** @hidden */
  12150. protected _isAnimationSheetEnabled: boolean;
  12151. /**
  12152. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  12153. */
  12154. beginAnimationOnStart: boolean;
  12155. /**
  12156. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  12157. */
  12158. beginAnimationFrom: number;
  12159. /**
  12160. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  12161. */
  12162. beginAnimationTo: number;
  12163. /**
  12164. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  12165. */
  12166. beginAnimationLoop: boolean;
  12167. /**
  12168. * Gets or sets a world offset applied to all particles
  12169. */
  12170. worldOffset: Vector3;
  12171. /**
  12172. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  12173. */
  12174. get isAnimationSheetEnabled(): boolean;
  12175. set isAnimationSheetEnabled(value: boolean);
  12176. /**
  12177. * Get hosting scene
  12178. * @returns the scene
  12179. */
  12180. getScene(): Nullable<Scene>;
  12181. /**
  12182. * You can use gravity if you want to give an orientation to your particles.
  12183. */
  12184. gravity: Vector3;
  12185. protected _colorGradients: Nullable<Array<ColorGradient>>;
  12186. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  12187. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  12188. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  12189. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  12190. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  12191. protected _dragGradients: Nullable<Array<FactorGradient>>;
  12192. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  12193. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  12194. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  12195. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  12196. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  12197. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  12198. /**
  12199. * Defines the delay in milliseconds before starting the system (0 by default)
  12200. */
  12201. startDelay: number;
  12202. /**
  12203. * Gets the current list of drag gradients.
  12204. * You must use addDragGradient and removeDragGradient to udpate this list
  12205. * @returns the list of drag gradients
  12206. */
  12207. getDragGradients(): Nullable<Array<FactorGradient>>;
  12208. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  12209. limitVelocityDamping: number;
  12210. /**
  12211. * Gets the current list of limit velocity gradients.
  12212. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  12213. * @returns the list of limit velocity gradients
  12214. */
  12215. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  12216. /**
  12217. * Gets the current list of color gradients.
  12218. * You must use addColorGradient and removeColorGradient to udpate this list
  12219. * @returns the list of color gradients
  12220. */
  12221. getColorGradients(): Nullable<Array<ColorGradient>>;
  12222. /**
  12223. * Gets the current list of size gradients.
  12224. * You must use addSizeGradient and removeSizeGradient to udpate this list
  12225. * @returns the list of size gradients
  12226. */
  12227. getSizeGradients(): Nullable<Array<FactorGradient>>;
  12228. /**
  12229. * Gets the current list of color remap gradients.
  12230. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  12231. * @returns the list of color remap gradients
  12232. */
  12233. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  12234. /**
  12235. * Gets the current list of alpha remap gradients.
  12236. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  12237. * @returns the list of alpha remap gradients
  12238. */
  12239. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  12240. /**
  12241. * Gets the current list of life time gradients.
  12242. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  12243. * @returns the list of life time gradients
  12244. */
  12245. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  12246. /**
  12247. * Gets the current list of angular speed gradients.
  12248. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  12249. * @returns the list of angular speed gradients
  12250. */
  12251. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  12252. /**
  12253. * Gets the current list of velocity gradients.
  12254. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  12255. * @returns the list of velocity gradients
  12256. */
  12257. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  12258. /**
  12259. * Gets the current list of start size gradients.
  12260. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  12261. * @returns the list of start size gradients
  12262. */
  12263. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  12264. /**
  12265. * Gets the current list of emit rate gradients.
  12266. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  12267. * @returns the list of emit rate gradients
  12268. */
  12269. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  12270. /**
  12271. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12272. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12273. */
  12274. get direction1(): Vector3;
  12275. set direction1(value: Vector3);
  12276. /**
  12277. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12278. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12279. */
  12280. get direction2(): Vector3;
  12281. set direction2(value: Vector3);
  12282. /**
  12283. * 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.
  12284. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12285. */
  12286. get minEmitBox(): Vector3;
  12287. set minEmitBox(value: Vector3);
  12288. /**
  12289. * 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.
  12290. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12291. */
  12292. get maxEmitBox(): Vector3;
  12293. set maxEmitBox(value: Vector3);
  12294. /**
  12295. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12296. */
  12297. color1: Color4;
  12298. /**
  12299. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12300. */
  12301. color2: Color4;
  12302. /**
  12303. * Color the particle will have at the end of its lifetime
  12304. */
  12305. colorDead: Color4;
  12306. /**
  12307. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  12308. */
  12309. textureMask: Color4;
  12310. /**
  12311. * The particle emitter type defines the emitter used by the particle system.
  12312. * It can be for example box, sphere, or cone...
  12313. */
  12314. particleEmitterType: IParticleEmitterType;
  12315. /** @hidden */
  12316. _isSubEmitter: boolean;
  12317. /**
  12318. * Gets or sets the billboard mode to use when isBillboardBased = true.
  12319. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  12320. */
  12321. billboardMode: number;
  12322. protected _isBillboardBased: boolean;
  12323. /**
  12324. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12325. */
  12326. get isBillboardBased(): boolean;
  12327. set isBillboardBased(value: boolean);
  12328. /**
  12329. * The scene the particle system belongs to.
  12330. */
  12331. protected _scene: Nullable<Scene>;
  12332. /**
  12333. * The engine the particle system belongs to.
  12334. */
  12335. protected _engine: ThinEngine;
  12336. /**
  12337. * Local cache of defines for image processing.
  12338. */
  12339. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  12340. /**
  12341. * Default configuration related to image processing available in the standard Material.
  12342. */
  12343. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  12344. /**
  12345. * Gets the image processing configuration used either in this material.
  12346. */
  12347. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  12348. /**
  12349. * Sets the Default image processing configuration used either in the this material.
  12350. *
  12351. * If sets to null, the scene one is in use.
  12352. */
  12353. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  12354. /**
  12355. * Attaches a new image processing configuration to the Standard Material.
  12356. * @param configuration
  12357. */
  12358. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  12359. /** @hidden */
  12360. protected _reset(): void;
  12361. /** @hidden */
  12362. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  12363. /**
  12364. * Instantiates a particle system.
  12365. * 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.
  12366. * @param name The name of the particle system
  12367. */
  12368. constructor(name: string);
  12369. /**
  12370. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  12371. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12372. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12373. * @returns the emitter
  12374. */
  12375. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  12376. /**
  12377. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  12378. * @param radius The radius of the hemisphere to emit from
  12379. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12380. * @returns the emitter
  12381. */
  12382. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  12383. /**
  12384. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  12385. * @param radius The radius of the sphere to emit from
  12386. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12387. * @returns the emitter
  12388. */
  12389. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  12390. /**
  12391. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  12392. * @param radius The radius of the sphere to emit from
  12393. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  12394. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  12395. * @returns the emitter
  12396. */
  12397. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  12398. /**
  12399. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  12400. * @param radius The radius of the emission cylinder
  12401. * @param height The height of the emission cylinder
  12402. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  12403. * @param directionRandomizer How much to randomize the particle direction [0-1]
  12404. * @returns the emitter
  12405. */
  12406. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  12407. /**
  12408. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  12409. * @param radius The radius of the cylinder to emit from
  12410. * @param height The height of the emission cylinder
  12411. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12412. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  12413. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  12414. * @returns the emitter
  12415. */
  12416. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  12417. /**
  12418. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  12419. * @param radius The radius of the cone to emit from
  12420. * @param angle The base angle of the cone
  12421. * @returns the emitter
  12422. */
  12423. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  12424. /**
  12425. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  12426. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12427. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12428. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12429. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12430. * @returns the emitter
  12431. */
  12432. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  12433. }
  12434. }
  12435. declare module BABYLON {
  12436. /**
  12437. * Type of sub emitter
  12438. */
  12439. export enum SubEmitterType {
  12440. /**
  12441. * Attached to the particle over it's lifetime
  12442. */
  12443. ATTACHED = 0,
  12444. /**
  12445. * Created when the particle dies
  12446. */
  12447. END = 1
  12448. }
  12449. /**
  12450. * Sub emitter class used to emit particles from an existing particle
  12451. */
  12452. export class SubEmitter {
  12453. /**
  12454. * the particle system to be used by the sub emitter
  12455. */
  12456. particleSystem: ParticleSystem;
  12457. /**
  12458. * Type of the submitter (Default: END)
  12459. */
  12460. type: SubEmitterType;
  12461. /**
  12462. * 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)
  12463. * Note: This only is supported when using an emitter of type Mesh
  12464. */
  12465. inheritDirection: boolean;
  12466. /**
  12467. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  12468. */
  12469. inheritedVelocityAmount: number;
  12470. /**
  12471. * Creates a sub emitter
  12472. * @param particleSystem the particle system to be used by the sub emitter
  12473. */
  12474. constructor(
  12475. /**
  12476. * the particle system to be used by the sub emitter
  12477. */
  12478. particleSystem: ParticleSystem);
  12479. /**
  12480. * Clones the sub emitter
  12481. * @returns the cloned sub emitter
  12482. */
  12483. clone(): SubEmitter;
  12484. /**
  12485. * Serialize current object to a JSON object
  12486. * @returns the serialized object
  12487. */
  12488. serialize(): any;
  12489. /** @hidden */
  12490. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  12491. /**
  12492. * Creates a new SubEmitter from a serialized JSON version
  12493. * @param serializationObject defines the JSON object to read from
  12494. * @param sceneOrEngine defines the hosting scene or the hosting engine
  12495. * @param rootUrl defines the rootUrl for data loading
  12496. * @returns a new SubEmitter
  12497. */
  12498. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  12499. /** Release associated resources */
  12500. dispose(): void;
  12501. }
  12502. }
  12503. declare module BABYLON {
  12504. /** @hidden */
  12505. export var imageProcessingDeclaration: {
  12506. name: string;
  12507. shader: string;
  12508. };
  12509. }
  12510. declare module BABYLON {
  12511. /** @hidden */
  12512. export var imageProcessingFunctions: {
  12513. name: string;
  12514. shader: string;
  12515. };
  12516. }
  12517. declare module BABYLON {
  12518. /** @hidden */
  12519. export var particlesPixelShader: {
  12520. name: string;
  12521. shader: string;
  12522. };
  12523. }
  12524. declare module BABYLON {
  12525. /** @hidden */
  12526. export var particlesVertexShader: {
  12527. name: string;
  12528. shader: string;
  12529. };
  12530. }
  12531. declare module BABYLON {
  12532. /**
  12533. * Interface used to define entities containing multiple clip planes
  12534. */
  12535. export interface IClipPlanesHolder {
  12536. /**
  12537. * Gets or sets the active clipplane 1
  12538. */
  12539. clipPlane: Nullable<Plane>;
  12540. /**
  12541. * Gets or sets the active clipplane 2
  12542. */
  12543. clipPlane2: Nullable<Plane>;
  12544. /**
  12545. * Gets or sets the active clipplane 3
  12546. */
  12547. clipPlane3: Nullable<Plane>;
  12548. /**
  12549. * Gets or sets the active clipplane 4
  12550. */
  12551. clipPlane4: Nullable<Plane>;
  12552. /**
  12553. * Gets or sets the active clipplane 5
  12554. */
  12555. clipPlane5: Nullable<Plane>;
  12556. /**
  12557. * Gets or sets the active clipplane 6
  12558. */
  12559. clipPlane6: Nullable<Plane>;
  12560. }
  12561. }
  12562. declare module BABYLON {
  12563. /**
  12564. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  12565. *
  12566. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  12567. *
  12568. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  12569. */
  12570. export class ThinMaterialHelper {
  12571. /**
  12572. * Binds the clip plane information from the holder to the effect.
  12573. * @param effect The effect we are binding the data to
  12574. * @param holder The entity containing the clip plane information
  12575. */
  12576. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  12577. }
  12578. }
  12579. declare module BABYLON {
  12580. interface ThinEngine {
  12581. /**
  12582. * Sets alpha constants used by some alpha blending modes
  12583. * @param r defines the red component
  12584. * @param g defines the green component
  12585. * @param b defines the blue component
  12586. * @param a defines the alpha component
  12587. */
  12588. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  12589. /**
  12590. * Sets the current alpha mode
  12591. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  12592. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  12593. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12594. */
  12595. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  12596. /**
  12597. * Gets the current alpha mode
  12598. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12599. * @returns the current alpha mode
  12600. */
  12601. getAlphaMode(): number;
  12602. /**
  12603. * Sets the current alpha equation
  12604. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  12605. */
  12606. setAlphaEquation(equation: number): void;
  12607. /**
  12608. * Gets the current alpha equation.
  12609. * @returns the current alpha equation
  12610. */
  12611. getAlphaEquation(): number;
  12612. }
  12613. }
  12614. declare module BABYLON {
  12615. /**
  12616. * This represents a particle system in Babylon.
  12617. * 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.
  12618. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12619. * @example https://doc.babylonjs.com/babylon101/particles
  12620. */
  12621. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  12622. /**
  12623. * Billboard mode will only apply to Y axis
  12624. */
  12625. static readonly BILLBOARDMODE_Y: number;
  12626. /**
  12627. * Billboard mode will apply to all axes
  12628. */
  12629. static readonly BILLBOARDMODE_ALL: number;
  12630. /**
  12631. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  12632. */
  12633. static readonly BILLBOARDMODE_STRETCHED: number;
  12634. /**
  12635. * This function can be defined to provide custom update for active particles.
  12636. * This function will be called instead of regular update (age, position, color, etc.).
  12637. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  12638. */
  12639. updateFunction: (particles: Particle[]) => void;
  12640. private _emitterWorldMatrix;
  12641. /**
  12642. * This function can be defined to specify initial direction for every new particle.
  12643. * It by default use the emitterType defined function
  12644. */
  12645. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12646. /**
  12647. * This function can be defined to specify initial position for every new particle.
  12648. * It by default use the emitterType defined function
  12649. */
  12650. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12651. /**
  12652. * @hidden
  12653. */
  12654. _inheritedVelocityOffset: Vector3;
  12655. /**
  12656. * An event triggered when the system is disposed
  12657. */
  12658. onDisposeObservable: Observable<IParticleSystem>;
  12659. /**
  12660. * An event triggered when the system is stopped
  12661. */
  12662. onStoppedObservable: Observable<IParticleSystem>;
  12663. private _onDisposeObserver;
  12664. /**
  12665. * Sets a callback that will be triggered when the system is disposed
  12666. */
  12667. set onDispose(callback: () => void);
  12668. private _particles;
  12669. private _epsilon;
  12670. private _capacity;
  12671. private _stockParticles;
  12672. private _newPartsExcess;
  12673. private _vertexData;
  12674. private _vertexBuffer;
  12675. private _vertexBuffers;
  12676. private _spriteBuffer;
  12677. private _indexBuffer;
  12678. private _effect;
  12679. private _customEffect;
  12680. private _cachedDefines;
  12681. private _scaledColorStep;
  12682. private _colorDiff;
  12683. private _scaledDirection;
  12684. private _scaledGravity;
  12685. private _currentRenderId;
  12686. private _alive;
  12687. private _useInstancing;
  12688. private _started;
  12689. private _stopped;
  12690. private _actualFrame;
  12691. private _scaledUpdateSpeed;
  12692. private _vertexBufferSize;
  12693. /** @hidden */
  12694. _currentEmitRateGradient: Nullable<FactorGradient>;
  12695. /** @hidden */
  12696. _currentEmitRate1: number;
  12697. /** @hidden */
  12698. _currentEmitRate2: number;
  12699. /** @hidden */
  12700. _currentStartSizeGradient: Nullable<FactorGradient>;
  12701. /** @hidden */
  12702. _currentStartSize1: number;
  12703. /** @hidden */
  12704. _currentStartSize2: number;
  12705. private readonly _rawTextureWidth;
  12706. private _rampGradientsTexture;
  12707. private _useRampGradients;
  12708. /** Gets or sets a matrix to use to compute projection */
  12709. defaultProjectionMatrix: Matrix;
  12710. /** Gets or sets a matrix to use to compute view */
  12711. defaultViewMatrix: Matrix;
  12712. /** Gets or sets a boolean indicating that ramp gradients must be used
  12713. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  12714. */
  12715. get useRampGradients(): boolean;
  12716. set useRampGradients(value: boolean);
  12717. /**
  12718. * 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.
  12719. * 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: [])
  12720. */
  12721. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  12722. private _subEmitters;
  12723. /**
  12724. * @hidden
  12725. * If the particle systems emitter should be disposed when the particle system is disposed
  12726. */
  12727. _disposeEmitterOnDispose: boolean;
  12728. /**
  12729. * The current active Sub-systems, this property is used by the root particle system only.
  12730. */
  12731. activeSubSystems: Array<ParticleSystem>;
  12732. /**
  12733. * Specifies if the particles are updated in emitter local space or world space
  12734. */
  12735. isLocal: boolean;
  12736. private _rootParticleSystem;
  12737. /**
  12738. * Gets the current list of active particles
  12739. */
  12740. get particles(): Particle[];
  12741. /**
  12742. * Gets the number of particles active at the same time.
  12743. * @returns The number of active particles.
  12744. */
  12745. getActiveCount(): number;
  12746. /**
  12747. * Returns the string "ParticleSystem"
  12748. * @returns a string containing the class name
  12749. */
  12750. getClassName(): string;
  12751. /**
  12752. * Gets a boolean indicating that the system is stopping
  12753. * @returns true if the system is currently stopping
  12754. */
  12755. isStopping(): boolean;
  12756. /**
  12757. * Gets the custom effect used to render the particles
  12758. * @param blendMode Blend mode for which the effect should be retrieved
  12759. * @returns The effect
  12760. */
  12761. getCustomEffect(blendMode?: number): Nullable<Effect>;
  12762. /**
  12763. * Sets the custom effect used to render the particles
  12764. * @param effect The effect to set
  12765. * @param blendMode Blend mode for which the effect should be set
  12766. */
  12767. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  12768. /** @hidden */
  12769. private _onBeforeDrawParticlesObservable;
  12770. /**
  12771. * Observable that will be called just before the particles are drawn
  12772. */
  12773. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  12774. /**
  12775. * Gets the name of the particle vertex shader
  12776. */
  12777. get vertexShaderName(): string;
  12778. /**
  12779. * Instantiates a particle system.
  12780. * 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.
  12781. * @param name The name of the particle system
  12782. * @param capacity The max number of particles alive at the same time
  12783. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  12784. * @param customEffect a custom effect used to change the way particles are rendered by default
  12785. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  12786. * @param epsilon Offset used to render the particles
  12787. */
  12788. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  12789. private _addFactorGradient;
  12790. private _removeFactorGradient;
  12791. /**
  12792. * Adds a new life time gradient
  12793. * @param gradient defines the gradient to use (between 0 and 1)
  12794. * @param factor defines the life time factor to affect to the specified gradient
  12795. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12796. * @returns the current particle system
  12797. */
  12798. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12799. /**
  12800. * Remove a specific life time gradient
  12801. * @param gradient defines the gradient to remove
  12802. * @returns the current particle system
  12803. */
  12804. removeLifeTimeGradient(gradient: number): IParticleSystem;
  12805. /**
  12806. * Adds a new size gradient
  12807. * @param gradient defines the gradient to use (between 0 and 1)
  12808. * @param factor defines the size factor to affect to the specified gradient
  12809. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12810. * @returns the current particle system
  12811. */
  12812. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12813. /**
  12814. * Remove a specific size gradient
  12815. * @param gradient defines the gradient to remove
  12816. * @returns the current particle system
  12817. */
  12818. removeSizeGradient(gradient: number): IParticleSystem;
  12819. /**
  12820. * Adds a new color remap gradient
  12821. * @param gradient defines the gradient to use (between 0 and 1)
  12822. * @param min defines the color remap minimal range
  12823. * @param max defines the color remap maximal range
  12824. * @returns the current particle system
  12825. */
  12826. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12827. /**
  12828. * Remove a specific color remap gradient
  12829. * @param gradient defines the gradient to remove
  12830. * @returns the current particle system
  12831. */
  12832. removeColorRemapGradient(gradient: number): IParticleSystem;
  12833. /**
  12834. * Adds a new alpha remap gradient
  12835. * @param gradient defines the gradient to use (between 0 and 1)
  12836. * @param min defines the alpha remap minimal range
  12837. * @param max defines the alpha remap maximal range
  12838. * @returns the current particle system
  12839. */
  12840. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  12841. /**
  12842. * Remove a specific alpha remap gradient
  12843. * @param gradient defines the gradient to remove
  12844. * @returns the current particle system
  12845. */
  12846. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  12847. /**
  12848. * Adds a new angular speed gradient
  12849. * @param gradient defines the gradient to use (between 0 and 1)
  12850. * @param factor defines the angular speed to affect to the specified gradient
  12851. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12852. * @returns the current particle system
  12853. */
  12854. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12855. /**
  12856. * Remove a specific angular speed gradient
  12857. * @param gradient defines the gradient to remove
  12858. * @returns the current particle system
  12859. */
  12860. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  12861. /**
  12862. * Adds a new velocity gradient
  12863. * @param gradient defines the gradient to use (between 0 and 1)
  12864. * @param factor defines the velocity to affect to the specified gradient
  12865. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12866. * @returns the current particle system
  12867. */
  12868. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12869. /**
  12870. * Remove a specific velocity gradient
  12871. * @param gradient defines the gradient to remove
  12872. * @returns the current particle system
  12873. */
  12874. removeVelocityGradient(gradient: number): IParticleSystem;
  12875. /**
  12876. * Adds a new limit velocity gradient
  12877. * @param gradient defines the gradient to use (between 0 and 1)
  12878. * @param factor defines the limit velocity value to affect to the specified gradient
  12879. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12880. * @returns the current particle system
  12881. */
  12882. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12883. /**
  12884. * Remove a specific limit velocity gradient
  12885. * @param gradient defines the gradient to remove
  12886. * @returns the current particle system
  12887. */
  12888. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  12889. /**
  12890. * Adds a new drag gradient
  12891. * @param gradient defines the gradient to use (between 0 and 1)
  12892. * @param factor defines the drag value to affect to the specified gradient
  12893. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12894. * @returns the current particle system
  12895. */
  12896. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12897. /**
  12898. * Remove a specific drag gradient
  12899. * @param gradient defines the gradient to remove
  12900. * @returns the current particle system
  12901. */
  12902. removeDragGradient(gradient: number): IParticleSystem;
  12903. /**
  12904. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  12905. * @param gradient defines the gradient to use (between 0 and 1)
  12906. * @param factor defines the emit rate value to affect to the specified gradient
  12907. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12908. * @returns the current particle system
  12909. */
  12910. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12911. /**
  12912. * Remove a specific emit rate gradient
  12913. * @param gradient defines the gradient to remove
  12914. * @returns the current particle system
  12915. */
  12916. removeEmitRateGradient(gradient: number): IParticleSystem;
  12917. /**
  12918. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  12919. * @param gradient defines the gradient to use (between 0 and 1)
  12920. * @param factor defines the start size value to affect to the specified gradient
  12921. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  12922. * @returns the current particle system
  12923. */
  12924. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  12925. /**
  12926. * Remove a specific start size gradient
  12927. * @param gradient defines the gradient to remove
  12928. * @returns the current particle system
  12929. */
  12930. removeStartSizeGradient(gradient: number): IParticleSystem;
  12931. private _createRampGradientTexture;
  12932. /**
  12933. * Gets the current list of ramp gradients.
  12934. * You must use addRampGradient and removeRampGradient to udpate this list
  12935. * @returns the list of ramp gradients
  12936. */
  12937. getRampGradients(): Nullable<Array<Color3Gradient>>;
  12938. /** Force the system to rebuild all gradients that need to be resync */
  12939. forceRefreshGradients(): void;
  12940. private _syncRampGradientTexture;
  12941. /**
  12942. * Adds a new ramp gradient used to remap particle colors
  12943. * @param gradient defines the gradient to use (between 0 and 1)
  12944. * @param color defines the color to affect to the specified gradient
  12945. * @returns the current particle system
  12946. */
  12947. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  12948. /**
  12949. * Remove a specific ramp gradient
  12950. * @param gradient defines the gradient to remove
  12951. * @returns the current particle system
  12952. */
  12953. removeRampGradient(gradient: number): ParticleSystem;
  12954. /**
  12955. * Adds a new color gradient
  12956. * @param gradient defines the gradient to use (between 0 and 1)
  12957. * @param color1 defines the color to affect to the specified gradient
  12958. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  12959. * @returns this particle system
  12960. */
  12961. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  12962. /**
  12963. * Remove a specific color gradient
  12964. * @param gradient defines the gradient to remove
  12965. * @returns this particle system
  12966. */
  12967. removeColorGradient(gradient: number): IParticleSystem;
  12968. private _fetchR;
  12969. protected _reset(): void;
  12970. private _resetEffect;
  12971. private _createVertexBuffers;
  12972. private _createIndexBuffer;
  12973. /**
  12974. * Gets the maximum number of particles active at the same time.
  12975. * @returns The max number of active particles.
  12976. */
  12977. getCapacity(): number;
  12978. /**
  12979. * Gets whether there are still active particles in the system.
  12980. * @returns True if it is alive, otherwise false.
  12981. */
  12982. isAlive(): boolean;
  12983. /**
  12984. * Gets if the system has been started. (Note: this will still be true after stop is called)
  12985. * @returns True if it has been started, otherwise false.
  12986. */
  12987. isStarted(): boolean;
  12988. private _prepareSubEmitterInternalArray;
  12989. /**
  12990. * Starts the particle system and begins to emit
  12991. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  12992. */
  12993. start(delay?: number): void;
  12994. /**
  12995. * Stops the particle system.
  12996. * @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.
  12997. */
  12998. stop(stopSubEmitters?: boolean): void;
  12999. /**
  13000. * Remove all active particles
  13001. */
  13002. reset(): void;
  13003. /**
  13004. * @hidden (for internal use only)
  13005. */
  13006. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  13007. /**
  13008. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  13009. * Its lifetime will start back at 0.
  13010. */
  13011. recycleParticle: (particle: Particle) => void;
  13012. private _stopSubEmitters;
  13013. private _createParticle;
  13014. private _removeFromRoot;
  13015. private _emitFromParticle;
  13016. private _update;
  13017. /** @hidden */
  13018. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  13019. /** @hidden */
  13020. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  13021. /**
  13022. * Fill the defines array according to the current settings of the particle system
  13023. * @param defines Array to be updated
  13024. * @param blendMode blend mode to take into account when updating the array
  13025. */
  13026. fillDefines(defines: Array<string>, blendMode: number): void;
  13027. /**
  13028. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  13029. * @param uniforms Uniforms array to fill
  13030. * @param attributes Attributes array to fill
  13031. * @param samplers Samplers array to fill
  13032. */
  13033. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  13034. /** @hidden */
  13035. private _getEffect;
  13036. /**
  13037. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  13038. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  13039. */
  13040. animate(preWarmOnly?: boolean): void;
  13041. private _appendParticleVertices;
  13042. /**
  13043. * Rebuilds the particle system.
  13044. */
  13045. rebuild(): void;
  13046. /**
  13047. * Is this system ready to be used/rendered
  13048. * @return true if the system is ready
  13049. */
  13050. isReady(): boolean;
  13051. private _render;
  13052. /**
  13053. * Renders the particle system in its current state.
  13054. * @returns the current number of particles
  13055. */
  13056. render(): number;
  13057. /**
  13058. * Disposes the particle system and free the associated resources
  13059. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13060. */
  13061. dispose(disposeTexture?: boolean): void;
  13062. /**
  13063. * Clones the particle system.
  13064. * @param name The name of the cloned object
  13065. * @param newEmitter The new emitter to use
  13066. * @returns the cloned particle system
  13067. */
  13068. clone(name: string, newEmitter: any): ParticleSystem;
  13069. /**
  13070. * Serializes the particle system to a JSON object
  13071. * @param serializeTexture defines if the texture must be serialized as well
  13072. * @returns the JSON object
  13073. */
  13074. serialize(serializeTexture?: boolean): any;
  13075. /** @hidden */
  13076. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  13077. /** @hidden */
  13078. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  13079. /**
  13080. * Parses a JSON object to create a particle system.
  13081. * @param parsedParticleSystem The JSON object to parse
  13082. * @param sceneOrEngine The scene or the engine to create the particle system in
  13083. * @param rootUrl The root url to use to load external dependencies like texture
  13084. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  13085. * @returns the Parsed particle system
  13086. */
  13087. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  13088. }
  13089. }
  13090. declare module BABYLON {
  13091. /**
  13092. * A particle represents one of the element emitted by a particle system.
  13093. * This is mainly define by its coordinates, direction, velocity and age.
  13094. */
  13095. export class Particle {
  13096. /**
  13097. * The particle system the particle belongs to.
  13098. */
  13099. particleSystem: ParticleSystem;
  13100. private static _Count;
  13101. /**
  13102. * Unique ID of the particle
  13103. */
  13104. id: number;
  13105. /**
  13106. * The world position of the particle in the scene.
  13107. */
  13108. position: Vector3;
  13109. /**
  13110. * The world direction of the particle in the scene.
  13111. */
  13112. direction: Vector3;
  13113. /**
  13114. * The color of the particle.
  13115. */
  13116. color: Color4;
  13117. /**
  13118. * The color change of the particle per step.
  13119. */
  13120. colorStep: Color4;
  13121. /**
  13122. * Defines how long will the life of the particle be.
  13123. */
  13124. lifeTime: number;
  13125. /**
  13126. * The current age of the particle.
  13127. */
  13128. age: number;
  13129. /**
  13130. * The current size of the particle.
  13131. */
  13132. size: number;
  13133. /**
  13134. * The current scale of the particle.
  13135. */
  13136. scale: Vector2;
  13137. /**
  13138. * The current angle of the particle.
  13139. */
  13140. angle: number;
  13141. /**
  13142. * Defines how fast is the angle changing.
  13143. */
  13144. angularSpeed: number;
  13145. /**
  13146. * Defines the cell index used by the particle to be rendered from a sprite.
  13147. */
  13148. cellIndex: number;
  13149. /**
  13150. * The information required to support color remapping
  13151. */
  13152. remapData: Vector4;
  13153. /** @hidden */
  13154. _randomCellOffset?: number;
  13155. /** @hidden */
  13156. _initialDirection: Nullable<Vector3>;
  13157. /** @hidden */
  13158. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  13159. /** @hidden */
  13160. _initialStartSpriteCellID: number;
  13161. /** @hidden */
  13162. _initialEndSpriteCellID: number;
  13163. /** @hidden */
  13164. _currentColorGradient: Nullable<ColorGradient>;
  13165. /** @hidden */
  13166. _currentColor1: Color4;
  13167. /** @hidden */
  13168. _currentColor2: Color4;
  13169. /** @hidden */
  13170. _currentSizeGradient: Nullable<FactorGradient>;
  13171. /** @hidden */
  13172. _currentSize1: number;
  13173. /** @hidden */
  13174. _currentSize2: number;
  13175. /** @hidden */
  13176. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  13177. /** @hidden */
  13178. _currentAngularSpeed1: number;
  13179. /** @hidden */
  13180. _currentAngularSpeed2: number;
  13181. /** @hidden */
  13182. _currentVelocityGradient: Nullable<FactorGradient>;
  13183. /** @hidden */
  13184. _currentVelocity1: number;
  13185. /** @hidden */
  13186. _currentVelocity2: number;
  13187. /** @hidden */
  13188. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  13189. /** @hidden */
  13190. _currentLimitVelocity1: number;
  13191. /** @hidden */
  13192. _currentLimitVelocity2: number;
  13193. /** @hidden */
  13194. _currentDragGradient: Nullable<FactorGradient>;
  13195. /** @hidden */
  13196. _currentDrag1: number;
  13197. /** @hidden */
  13198. _currentDrag2: number;
  13199. /** @hidden */
  13200. _randomNoiseCoordinates1: Vector3;
  13201. /** @hidden */
  13202. _randomNoiseCoordinates2: Vector3;
  13203. /** @hidden */
  13204. _localPosition?: Vector3;
  13205. /**
  13206. * Creates a new instance Particle
  13207. * @param particleSystem the particle system the particle belongs to
  13208. */
  13209. constructor(
  13210. /**
  13211. * The particle system the particle belongs to.
  13212. */
  13213. particleSystem: ParticleSystem);
  13214. private updateCellInfoFromSystem;
  13215. /**
  13216. * Defines how the sprite cell index is updated for the particle
  13217. */
  13218. updateCellIndex(): void;
  13219. /** @hidden */
  13220. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  13221. /** @hidden */
  13222. _inheritParticleInfoToSubEmitters(): void;
  13223. /** @hidden */
  13224. _reset(): void;
  13225. /**
  13226. * Copy the properties of particle to another one.
  13227. * @param other the particle to copy the information to.
  13228. */
  13229. copyTo(other: Particle): void;
  13230. }
  13231. }
  13232. declare module BABYLON {
  13233. /**
  13234. * Particle emitter represents a volume emitting particles.
  13235. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  13236. */
  13237. export interface IParticleEmitterType {
  13238. /**
  13239. * Called by the particle System when the direction is computed for the created particle.
  13240. * @param worldMatrix is the world matrix of the particle system
  13241. * @param directionToUpdate is the direction vector to update with the result
  13242. * @param particle is the particle we are computed the direction for
  13243. * @param isLocal defines if the direction should be set in local space
  13244. */
  13245. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13246. /**
  13247. * Called by the particle System when the position is computed for the created particle.
  13248. * @param worldMatrix is the world matrix of the particle system
  13249. * @param positionToUpdate is the position vector to update with the result
  13250. * @param particle is the particle we are computed the position for
  13251. * @param isLocal defines if the position should be set in local space
  13252. */
  13253. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13254. /**
  13255. * Clones the current emitter and returns a copy of it
  13256. * @returns the new emitter
  13257. */
  13258. clone(): IParticleEmitterType;
  13259. /**
  13260. * Called by the GPUParticleSystem to setup the update shader
  13261. * @param effect defines the update shader
  13262. */
  13263. applyToShader(effect: Effect): void;
  13264. /**
  13265. * Returns a string to use to update the GPU particles update shader
  13266. * @returns the effect defines string
  13267. */
  13268. getEffectDefines(): string;
  13269. /**
  13270. * Returns a string representing the class name
  13271. * @returns a string containing the class name
  13272. */
  13273. getClassName(): string;
  13274. /**
  13275. * Serializes the particle system to a JSON object.
  13276. * @returns the JSON object
  13277. */
  13278. serialize(): any;
  13279. /**
  13280. * Parse properties from a JSON object
  13281. * @param serializationObject defines the JSON object
  13282. * @param scene defines the hosting scene
  13283. */
  13284. parse(serializationObject: any, scene: Nullable<Scene>): void;
  13285. }
  13286. }
  13287. declare module BABYLON {
  13288. /**
  13289. * Particle emitter emitting particles from the inside of a box.
  13290. * It emits the particles randomly between 2 given directions.
  13291. */
  13292. export class BoxParticleEmitter implements IParticleEmitterType {
  13293. /**
  13294. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13295. */
  13296. direction1: Vector3;
  13297. /**
  13298. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13299. */
  13300. direction2: Vector3;
  13301. /**
  13302. * 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.
  13303. */
  13304. minEmitBox: Vector3;
  13305. /**
  13306. * 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.
  13307. */
  13308. maxEmitBox: Vector3;
  13309. /**
  13310. * Creates a new instance BoxParticleEmitter
  13311. */
  13312. constructor();
  13313. /**
  13314. * Called by the particle System when the direction is computed for the created particle.
  13315. * @param worldMatrix is the world matrix of the particle system
  13316. * @param directionToUpdate is the direction vector to update with the result
  13317. * @param particle is the particle we are computed the direction for
  13318. * @param isLocal defines if the direction should be set in local space
  13319. */
  13320. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13321. /**
  13322. * Called by the particle System when the position is computed for the created particle.
  13323. * @param worldMatrix is the world matrix of the particle system
  13324. * @param positionToUpdate is the position vector to update with the result
  13325. * @param particle is the particle we are computed the position for
  13326. * @param isLocal defines if the position should be set in local space
  13327. */
  13328. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13329. /**
  13330. * Clones the current emitter and returns a copy of it
  13331. * @returns the new emitter
  13332. */
  13333. clone(): BoxParticleEmitter;
  13334. /**
  13335. * Called by the GPUParticleSystem to setup the update shader
  13336. * @param effect defines the update shader
  13337. */
  13338. applyToShader(effect: Effect): void;
  13339. /**
  13340. * Returns a string to use to update the GPU particles update shader
  13341. * @returns a string containng the defines string
  13342. */
  13343. getEffectDefines(): string;
  13344. /**
  13345. * Returns the string "BoxParticleEmitter"
  13346. * @returns a string containing the class name
  13347. */
  13348. getClassName(): string;
  13349. /**
  13350. * Serializes the particle system to a JSON object.
  13351. * @returns the JSON object
  13352. */
  13353. serialize(): any;
  13354. /**
  13355. * Parse properties from a JSON object
  13356. * @param serializationObject defines the JSON object
  13357. */
  13358. parse(serializationObject: any): void;
  13359. }
  13360. }
  13361. declare module BABYLON {
  13362. /**
  13363. * Particle emitter emitting particles from the inside of a cone.
  13364. * It emits the particles alongside the cone volume from the base to the particle.
  13365. * The emission direction might be randomized.
  13366. */
  13367. export class ConeParticleEmitter implements IParticleEmitterType {
  13368. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13369. directionRandomizer: number;
  13370. private _radius;
  13371. private _angle;
  13372. private _height;
  13373. /**
  13374. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  13375. */
  13376. radiusRange: number;
  13377. /**
  13378. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  13379. */
  13380. heightRange: number;
  13381. /**
  13382. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  13383. */
  13384. emitFromSpawnPointOnly: boolean;
  13385. /**
  13386. * Gets or sets the radius of the emission cone
  13387. */
  13388. get radius(): number;
  13389. set radius(value: number);
  13390. /**
  13391. * Gets or sets the angle of the emission cone
  13392. */
  13393. get angle(): number;
  13394. set angle(value: number);
  13395. private _buildHeight;
  13396. /**
  13397. * Creates a new instance ConeParticleEmitter
  13398. * @param radius the radius of the emission cone (1 by default)
  13399. * @param angle the cone base angle (PI by default)
  13400. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  13401. */
  13402. constructor(radius?: number, angle?: number,
  13403. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13404. directionRandomizer?: number);
  13405. /**
  13406. * Called by the particle System when the direction is computed for the created particle.
  13407. * @param worldMatrix is the world matrix of the particle system
  13408. * @param directionToUpdate is the direction vector to update with the result
  13409. * @param particle is the particle we are computed the direction for
  13410. * @param isLocal defines if the direction should be set in local space
  13411. */
  13412. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13413. /**
  13414. * Called by the particle System when the position is computed for the created particle.
  13415. * @param worldMatrix is the world matrix of the particle system
  13416. * @param positionToUpdate is the position vector to update with the result
  13417. * @param particle is the particle we are computed the position for
  13418. * @param isLocal defines if the position should be set in local space
  13419. */
  13420. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13421. /**
  13422. * Clones the current emitter and returns a copy of it
  13423. * @returns the new emitter
  13424. */
  13425. clone(): ConeParticleEmitter;
  13426. /**
  13427. * Called by the GPUParticleSystem to setup the update shader
  13428. * @param effect defines the update shader
  13429. */
  13430. applyToShader(effect: Effect): void;
  13431. /**
  13432. * Returns a string to use to update the GPU particles update shader
  13433. * @returns a string containng the defines string
  13434. */
  13435. getEffectDefines(): string;
  13436. /**
  13437. * Returns the string "ConeParticleEmitter"
  13438. * @returns a string containing the class name
  13439. */
  13440. getClassName(): string;
  13441. /**
  13442. * Serializes the particle system to a JSON object.
  13443. * @returns the JSON object
  13444. */
  13445. serialize(): any;
  13446. /**
  13447. * Parse properties from a JSON object
  13448. * @param serializationObject defines the JSON object
  13449. */
  13450. parse(serializationObject: any): void;
  13451. }
  13452. }
  13453. declare module BABYLON {
  13454. /**
  13455. * Particle emitter emitting particles from the inside of a cylinder.
  13456. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  13457. */
  13458. export class CylinderParticleEmitter implements IParticleEmitterType {
  13459. /**
  13460. * The radius of the emission cylinder.
  13461. */
  13462. radius: number;
  13463. /**
  13464. * The height of the emission cylinder.
  13465. */
  13466. height: number;
  13467. /**
  13468. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13469. */
  13470. radiusRange: number;
  13471. /**
  13472. * How much to randomize the particle direction [0-1].
  13473. */
  13474. directionRandomizer: number;
  13475. /**
  13476. * Creates a new instance CylinderParticleEmitter
  13477. * @param radius the radius of the emission cylinder (1 by default)
  13478. * @param height the height of the emission cylinder (1 by default)
  13479. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13480. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13481. */
  13482. constructor(
  13483. /**
  13484. * The radius of the emission cylinder.
  13485. */
  13486. radius?: number,
  13487. /**
  13488. * The height of the emission cylinder.
  13489. */
  13490. height?: number,
  13491. /**
  13492. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13493. */
  13494. radiusRange?: number,
  13495. /**
  13496. * How much to randomize the particle direction [0-1].
  13497. */
  13498. directionRandomizer?: number);
  13499. /**
  13500. * Called by the particle System when the direction is computed for the created particle.
  13501. * @param worldMatrix is the world matrix of the particle system
  13502. * @param directionToUpdate is the direction vector to update with the result
  13503. * @param particle is the particle we are computed the direction for
  13504. * @param isLocal defines if the direction should be set in local space
  13505. */
  13506. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13507. /**
  13508. * Called by the particle System when the position is computed for the created particle.
  13509. * @param worldMatrix is the world matrix of the particle system
  13510. * @param positionToUpdate is the position vector to update with the result
  13511. * @param particle is the particle we are computed the position for
  13512. * @param isLocal defines if the position should be set in local space
  13513. */
  13514. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13515. /**
  13516. * Clones the current emitter and returns a copy of it
  13517. * @returns the new emitter
  13518. */
  13519. clone(): CylinderParticleEmitter;
  13520. /**
  13521. * Called by the GPUParticleSystem to setup the update shader
  13522. * @param effect defines the update shader
  13523. */
  13524. applyToShader(effect: Effect): void;
  13525. /**
  13526. * Returns a string to use to update the GPU particles update shader
  13527. * @returns a string containng the defines string
  13528. */
  13529. getEffectDefines(): string;
  13530. /**
  13531. * Returns the string "CylinderParticleEmitter"
  13532. * @returns a string containing the class name
  13533. */
  13534. getClassName(): string;
  13535. /**
  13536. * Serializes the particle system to a JSON object.
  13537. * @returns the JSON object
  13538. */
  13539. serialize(): any;
  13540. /**
  13541. * Parse properties from a JSON object
  13542. * @param serializationObject defines the JSON object
  13543. */
  13544. parse(serializationObject: any): void;
  13545. }
  13546. /**
  13547. * Particle emitter emitting particles from the inside of a cylinder.
  13548. * It emits the particles randomly between two vectors.
  13549. */
  13550. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  13551. /**
  13552. * The min limit of the emission direction.
  13553. */
  13554. direction1: Vector3;
  13555. /**
  13556. * The max limit of the emission direction.
  13557. */
  13558. direction2: Vector3;
  13559. /**
  13560. * Creates a new instance CylinderDirectedParticleEmitter
  13561. * @param radius the radius of the emission cylinder (1 by default)
  13562. * @param height the height of the emission cylinder (1 by default)
  13563. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13564. * @param direction1 the min limit of the emission direction (up vector by default)
  13565. * @param direction2 the max limit of the emission direction (up vector by default)
  13566. */
  13567. constructor(radius?: number, height?: number, radiusRange?: number,
  13568. /**
  13569. * The min limit of the emission direction.
  13570. */
  13571. direction1?: Vector3,
  13572. /**
  13573. * The max limit of the emission direction.
  13574. */
  13575. direction2?: Vector3);
  13576. /**
  13577. * Called by the particle System when the direction is computed for the created particle.
  13578. * @param worldMatrix is the world matrix of the particle system
  13579. * @param directionToUpdate is the direction vector to update with the result
  13580. * @param particle is the particle we are computed the direction for
  13581. */
  13582. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13583. /**
  13584. * Clones the current emitter and returns a copy of it
  13585. * @returns the new emitter
  13586. */
  13587. clone(): CylinderDirectedParticleEmitter;
  13588. /**
  13589. * Called by the GPUParticleSystem to setup the update shader
  13590. * @param effect defines the update shader
  13591. */
  13592. applyToShader(effect: Effect): void;
  13593. /**
  13594. * Returns a string to use to update the GPU particles update shader
  13595. * @returns a string containng the defines string
  13596. */
  13597. getEffectDefines(): string;
  13598. /**
  13599. * Returns the string "CylinderDirectedParticleEmitter"
  13600. * @returns a string containing the class name
  13601. */
  13602. getClassName(): string;
  13603. /**
  13604. * Serializes the particle system to a JSON object.
  13605. * @returns the JSON object
  13606. */
  13607. serialize(): any;
  13608. /**
  13609. * Parse properties from a JSON object
  13610. * @param serializationObject defines the JSON object
  13611. */
  13612. parse(serializationObject: any): void;
  13613. }
  13614. }
  13615. declare module BABYLON {
  13616. /**
  13617. * Particle emitter emitting particles from the inside of a hemisphere.
  13618. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  13619. */
  13620. export class HemisphericParticleEmitter implements IParticleEmitterType {
  13621. /**
  13622. * The radius of the emission hemisphere.
  13623. */
  13624. radius: number;
  13625. /**
  13626. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13627. */
  13628. radiusRange: number;
  13629. /**
  13630. * How much to randomize the particle direction [0-1].
  13631. */
  13632. directionRandomizer: number;
  13633. /**
  13634. * Creates a new instance HemisphericParticleEmitter
  13635. * @param radius the radius of the emission hemisphere (1 by default)
  13636. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13637. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13638. */
  13639. constructor(
  13640. /**
  13641. * The radius of the emission hemisphere.
  13642. */
  13643. radius?: number,
  13644. /**
  13645. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13646. */
  13647. radiusRange?: number,
  13648. /**
  13649. * How much to randomize the particle direction [0-1].
  13650. */
  13651. directionRandomizer?: number);
  13652. /**
  13653. * Called by the particle System when the direction is computed for the created particle.
  13654. * @param worldMatrix is the world matrix of the particle system
  13655. * @param directionToUpdate is the direction vector to update with the result
  13656. * @param particle is the particle we are computed the direction for
  13657. * @param isLocal defines if the direction should be set in local space
  13658. */
  13659. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13660. /**
  13661. * Called by the particle System when the position is computed for the created particle.
  13662. * @param worldMatrix is the world matrix of the particle system
  13663. * @param positionToUpdate is the position vector to update with the result
  13664. * @param particle is the particle we are computed the position for
  13665. * @param isLocal defines if the position should be set in local space
  13666. */
  13667. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13668. /**
  13669. * Clones the current emitter and returns a copy of it
  13670. * @returns the new emitter
  13671. */
  13672. clone(): HemisphericParticleEmitter;
  13673. /**
  13674. * Called by the GPUParticleSystem to setup the update shader
  13675. * @param effect defines the update shader
  13676. */
  13677. applyToShader(effect: Effect): void;
  13678. /**
  13679. * Returns a string to use to update the GPU particles update shader
  13680. * @returns a string containng the defines string
  13681. */
  13682. getEffectDefines(): string;
  13683. /**
  13684. * Returns the string "HemisphericParticleEmitter"
  13685. * @returns a string containing the class name
  13686. */
  13687. getClassName(): string;
  13688. /**
  13689. * Serializes the particle system to a JSON object.
  13690. * @returns the JSON object
  13691. */
  13692. serialize(): any;
  13693. /**
  13694. * Parse properties from a JSON object
  13695. * @param serializationObject defines the JSON object
  13696. */
  13697. parse(serializationObject: any): void;
  13698. }
  13699. }
  13700. declare module BABYLON {
  13701. /**
  13702. * Particle emitter emitting particles from a point.
  13703. * It emits the particles randomly between 2 given directions.
  13704. */
  13705. export class PointParticleEmitter implements IParticleEmitterType {
  13706. /**
  13707. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13708. */
  13709. direction1: Vector3;
  13710. /**
  13711. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13712. */
  13713. direction2: Vector3;
  13714. /**
  13715. * Creates a new instance PointParticleEmitter
  13716. */
  13717. constructor();
  13718. /**
  13719. * Called by the particle System when the direction is computed for the created particle.
  13720. * @param worldMatrix is the world matrix of the particle system
  13721. * @param directionToUpdate is the direction vector to update with the result
  13722. * @param particle is the particle we are computed the direction for
  13723. * @param isLocal defines if the direction should be set in local space
  13724. */
  13725. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13726. /**
  13727. * Called by the particle System when the position is computed for the created particle.
  13728. * @param worldMatrix is the world matrix of the particle system
  13729. * @param positionToUpdate is the position vector to update with the result
  13730. * @param particle is the particle we are computed the position for
  13731. * @param isLocal defines if the position should be set in local space
  13732. */
  13733. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13734. /**
  13735. * Clones the current emitter and returns a copy of it
  13736. * @returns the new emitter
  13737. */
  13738. clone(): PointParticleEmitter;
  13739. /**
  13740. * Called by the GPUParticleSystem to setup the update shader
  13741. * @param effect defines the update shader
  13742. */
  13743. applyToShader(effect: Effect): void;
  13744. /**
  13745. * Returns a string to use to update the GPU particles update shader
  13746. * @returns a string containng the defines string
  13747. */
  13748. getEffectDefines(): string;
  13749. /**
  13750. * Returns the string "PointParticleEmitter"
  13751. * @returns a string containing the class name
  13752. */
  13753. getClassName(): string;
  13754. /**
  13755. * Serializes the particle system to a JSON object.
  13756. * @returns the JSON object
  13757. */
  13758. serialize(): any;
  13759. /**
  13760. * Parse properties from a JSON object
  13761. * @param serializationObject defines the JSON object
  13762. */
  13763. parse(serializationObject: any): void;
  13764. }
  13765. }
  13766. declare module BABYLON {
  13767. /**
  13768. * Particle emitter emitting particles from the inside of a sphere.
  13769. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  13770. */
  13771. export class SphereParticleEmitter implements IParticleEmitterType {
  13772. /**
  13773. * The radius of the emission sphere.
  13774. */
  13775. radius: number;
  13776. /**
  13777. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13778. */
  13779. radiusRange: number;
  13780. /**
  13781. * How much to randomize the particle direction [0-1].
  13782. */
  13783. directionRandomizer: number;
  13784. /**
  13785. * Creates a new instance SphereParticleEmitter
  13786. * @param radius the radius of the emission sphere (1 by default)
  13787. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13788. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13789. */
  13790. constructor(
  13791. /**
  13792. * The radius of the emission sphere.
  13793. */
  13794. radius?: number,
  13795. /**
  13796. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13797. */
  13798. radiusRange?: number,
  13799. /**
  13800. * How much to randomize the particle direction [0-1].
  13801. */
  13802. directionRandomizer?: number);
  13803. /**
  13804. * Called by the particle System when the direction is computed for the created particle.
  13805. * @param worldMatrix is the world matrix of the particle system
  13806. * @param directionToUpdate is the direction vector to update with the result
  13807. * @param particle is the particle we are computed the direction for
  13808. * @param isLocal defines if the direction should be set in local space
  13809. */
  13810. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13811. /**
  13812. * Called by the particle System when the position is computed for the created particle.
  13813. * @param worldMatrix is the world matrix of the particle system
  13814. * @param positionToUpdate is the position vector to update with the result
  13815. * @param particle is the particle we are computed the position for
  13816. * @param isLocal defines if the position should be set in local space
  13817. */
  13818. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13819. /**
  13820. * Clones the current emitter and returns a copy of it
  13821. * @returns the new emitter
  13822. */
  13823. clone(): SphereParticleEmitter;
  13824. /**
  13825. * Called by the GPUParticleSystem to setup the update shader
  13826. * @param effect defines the update shader
  13827. */
  13828. applyToShader(effect: Effect): void;
  13829. /**
  13830. * Returns a string to use to update the GPU particles update shader
  13831. * @returns a string containng the defines string
  13832. */
  13833. getEffectDefines(): string;
  13834. /**
  13835. * Returns the string "SphereParticleEmitter"
  13836. * @returns a string containing the class name
  13837. */
  13838. getClassName(): string;
  13839. /**
  13840. * Serializes the particle system to a JSON object.
  13841. * @returns the JSON object
  13842. */
  13843. serialize(): any;
  13844. /**
  13845. * Parse properties from a JSON object
  13846. * @param serializationObject defines the JSON object
  13847. */
  13848. parse(serializationObject: any): void;
  13849. }
  13850. /**
  13851. * Particle emitter emitting particles from the inside of a sphere.
  13852. * It emits the particles randomly between two vectors.
  13853. */
  13854. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  13855. /**
  13856. * The min limit of the emission direction.
  13857. */
  13858. direction1: Vector3;
  13859. /**
  13860. * The max limit of the emission direction.
  13861. */
  13862. direction2: Vector3;
  13863. /**
  13864. * Creates a new instance SphereDirectedParticleEmitter
  13865. * @param radius the radius of the emission sphere (1 by default)
  13866. * @param direction1 the min limit of the emission direction (up vector by default)
  13867. * @param direction2 the max limit of the emission direction (up vector by default)
  13868. */
  13869. constructor(radius?: number,
  13870. /**
  13871. * The min limit of the emission direction.
  13872. */
  13873. direction1?: Vector3,
  13874. /**
  13875. * The max limit of the emission direction.
  13876. */
  13877. direction2?: Vector3);
  13878. /**
  13879. * Called by the particle System when the direction is computed for the created particle.
  13880. * @param worldMatrix is the world matrix of the particle system
  13881. * @param directionToUpdate is the direction vector to update with the result
  13882. * @param particle is the particle we are computed the direction for
  13883. */
  13884. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13885. /**
  13886. * Clones the current emitter and returns a copy of it
  13887. * @returns the new emitter
  13888. */
  13889. clone(): SphereDirectedParticleEmitter;
  13890. /**
  13891. * Called by the GPUParticleSystem to setup the update shader
  13892. * @param effect defines the update shader
  13893. */
  13894. applyToShader(effect: Effect): void;
  13895. /**
  13896. * Returns a string to use to update the GPU particles update shader
  13897. * @returns a string containng the defines string
  13898. */
  13899. getEffectDefines(): string;
  13900. /**
  13901. * Returns the string "SphereDirectedParticleEmitter"
  13902. * @returns a string containing the class name
  13903. */
  13904. getClassName(): string;
  13905. /**
  13906. * Serializes the particle system to a JSON object.
  13907. * @returns the JSON object
  13908. */
  13909. serialize(): any;
  13910. /**
  13911. * Parse properties from a JSON object
  13912. * @param serializationObject defines the JSON object
  13913. */
  13914. parse(serializationObject: any): void;
  13915. }
  13916. }
  13917. declare module BABYLON {
  13918. /**
  13919. * Particle emitter emitting particles from a custom list of positions.
  13920. */
  13921. export class CustomParticleEmitter implements IParticleEmitterType {
  13922. /**
  13923. * Gets or sets the position generator that will create the inital position of each particle.
  13924. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13925. */
  13926. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  13927. /**
  13928. * Gets or sets the destination generator that will create the final destination of each particle.
  13929. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  13930. */
  13931. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  13932. /**
  13933. * Creates a new instance CustomParticleEmitter
  13934. */
  13935. constructor();
  13936. /**
  13937. * Called by the particle System when the direction is computed for the created particle.
  13938. * @param worldMatrix is the world matrix of the particle system
  13939. * @param directionToUpdate is the direction vector to update with the result
  13940. * @param particle is the particle we are computed the direction for
  13941. * @param isLocal defines if the direction should be set in local space
  13942. */
  13943. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13944. /**
  13945. * Called by the particle System when the position is computed for the created particle.
  13946. * @param worldMatrix is the world matrix of the particle system
  13947. * @param positionToUpdate is the position vector to update with the result
  13948. * @param particle is the particle we are computed the position for
  13949. * @param isLocal defines if the position should be set in local space
  13950. */
  13951. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13952. /**
  13953. * Clones the current emitter and returns a copy of it
  13954. * @returns the new emitter
  13955. */
  13956. clone(): CustomParticleEmitter;
  13957. /**
  13958. * Called by the GPUParticleSystem to setup the update shader
  13959. * @param effect defines the update shader
  13960. */
  13961. applyToShader(effect: Effect): void;
  13962. /**
  13963. * Returns a string to use to update the GPU particles update shader
  13964. * @returns a string containng the defines string
  13965. */
  13966. getEffectDefines(): string;
  13967. /**
  13968. * Returns the string "PointParticleEmitter"
  13969. * @returns a string containing the class name
  13970. */
  13971. getClassName(): string;
  13972. /**
  13973. * Serializes the particle system to a JSON object.
  13974. * @returns the JSON object
  13975. */
  13976. serialize(): any;
  13977. /**
  13978. * Parse properties from a JSON object
  13979. * @param serializationObject defines the JSON object
  13980. */
  13981. parse(serializationObject: any): void;
  13982. }
  13983. }
  13984. declare module BABYLON {
  13985. /**
  13986. * Particle emitter emitting particles from the inside of a box.
  13987. * It emits the particles randomly between 2 given directions.
  13988. */
  13989. export class MeshParticleEmitter implements IParticleEmitterType {
  13990. private _indices;
  13991. private _positions;
  13992. private _normals;
  13993. private _storedNormal;
  13994. private _mesh;
  13995. /**
  13996. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13997. */
  13998. direction1: Vector3;
  13999. /**
  14000. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14001. */
  14002. direction2: Vector3;
  14003. /**
  14004. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  14005. */
  14006. useMeshNormalsForDirection: boolean;
  14007. /** Defines the mesh to use as source */
  14008. get mesh(): Nullable<AbstractMesh>;
  14009. set mesh(value: Nullable<AbstractMesh>);
  14010. /**
  14011. * Creates a new instance MeshParticleEmitter
  14012. * @param mesh defines the mesh to use as source
  14013. */
  14014. constructor(mesh?: Nullable<AbstractMesh>);
  14015. /**
  14016. * Called by the particle System when the direction is computed for the created particle.
  14017. * @param worldMatrix is the world matrix of the particle system
  14018. * @param directionToUpdate is the direction vector to update with the result
  14019. * @param particle is the particle we are computed the direction for
  14020. * @param isLocal defines if the direction should be set in local space
  14021. */
  14022. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14023. /**
  14024. * Called by the particle System when the position is computed for the created particle.
  14025. * @param worldMatrix is the world matrix of the particle system
  14026. * @param positionToUpdate is the position vector to update with the result
  14027. * @param particle is the particle we are computed the position for
  14028. * @param isLocal defines if the position should be set in local space
  14029. */
  14030. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14031. /**
  14032. * Clones the current emitter and returns a copy of it
  14033. * @returns the new emitter
  14034. */
  14035. clone(): MeshParticleEmitter;
  14036. /**
  14037. * Called by the GPUParticleSystem to setup the update shader
  14038. * @param effect defines the update shader
  14039. */
  14040. applyToShader(effect: Effect): void;
  14041. /**
  14042. * Returns a string to use to update the GPU particles update shader
  14043. * @returns a string containng the defines string
  14044. */
  14045. getEffectDefines(): string;
  14046. /**
  14047. * Returns the string "BoxParticleEmitter"
  14048. * @returns a string containing the class name
  14049. */
  14050. getClassName(): string;
  14051. /**
  14052. * Serializes the particle system to a JSON object.
  14053. * @returns the JSON object
  14054. */
  14055. serialize(): any;
  14056. /**
  14057. * Parse properties from a JSON object
  14058. * @param serializationObject defines the JSON object
  14059. * @param scene defines the hosting scene
  14060. */
  14061. parse(serializationObject: any, scene: Nullable<Scene>): void;
  14062. }
  14063. }
  14064. declare module BABYLON {
  14065. /**
  14066. * Interface representing a particle system in Babylon.js.
  14067. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  14068. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  14069. */
  14070. export interface IParticleSystem {
  14071. /**
  14072. * List of animations used by the particle system.
  14073. */
  14074. animations: Animation[];
  14075. /**
  14076. * The id of the Particle system.
  14077. */
  14078. id: string;
  14079. /**
  14080. * The name of the Particle system.
  14081. */
  14082. name: string;
  14083. /**
  14084. * The emitter represents the Mesh or position we are attaching the particle system to.
  14085. */
  14086. emitter: Nullable<AbstractMesh | Vector3>;
  14087. /**
  14088. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14089. */
  14090. isBillboardBased: boolean;
  14091. /**
  14092. * The rendering group used by the Particle system to chose when to render.
  14093. */
  14094. renderingGroupId: number;
  14095. /**
  14096. * The layer mask we are rendering the particles through.
  14097. */
  14098. layerMask: number;
  14099. /**
  14100. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14101. */
  14102. updateSpeed: number;
  14103. /**
  14104. * The amount of time the particle system is running (depends of the overall update speed).
  14105. */
  14106. targetStopDuration: number;
  14107. /**
  14108. * The texture used to render each particle. (this can be a spritesheet)
  14109. */
  14110. particleTexture: Nullable<BaseTexture>;
  14111. /**
  14112. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  14113. */
  14114. blendMode: number;
  14115. /**
  14116. * Minimum life time of emitting particles.
  14117. */
  14118. minLifeTime: number;
  14119. /**
  14120. * Maximum life time of emitting particles.
  14121. */
  14122. maxLifeTime: number;
  14123. /**
  14124. * Minimum Size of emitting particles.
  14125. */
  14126. minSize: number;
  14127. /**
  14128. * Maximum Size of emitting particles.
  14129. */
  14130. maxSize: number;
  14131. /**
  14132. * Minimum scale of emitting particles on X axis.
  14133. */
  14134. minScaleX: number;
  14135. /**
  14136. * Maximum scale of emitting particles on X axis.
  14137. */
  14138. maxScaleX: number;
  14139. /**
  14140. * Minimum scale of emitting particles on Y axis.
  14141. */
  14142. minScaleY: number;
  14143. /**
  14144. * Maximum scale of emitting particles on Y axis.
  14145. */
  14146. maxScaleY: number;
  14147. /**
  14148. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14149. */
  14150. color1: Color4;
  14151. /**
  14152. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14153. */
  14154. color2: Color4;
  14155. /**
  14156. * Color the particle will have at the end of its lifetime.
  14157. */
  14158. colorDead: Color4;
  14159. /**
  14160. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  14161. */
  14162. emitRate: number;
  14163. /**
  14164. * You can use gravity if you want to give an orientation to your particles.
  14165. */
  14166. gravity: Vector3;
  14167. /**
  14168. * Minimum power of emitting particles.
  14169. */
  14170. minEmitPower: number;
  14171. /**
  14172. * Maximum power of emitting particles.
  14173. */
  14174. maxEmitPower: number;
  14175. /**
  14176. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14177. */
  14178. minAngularSpeed: number;
  14179. /**
  14180. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14181. */
  14182. maxAngularSpeed: number;
  14183. /**
  14184. * Gets or sets the minimal initial rotation in radians.
  14185. */
  14186. minInitialRotation: number;
  14187. /**
  14188. * Gets or sets the maximal initial rotation in radians.
  14189. */
  14190. maxInitialRotation: number;
  14191. /**
  14192. * The particle emitter type defines the emitter used by the particle system.
  14193. * It can be for example box, sphere, or cone...
  14194. */
  14195. particleEmitterType: Nullable<IParticleEmitterType>;
  14196. /**
  14197. * Defines the delay in milliseconds before starting the system (0 by default)
  14198. */
  14199. startDelay: number;
  14200. /**
  14201. * 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
  14202. */
  14203. preWarmCycles: number;
  14204. /**
  14205. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  14206. */
  14207. preWarmStepOffset: number;
  14208. /**
  14209. * 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)
  14210. */
  14211. spriteCellChangeSpeed: number;
  14212. /**
  14213. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14214. */
  14215. startSpriteCellID: number;
  14216. /**
  14217. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14218. */
  14219. endSpriteCellID: number;
  14220. /**
  14221. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14222. */
  14223. spriteCellWidth: number;
  14224. /**
  14225. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14226. */
  14227. spriteCellHeight: number;
  14228. /**
  14229. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14230. */
  14231. spriteRandomStartCell: boolean;
  14232. /**
  14233. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  14234. */
  14235. isAnimationSheetEnabled: boolean;
  14236. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14237. translationPivot: Vector2;
  14238. /**
  14239. * Gets or sets a texture used to add random noise to particle positions
  14240. */
  14241. noiseTexture: Nullable<BaseTexture>;
  14242. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14243. noiseStrength: Vector3;
  14244. /**
  14245. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14246. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14247. */
  14248. billboardMode: number;
  14249. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14250. limitVelocityDamping: number;
  14251. /**
  14252. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14253. */
  14254. beginAnimationOnStart: boolean;
  14255. /**
  14256. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14257. */
  14258. beginAnimationFrom: number;
  14259. /**
  14260. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14261. */
  14262. beginAnimationTo: number;
  14263. /**
  14264. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14265. */
  14266. beginAnimationLoop: boolean;
  14267. /**
  14268. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14269. */
  14270. disposeOnStop: boolean;
  14271. /**
  14272. * Specifies if the particles are updated in emitter local space or world space
  14273. */
  14274. isLocal: boolean;
  14275. /** Snippet ID if the particle system was created from the snippet server */
  14276. snippetId: string;
  14277. /** Gets or sets a matrix to use to compute projection */
  14278. defaultProjectionMatrix: Matrix;
  14279. /**
  14280. * Gets the maximum number of particles active at the same time.
  14281. * @returns The max number of active particles.
  14282. */
  14283. getCapacity(): number;
  14284. /**
  14285. * Gets the number of particles active at the same time.
  14286. * @returns The number of active particles.
  14287. */
  14288. getActiveCount(): number;
  14289. /**
  14290. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14291. * @returns True if it has been started, otherwise false.
  14292. */
  14293. isStarted(): boolean;
  14294. /**
  14295. * Animates the particle system for this frame.
  14296. */
  14297. animate(): void;
  14298. /**
  14299. * Renders the particle system in its current state.
  14300. * @returns the current number of particles
  14301. */
  14302. render(): number;
  14303. /**
  14304. * Dispose the particle system and frees its associated resources.
  14305. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14306. */
  14307. dispose(disposeTexture?: boolean): void;
  14308. /**
  14309. * An event triggered when the system is disposed
  14310. */
  14311. onDisposeObservable: Observable<IParticleSystem>;
  14312. /**
  14313. * An event triggered when the system is stopped
  14314. */
  14315. onStoppedObservable: Observable<IParticleSystem>;
  14316. /**
  14317. * Clones the particle system.
  14318. * @param name The name of the cloned object
  14319. * @param newEmitter The new emitter to use
  14320. * @returns the cloned particle system
  14321. */
  14322. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  14323. /**
  14324. * Serializes the particle system to a JSON object
  14325. * @param serializeTexture defines if the texture must be serialized as well
  14326. * @returns the JSON object
  14327. */
  14328. serialize(serializeTexture: boolean): any;
  14329. /**
  14330. * Rebuild the particle system
  14331. */
  14332. rebuild(): void;
  14333. /** Force the system to rebuild all gradients that need to be resync */
  14334. forceRefreshGradients(): void;
  14335. /**
  14336. * Starts the particle system and begins to emit
  14337. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  14338. */
  14339. start(delay?: number): void;
  14340. /**
  14341. * Stops the particle system.
  14342. */
  14343. stop(): void;
  14344. /**
  14345. * Remove all active particles
  14346. */
  14347. reset(): void;
  14348. /**
  14349. * Gets a boolean indicating that the system is stopping
  14350. * @returns true if the system is currently stopping
  14351. */
  14352. isStopping(): boolean;
  14353. /**
  14354. * Is this system ready to be used/rendered
  14355. * @return true if the system is ready
  14356. */
  14357. isReady(): boolean;
  14358. /**
  14359. * Returns the string "ParticleSystem"
  14360. * @returns a string containing the class name
  14361. */
  14362. getClassName(): string;
  14363. /**
  14364. * Gets the custom effect used to render the particles
  14365. * @param blendMode Blend mode for which the effect should be retrieved
  14366. * @returns The effect
  14367. */
  14368. getCustomEffect(blendMode: number): Nullable<Effect>;
  14369. /**
  14370. * Sets the custom effect used to render the particles
  14371. * @param effect The effect to set
  14372. * @param blendMode Blend mode for which the effect should be set
  14373. */
  14374. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  14375. /**
  14376. * Fill the defines array according to the current settings of the particle system
  14377. * @param defines Array to be updated
  14378. * @param blendMode blend mode to take into account when updating the array
  14379. */
  14380. fillDefines(defines: Array<string>, blendMode: number): void;
  14381. /**
  14382. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  14383. * @param uniforms Uniforms array to fill
  14384. * @param attributes Attributes array to fill
  14385. * @param samplers Samplers array to fill
  14386. */
  14387. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  14388. /**
  14389. * Observable that will be called just before the particles are drawn
  14390. */
  14391. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  14392. /**
  14393. * Gets the name of the particle vertex shader
  14394. */
  14395. vertexShaderName: string;
  14396. /**
  14397. * Adds a new color gradient
  14398. * @param gradient defines the gradient to use (between 0 and 1)
  14399. * @param color1 defines the color to affect to the specified gradient
  14400. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14401. * @returns the current particle system
  14402. */
  14403. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14404. /**
  14405. * Remove a specific color gradient
  14406. * @param gradient defines the gradient to remove
  14407. * @returns the current particle system
  14408. */
  14409. removeColorGradient(gradient: number): IParticleSystem;
  14410. /**
  14411. * Adds a new size gradient
  14412. * @param gradient defines the gradient to use (between 0 and 1)
  14413. * @param factor defines the size factor to affect to the specified gradient
  14414. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14415. * @returns the current particle system
  14416. */
  14417. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14418. /**
  14419. * Remove a specific size gradient
  14420. * @param gradient defines the gradient to remove
  14421. * @returns the current particle system
  14422. */
  14423. removeSizeGradient(gradient: number): IParticleSystem;
  14424. /**
  14425. * Gets the current list of color gradients.
  14426. * You must use addColorGradient and removeColorGradient to udpate this list
  14427. * @returns the list of color gradients
  14428. */
  14429. getColorGradients(): Nullable<Array<ColorGradient>>;
  14430. /**
  14431. * Gets the current list of size gradients.
  14432. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14433. * @returns the list of size gradients
  14434. */
  14435. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14436. /**
  14437. * Gets the current list of angular speed gradients.
  14438. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14439. * @returns the list of angular speed gradients
  14440. */
  14441. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14442. /**
  14443. * Adds a new angular speed gradient
  14444. * @param gradient defines the gradient to use (between 0 and 1)
  14445. * @param factor defines the angular speed 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. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14450. /**
  14451. * Remove a specific angular speed gradient
  14452. * @param gradient defines the gradient to remove
  14453. * @returns the current particle system
  14454. */
  14455. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14456. /**
  14457. * Gets the current list of velocity gradients.
  14458. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14459. * @returns the list of velocity gradients
  14460. */
  14461. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14462. /**
  14463. * Adds a new velocity gradient
  14464. * @param gradient defines the gradient to use (between 0 and 1)
  14465. * @param factor defines the velocity 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. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14470. /**
  14471. * Remove a specific velocity gradient
  14472. * @param gradient defines the gradient to remove
  14473. * @returns the current particle system
  14474. */
  14475. removeVelocityGradient(gradient: number): IParticleSystem;
  14476. /**
  14477. * Gets the current list of limit velocity gradients.
  14478. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14479. * @returns the list of limit velocity gradients
  14480. */
  14481. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14482. /**
  14483. * Adds a new limit velocity gradient
  14484. * @param gradient defines the gradient to use (between 0 and 1)
  14485. * @param factor defines the limit velocity to affect to the specified gradient
  14486. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14487. * @returns the current particle system
  14488. */
  14489. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14490. /**
  14491. * Remove a specific limit velocity gradient
  14492. * @param gradient defines the gradient to remove
  14493. * @returns the current particle system
  14494. */
  14495. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14496. /**
  14497. * Adds a new drag gradient
  14498. * @param gradient defines the gradient to use (between 0 and 1)
  14499. * @param factor defines the drag to affect to the specified gradient
  14500. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14501. * @returns the current particle system
  14502. */
  14503. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14504. /**
  14505. * Remove a specific drag gradient
  14506. * @param gradient defines the gradient to remove
  14507. * @returns the current particle system
  14508. */
  14509. removeDragGradient(gradient: number): IParticleSystem;
  14510. /**
  14511. * Gets the current list of drag gradients.
  14512. * You must use addDragGradient and removeDragGradient to udpate this list
  14513. * @returns the list of drag gradients
  14514. */
  14515. getDragGradients(): Nullable<Array<FactorGradient>>;
  14516. /**
  14517. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14518. * @param gradient defines the gradient to use (between 0 and 1)
  14519. * @param factor defines the emit rate to affect to the specified gradient
  14520. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14521. * @returns the current particle system
  14522. */
  14523. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14524. /**
  14525. * Remove a specific emit rate gradient
  14526. * @param gradient defines the gradient to remove
  14527. * @returns the current particle system
  14528. */
  14529. removeEmitRateGradient(gradient: number): IParticleSystem;
  14530. /**
  14531. * Gets the current list of emit rate gradients.
  14532. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14533. * @returns the list of emit rate gradients
  14534. */
  14535. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14536. /**
  14537. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14538. * @param gradient defines the gradient to use (between 0 and 1)
  14539. * @param factor defines the start size to affect to the specified gradient
  14540. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14541. * @returns the current particle system
  14542. */
  14543. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14544. /**
  14545. * Remove a specific start size gradient
  14546. * @param gradient defines the gradient to remove
  14547. * @returns the current particle system
  14548. */
  14549. removeStartSizeGradient(gradient: number): IParticleSystem;
  14550. /**
  14551. * Gets the current list of start size gradients.
  14552. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14553. * @returns the list of start size gradients
  14554. */
  14555. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14556. /**
  14557. * Adds a new life time gradient
  14558. * @param gradient defines the gradient to use (between 0 and 1)
  14559. * @param factor defines the life time factor to affect to the specified gradient
  14560. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14561. * @returns the current particle system
  14562. */
  14563. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14564. /**
  14565. * Remove a specific life time gradient
  14566. * @param gradient defines the gradient to remove
  14567. * @returns the current particle system
  14568. */
  14569. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14570. /**
  14571. * Gets the current list of life time gradients.
  14572. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14573. * @returns the list of life time gradients
  14574. */
  14575. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14576. /**
  14577. * Gets the current list of color gradients.
  14578. * You must use addColorGradient and removeColorGradient to udpate this list
  14579. * @returns the list of color gradients
  14580. */
  14581. getColorGradients(): Nullable<Array<ColorGradient>>;
  14582. /**
  14583. * Adds a new ramp gradient used to remap particle colors
  14584. * @param gradient defines the gradient to use (between 0 and 1)
  14585. * @param color defines the color to affect to the specified gradient
  14586. * @returns the current particle system
  14587. */
  14588. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  14589. /**
  14590. * Gets the current list of ramp gradients.
  14591. * You must use addRampGradient and removeRampGradient to udpate this list
  14592. * @returns the list of ramp gradients
  14593. */
  14594. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14595. /** Gets or sets a boolean indicating that ramp gradients must be used
  14596. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14597. */
  14598. useRampGradients: boolean;
  14599. /**
  14600. * Adds a new color remap gradient
  14601. * @param gradient defines the gradient to use (between 0 and 1)
  14602. * @param min defines the color remap minimal range
  14603. * @param max defines the color remap maximal range
  14604. * @returns the current particle system
  14605. */
  14606. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14607. /**
  14608. * Gets the current list of color remap gradients.
  14609. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14610. * @returns the list of color remap gradients
  14611. */
  14612. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14613. /**
  14614. * Adds a new alpha remap gradient
  14615. * @param gradient defines the gradient to use (between 0 and 1)
  14616. * @param min defines the alpha remap minimal range
  14617. * @param max defines the alpha remap maximal range
  14618. * @returns the current particle system
  14619. */
  14620. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14621. /**
  14622. * Gets the current list of alpha remap gradients.
  14623. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14624. * @returns the list of alpha remap gradients
  14625. */
  14626. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14627. /**
  14628. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14629. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14630. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14631. * @returns the emitter
  14632. */
  14633. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14634. /**
  14635. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14636. * @param radius The radius of the hemisphere to emit from
  14637. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14638. * @returns the emitter
  14639. */
  14640. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  14641. /**
  14642. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14643. * @param radius The radius of the sphere to emit from
  14644. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14645. * @returns the emitter
  14646. */
  14647. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  14648. /**
  14649. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14650. * @param radius The radius of the sphere to emit from
  14651. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14652. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14653. * @returns the emitter
  14654. */
  14655. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14656. /**
  14657. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14658. * @param radius The radius of the emission cylinder
  14659. * @param height The height of the emission cylinder
  14660. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14661. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14662. * @returns the emitter
  14663. */
  14664. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  14665. /**
  14666. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14667. * @param radius The radius of the cylinder to emit from
  14668. * @param height The height of the emission cylinder
  14669. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14670. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14671. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14672. * @returns the emitter
  14673. */
  14674. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  14675. /**
  14676. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14677. * @param radius The radius of the cone to emit from
  14678. * @param angle The base angle of the cone
  14679. * @returns the emitter
  14680. */
  14681. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  14682. /**
  14683. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14684. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14685. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14686. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14687. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14688. * @returns the emitter
  14689. */
  14690. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14691. /**
  14692. * Get hosting scene
  14693. * @returns the scene
  14694. */
  14695. getScene(): Nullable<Scene>;
  14696. }
  14697. }
  14698. declare module BABYLON {
  14699. /**
  14700. * 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.
  14701. * @see https://doc.babylonjs.com/how_to/transformnode
  14702. */
  14703. export class TransformNode extends Node {
  14704. /**
  14705. * Object will not rotate to face the camera
  14706. */
  14707. static BILLBOARDMODE_NONE: number;
  14708. /**
  14709. * Object will rotate to face the camera but only on the x axis
  14710. */
  14711. static BILLBOARDMODE_X: number;
  14712. /**
  14713. * Object will rotate to face the camera but only on the y axis
  14714. */
  14715. static BILLBOARDMODE_Y: number;
  14716. /**
  14717. * Object will rotate to face the camera but only on the z axis
  14718. */
  14719. static BILLBOARDMODE_Z: number;
  14720. /**
  14721. * Object will rotate to face the camera
  14722. */
  14723. static BILLBOARDMODE_ALL: number;
  14724. /**
  14725. * Object will rotate to face the camera's position instead of orientation
  14726. */
  14727. static BILLBOARDMODE_USE_POSITION: number;
  14728. private static _TmpRotation;
  14729. private static _TmpScaling;
  14730. private static _TmpTranslation;
  14731. private _forward;
  14732. private _forwardInverted;
  14733. private _up;
  14734. private _right;
  14735. private _rightInverted;
  14736. private _position;
  14737. private _rotation;
  14738. private _rotationQuaternion;
  14739. protected _scaling: Vector3;
  14740. protected _isDirty: boolean;
  14741. private _transformToBoneReferal;
  14742. private _isAbsoluteSynced;
  14743. private _billboardMode;
  14744. /**
  14745. * Gets or sets the billboard mode. Default is 0.
  14746. *
  14747. * | Value | Type | Description |
  14748. * | --- | --- | --- |
  14749. * | 0 | BILLBOARDMODE_NONE | |
  14750. * | 1 | BILLBOARDMODE_X | |
  14751. * | 2 | BILLBOARDMODE_Y | |
  14752. * | 4 | BILLBOARDMODE_Z | |
  14753. * | 7 | BILLBOARDMODE_ALL | |
  14754. *
  14755. */
  14756. get billboardMode(): number;
  14757. set billboardMode(value: number);
  14758. private _preserveParentRotationForBillboard;
  14759. /**
  14760. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14761. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14762. */
  14763. get preserveParentRotationForBillboard(): boolean;
  14764. set preserveParentRotationForBillboard(value: boolean);
  14765. /**
  14766. * 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
  14767. */
  14768. scalingDeterminant: number;
  14769. private _infiniteDistance;
  14770. /**
  14771. * Gets or sets the distance of the object to max, often used by skybox
  14772. */
  14773. get infiniteDistance(): boolean;
  14774. set infiniteDistance(value: boolean);
  14775. /**
  14776. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14777. * By default the system will update normals to compensate
  14778. */
  14779. ignoreNonUniformScaling: boolean;
  14780. /**
  14781. * 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
  14782. */
  14783. reIntegrateRotationIntoRotationQuaternion: boolean;
  14784. /** @hidden */
  14785. _poseMatrix: Nullable<Matrix>;
  14786. /** @hidden */
  14787. _localMatrix: Matrix;
  14788. private _usePivotMatrix;
  14789. private _absolutePosition;
  14790. private _absoluteScaling;
  14791. private _absoluteRotationQuaternion;
  14792. private _pivotMatrix;
  14793. private _pivotMatrixInverse;
  14794. /** @hidden */
  14795. _postMultiplyPivotMatrix: boolean;
  14796. protected _isWorldMatrixFrozen: boolean;
  14797. /** @hidden */
  14798. _indexInSceneTransformNodesArray: number;
  14799. /**
  14800. * An event triggered after the world matrix is updated
  14801. */
  14802. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14803. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14804. /**
  14805. * Gets a string identifying the name of the class
  14806. * @returns "TransformNode" string
  14807. */
  14808. getClassName(): string;
  14809. /**
  14810. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14811. */
  14812. get position(): Vector3;
  14813. set position(newPosition: Vector3);
  14814. /**
  14815. * 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)).
  14816. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14817. */
  14818. get rotation(): Vector3;
  14819. set rotation(newRotation: Vector3);
  14820. /**
  14821. * 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)).
  14822. */
  14823. get scaling(): Vector3;
  14824. set scaling(newScaling: Vector3);
  14825. /**
  14826. * 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).
  14827. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14828. */
  14829. get rotationQuaternion(): Nullable<Quaternion>;
  14830. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  14831. /**
  14832. * The forward direction of that transform in world space.
  14833. */
  14834. get forward(): Vector3;
  14835. /**
  14836. * The up direction of that transform in world space.
  14837. */
  14838. get up(): Vector3;
  14839. /**
  14840. * The right direction of that transform in world space.
  14841. */
  14842. get right(): Vector3;
  14843. /**
  14844. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14845. * @param matrix the matrix to copy the pose from
  14846. * @returns this TransformNode.
  14847. */
  14848. updatePoseMatrix(matrix: Matrix): TransformNode;
  14849. /**
  14850. * Returns the mesh Pose matrix.
  14851. * @returns the pose matrix
  14852. */
  14853. getPoseMatrix(): Matrix;
  14854. /** @hidden */
  14855. _isSynchronized(): boolean;
  14856. /** @hidden */
  14857. _initCache(): void;
  14858. /**
  14859. * Flag the transform node as dirty (Forcing it to update everything)
  14860. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14861. * @returns this transform node
  14862. */
  14863. markAsDirty(property: string): TransformNode;
  14864. /**
  14865. * Returns the current mesh absolute position.
  14866. * Returns a Vector3.
  14867. */
  14868. get absolutePosition(): Vector3;
  14869. /**
  14870. * Returns the current mesh absolute scaling.
  14871. * Returns a Vector3.
  14872. */
  14873. get absoluteScaling(): Vector3;
  14874. /**
  14875. * Returns the current mesh absolute rotation.
  14876. * Returns a Quaternion.
  14877. */
  14878. get absoluteRotationQuaternion(): Quaternion;
  14879. /**
  14880. * Sets a new matrix to apply before all other transformation
  14881. * @param matrix defines the transform matrix
  14882. * @returns the current TransformNode
  14883. */
  14884. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14885. /**
  14886. * Sets a new pivot matrix to the current node
  14887. * @param matrix defines the new pivot matrix to use
  14888. * @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
  14889. * @returns the current TransformNode
  14890. */
  14891. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14892. /**
  14893. * Returns the mesh pivot matrix.
  14894. * Default : Identity.
  14895. * @returns the matrix
  14896. */
  14897. getPivotMatrix(): Matrix;
  14898. /**
  14899. * Instantiate (when possible) or clone that node with its hierarchy
  14900. * @param newParent defines the new parent to use for the instance (or clone)
  14901. * @param options defines options to configure how copy is done
  14902. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  14903. * @returns an instance (or a clone) of the current node with its hiearchy
  14904. */
  14905. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  14906. doNotInstantiate: boolean;
  14907. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  14908. /**
  14909. * Prevents the World matrix to be computed any longer
  14910. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14911. * @returns the TransformNode.
  14912. */
  14913. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14914. /**
  14915. * Allows back the World matrix computation.
  14916. * @returns the TransformNode.
  14917. */
  14918. unfreezeWorldMatrix(): this;
  14919. /**
  14920. * True if the World matrix has been frozen.
  14921. */
  14922. get isWorldMatrixFrozen(): boolean;
  14923. /**
  14924. * Retuns the mesh absolute position in the World.
  14925. * @returns a Vector3.
  14926. */
  14927. getAbsolutePosition(): Vector3;
  14928. /**
  14929. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14930. * @param absolutePosition the absolute position to set
  14931. * @returns the TransformNode.
  14932. */
  14933. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14934. /**
  14935. * Sets the mesh position in its local space.
  14936. * @param vector3 the position to set in localspace
  14937. * @returns the TransformNode.
  14938. */
  14939. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14940. /**
  14941. * Returns the mesh position in the local space from the current World matrix values.
  14942. * @returns a new Vector3.
  14943. */
  14944. getPositionExpressedInLocalSpace(): Vector3;
  14945. /**
  14946. * Translates the mesh along the passed Vector3 in its local space.
  14947. * @param vector3 the distance to translate in localspace
  14948. * @returns the TransformNode.
  14949. */
  14950. locallyTranslate(vector3: Vector3): TransformNode;
  14951. private static _lookAtVectorCache;
  14952. /**
  14953. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14954. * @param targetPoint the position (must be in same space as current mesh) to look at
  14955. * @param yawCor optional yaw (y-axis) correction in radians
  14956. * @param pitchCor optional pitch (x-axis) correction in radians
  14957. * @param rollCor optional roll (z-axis) correction in radians
  14958. * @param space the choosen space of the target
  14959. * @returns the TransformNode.
  14960. */
  14961. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14962. /**
  14963. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14964. * This Vector3 is expressed in the World space.
  14965. * @param localAxis axis to rotate
  14966. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14967. */
  14968. getDirection(localAxis: Vector3): Vector3;
  14969. /**
  14970. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14971. * localAxis is expressed in the mesh local space.
  14972. * result is computed in the Wordl space from the mesh World matrix.
  14973. * @param localAxis axis to rotate
  14974. * @param result the resulting transformnode
  14975. * @returns this TransformNode.
  14976. */
  14977. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14978. /**
  14979. * Sets this transform node rotation to the given local axis.
  14980. * @param localAxis the axis in local space
  14981. * @param yawCor optional yaw (y-axis) correction in radians
  14982. * @param pitchCor optional pitch (x-axis) correction in radians
  14983. * @param rollCor optional roll (z-axis) correction in radians
  14984. * @returns this TransformNode
  14985. */
  14986. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14987. /**
  14988. * Sets a new pivot point to the current node
  14989. * @param point defines the new pivot point to use
  14990. * @param space defines if the point is in world or local space (local by default)
  14991. * @returns the current TransformNode
  14992. */
  14993. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14994. /**
  14995. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14996. * @returns the pivot point
  14997. */
  14998. getPivotPoint(): Vector3;
  14999. /**
  15000. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  15001. * @param result the vector3 to store the result
  15002. * @returns this TransformNode.
  15003. */
  15004. getPivotPointToRef(result: Vector3): TransformNode;
  15005. /**
  15006. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  15007. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  15008. */
  15009. getAbsolutePivotPoint(): Vector3;
  15010. /**
  15011. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  15012. * @param result vector3 to store the result
  15013. * @returns this TransformNode.
  15014. */
  15015. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  15016. /**
  15017. * Defines the passed node as the parent of the current node.
  15018. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  15019. * @see https://doc.babylonjs.com/how_to/parenting
  15020. * @param node the node ot set as the parent
  15021. * @returns this TransformNode.
  15022. */
  15023. setParent(node: Nullable<Node>): TransformNode;
  15024. private _nonUniformScaling;
  15025. /**
  15026. * True if the scaling property of this object is non uniform eg. (1,2,1)
  15027. */
  15028. get nonUniformScaling(): boolean;
  15029. /** @hidden */
  15030. _updateNonUniformScalingState(value: boolean): boolean;
  15031. /**
  15032. * Attach the current TransformNode to another TransformNode associated with a bone
  15033. * @param bone Bone affecting the TransformNode
  15034. * @param affectedTransformNode TransformNode associated with the bone
  15035. * @returns this object
  15036. */
  15037. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  15038. /**
  15039. * Detach the transform node if its associated with a bone
  15040. * @returns this object
  15041. */
  15042. detachFromBone(): TransformNode;
  15043. private static _rotationAxisCache;
  15044. /**
  15045. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  15046. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15047. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15048. * The passed axis is also normalized.
  15049. * @param axis the axis to rotate around
  15050. * @param amount the amount to rotate in radians
  15051. * @param space Space to rotate in (Default: local)
  15052. * @returns the TransformNode.
  15053. */
  15054. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  15055. /**
  15056. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  15057. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15058. * The passed axis is also normalized. .
  15059. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  15060. * @param point the point to rotate around
  15061. * @param axis the axis to rotate around
  15062. * @param amount the amount to rotate in radians
  15063. * @returns the TransformNode
  15064. */
  15065. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  15066. /**
  15067. * Translates the mesh along the axis vector for the passed distance in the given space.
  15068. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15069. * @param axis the axis to translate in
  15070. * @param distance the distance to translate
  15071. * @param space Space to rotate in (Default: local)
  15072. * @returns the TransformNode.
  15073. */
  15074. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  15075. /**
  15076. * Adds a rotation step to the mesh current rotation.
  15077. * x, y, z are Euler angles expressed in radians.
  15078. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  15079. * This means this rotation is made in the mesh local space only.
  15080. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  15081. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  15082. * ```javascript
  15083. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  15084. * ```
  15085. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  15086. * 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.
  15087. * @param x Rotation to add
  15088. * @param y Rotation to add
  15089. * @param z Rotation to add
  15090. * @returns the TransformNode.
  15091. */
  15092. addRotation(x: number, y: number, z: number): TransformNode;
  15093. /**
  15094. * @hidden
  15095. */
  15096. protected _getEffectiveParent(): Nullable<Node>;
  15097. /**
  15098. * Computes the world matrix of the node
  15099. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15100. * @returns the world matrix
  15101. */
  15102. computeWorldMatrix(force?: boolean): Matrix;
  15103. /**
  15104. * Resets this nodeTransform's local matrix to Matrix.Identity().
  15105. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  15106. */
  15107. resetLocalMatrix(independentOfChildren?: boolean): void;
  15108. protected _afterComputeWorldMatrix(): void;
  15109. /**
  15110. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  15111. * @param func callback function to add
  15112. *
  15113. * @returns the TransformNode.
  15114. */
  15115. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15116. /**
  15117. * Removes a registered callback function.
  15118. * @param func callback function to remove
  15119. * @returns the TransformNode.
  15120. */
  15121. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15122. /**
  15123. * Gets the position of the current mesh in camera space
  15124. * @param camera defines the camera to use
  15125. * @returns a position
  15126. */
  15127. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  15128. /**
  15129. * Returns the distance from the mesh to the active camera
  15130. * @param camera defines the camera to use
  15131. * @returns the distance
  15132. */
  15133. getDistanceToCamera(camera?: Nullable<Camera>): number;
  15134. /**
  15135. * Clone the current transform node
  15136. * @param name Name of the new clone
  15137. * @param newParent New parent for the clone
  15138. * @param doNotCloneChildren Do not clone children hierarchy
  15139. * @returns the new transform node
  15140. */
  15141. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  15142. /**
  15143. * Serializes the objects information.
  15144. * @param currentSerializationObject defines the object to serialize in
  15145. * @returns the serialized object
  15146. */
  15147. serialize(currentSerializationObject?: any): any;
  15148. /**
  15149. * Returns a new TransformNode object parsed from the source provided.
  15150. * @param parsedTransformNode is the source.
  15151. * @param scene the scne the object belongs to
  15152. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  15153. * @returns a new TransformNode object parsed from the source provided.
  15154. */
  15155. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  15156. /**
  15157. * Get all child-transformNodes of this node
  15158. * @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
  15159. * @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
  15160. * @returns an array of TransformNode
  15161. */
  15162. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  15163. /**
  15164. * Releases resources associated with this transform node.
  15165. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  15166. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  15167. */
  15168. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15169. /**
  15170. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  15171. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  15172. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  15173. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  15174. * @returns the current mesh
  15175. */
  15176. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  15177. private _syncAbsoluteScalingAndRotation;
  15178. }
  15179. }
  15180. declare module BABYLON {
  15181. /**
  15182. * Class used to override all child animations of a given target
  15183. */
  15184. export class AnimationPropertiesOverride {
  15185. /**
  15186. * Gets or sets a value indicating if animation blending must be used
  15187. */
  15188. enableBlending: boolean;
  15189. /**
  15190. * Gets or sets the blending speed to use when enableBlending is true
  15191. */
  15192. blendingSpeed: number;
  15193. /**
  15194. * Gets or sets the default loop mode to use
  15195. */
  15196. loopMode: number;
  15197. }
  15198. }
  15199. declare module BABYLON {
  15200. /**
  15201. * Class used to store bone information
  15202. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15203. */
  15204. export class Bone extends Node {
  15205. /**
  15206. * defines the bone name
  15207. */
  15208. name: string;
  15209. private static _tmpVecs;
  15210. private static _tmpQuat;
  15211. private static _tmpMats;
  15212. /**
  15213. * Gets the list of child bones
  15214. */
  15215. children: Bone[];
  15216. /** Gets the animations associated with this bone */
  15217. animations: Animation[];
  15218. /**
  15219. * Gets or sets bone length
  15220. */
  15221. length: number;
  15222. /**
  15223. * @hidden Internal only
  15224. * Set this value to map this bone to a different index in the transform matrices
  15225. * Set this value to -1 to exclude the bone from the transform matrices
  15226. */
  15227. _index: Nullable<number>;
  15228. private _skeleton;
  15229. private _localMatrix;
  15230. private _restPose;
  15231. private _bindPose;
  15232. private _baseMatrix;
  15233. private _absoluteTransform;
  15234. private _invertedAbsoluteTransform;
  15235. private _parent;
  15236. private _scalingDeterminant;
  15237. private _worldTransform;
  15238. private _localScaling;
  15239. private _localRotation;
  15240. private _localPosition;
  15241. private _needToDecompose;
  15242. private _needToCompose;
  15243. /** @hidden */
  15244. _linkedTransformNode: Nullable<TransformNode>;
  15245. /** @hidden */
  15246. _waitingTransformNodeId: Nullable<string>;
  15247. /** @hidden */
  15248. get _matrix(): Matrix;
  15249. /** @hidden */
  15250. set _matrix(value: Matrix);
  15251. /**
  15252. * Create a new bone
  15253. * @param name defines the bone name
  15254. * @param skeleton defines the parent skeleton
  15255. * @param parentBone defines the parent (can be null if the bone is the root)
  15256. * @param localMatrix defines the local matrix
  15257. * @param restPose defines the rest pose matrix
  15258. * @param baseMatrix defines the base matrix
  15259. * @param index defines index of the bone in the hiearchy
  15260. */
  15261. constructor(
  15262. /**
  15263. * defines the bone name
  15264. */
  15265. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  15266. /**
  15267. * Gets the current object class name.
  15268. * @return the class name
  15269. */
  15270. getClassName(): string;
  15271. /**
  15272. * Gets the parent skeleton
  15273. * @returns a skeleton
  15274. */
  15275. getSkeleton(): Skeleton;
  15276. /**
  15277. * Gets parent bone
  15278. * @returns a bone or null if the bone is the root of the bone hierarchy
  15279. */
  15280. getParent(): Nullable<Bone>;
  15281. /**
  15282. * Returns an array containing the root bones
  15283. * @returns an array containing the root bones
  15284. */
  15285. getChildren(): Array<Bone>;
  15286. /**
  15287. * Gets the node index in matrix array generated for rendering
  15288. * @returns the node index
  15289. */
  15290. getIndex(): number;
  15291. /**
  15292. * Sets the parent bone
  15293. * @param parent defines the parent (can be null if the bone is the root)
  15294. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15295. */
  15296. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  15297. /**
  15298. * Gets the local matrix
  15299. * @returns a matrix
  15300. */
  15301. getLocalMatrix(): Matrix;
  15302. /**
  15303. * Gets the base matrix (initial matrix which remains unchanged)
  15304. * @returns a matrix
  15305. */
  15306. getBaseMatrix(): Matrix;
  15307. /**
  15308. * Gets the rest pose matrix
  15309. * @returns a matrix
  15310. */
  15311. getRestPose(): Matrix;
  15312. /**
  15313. * Sets the rest pose matrix
  15314. * @param matrix the local-space rest pose to set for this bone
  15315. */
  15316. setRestPose(matrix: Matrix): void;
  15317. /**
  15318. * Gets the bind pose matrix
  15319. * @returns the bind pose matrix
  15320. */
  15321. getBindPose(): Matrix;
  15322. /**
  15323. * Sets the bind pose matrix
  15324. * @param matrix the local-space bind pose to set for this bone
  15325. */
  15326. setBindPose(matrix: Matrix): void;
  15327. /**
  15328. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  15329. */
  15330. getWorldMatrix(): Matrix;
  15331. /**
  15332. * Sets the local matrix to rest pose matrix
  15333. */
  15334. returnToRest(): void;
  15335. /**
  15336. * Gets the inverse of the absolute transform matrix.
  15337. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  15338. * @returns a matrix
  15339. */
  15340. getInvertedAbsoluteTransform(): Matrix;
  15341. /**
  15342. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  15343. * @returns a matrix
  15344. */
  15345. getAbsoluteTransform(): Matrix;
  15346. /**
  15347. * Links with the given transform node.
  15348. * The local matrix of this bone is copied from the transform node every frame.
  15349. * @param transformNode defines the transform node to link to
  15350. */
  15351. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  15352. /**
  15353. * Gets the node used to drive the bone's transformation
  15354. * @returns a transform node or null
  15355. */
  15356. getTransformNode(): Nullable<TransformNode>;
  15357. /** Gets or sets current position (in local space) */
  15358. get position(): Vector3;
  15359. set position(newPosition: Vector3);
  15360. /** Gets or sets current rotation (in local space) */
  15361. get rotation(): Vector3;
  15362. set rotation(newRotation: Vector3);
  15363. /** Gets or sets current rotation quaternion (in local space) */
  15364. get rotationQuaternion(): Quaternion;
  15365. set rotationQuaternion(newRotation: Quaternion);
  15366. /** Gets or sets current scaling (in local space) */
  15367. get scaling(): Vector3;
  15368. set scaling(newScaling: Vector3);
  15369. /**
  15370. * Gets the animation properties override
  15371. */
  15372. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15373. private _decompose;
  15374. private _compose;
  15375. /**
  15376. * Update the base and local matrices
  15377. * @param matrix defines the new base or local matrix
  15378. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15379. * @param updateLocalMatrix defines if the local matrix should be updated
  15380. */
  15381. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  15382. /** @hidden */
  15383. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  15384. /**
  15385. * Flag the bone as dirty (Forcing it to update everything)
  15386. */
  15387. markAsDirty(): void;
  15388. /** @hidden */
  15389. _markAsDirtyAndCompose(): void;
  15390. private _markAsDirtyAndDecompose;
  15391. /**
  15392. * Translate the bone in local or world space
  15393. * @param vec The amount to translate the bone
  15394. * @param space The space that the translation is in
  15395. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15396. */
  15397. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15398. /**
  15399. * Set the postion of the bone in local or world space
  15400. * @param position The position to set the bone
  15401. * @param space The space that the position is in
  15402. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15403. */
  15404. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15405. /**
  15406. * Set the absolute position of the bone (world space)
  15407. * @param position The position to set the bone
  15408. * @param mesh The mesh that this bone is attached to
  15409. */
  15410. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  15411. /**
  15412. * Scale the bone on the x, y and z axes (in local space)
  15413. * @param x The amount to scale the bone on the x axis
  15414. * @param y The amount to scale the bone on the y axis
  15415. * @param z The amount to scale the bone on the z axis
  15416. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  15417. */
  15418. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  15419. /**
  15420. * Set the bone scaling in local space
  15421. * @param scale defines the scaling vector
  15422. */
  15423. setScale(scale: Vector3): void;
  15424. /**
  15425. * Gets the current scaling in local space
  15426. * @returns the current scaling vector
  15427. */
  15428. getScale(): Vector3;
  15429. /**
  15430. * Gets the current scaling in local space and stores it in a target vector
  15431. * @param result defines the target vector
  15432. */
  15433. getScaleToRef(result: Vector3): void;
  15434. /**
  15435. * Set the yaw, pitch, and roll of the bone in local or world space
  15436. * @param yaw The rotation of the bone on the y axis
  15437. * @param pitch The rotation of the bone on the x axis
  15438. * @param roll The rotation of the bone on the z axis
  15439. * @param space The space that the axes of rotation are in
  15440. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15441. */
  15442. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  15443. /**
  15444. * Add a rotation to the bone on an axis in local or world space
  15445. * @param axis The axis to rotate the bone on
  15446. * @param amount The amount to rotate the bone
  15447. * @param space The space that the axis is in
  15448. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15449. */
  15450. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  15451. /**
  15452. * Set the rotation of the bone to a particular axis angle in local or world space
  15453. * @param axis The axis to rotate the bone on
  15454. * @param angle The angle that the bone should be rotated to
  15455. * @param space The space that the axis is in
  15456. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15457. */
  15458. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  15459. /**
  15460. * Set the euler rotation of the bone in local or world space
  15461. * @param rotation The euler rotation that the bone should be set to
  15462. * @param space The space that the rotation is in
  15463. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15464. */
  15465. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15466. /**
  15467. * Set the quaternion rotation of the bone in local or world space
  15468. * @param quat The quaternion rotation that the bone should be set to
  15469. * @param space The space that the rotation is in
  15470. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15471. */
  15472. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  15473. /**
  15474. * Set the rotation matrix of the bone in local or world space
  15475. * @param rotMat The rotation matrix that the bone should be set to
  15476. * @param space The space that the rotation is in
  15477. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15478. */
  15479. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  15480. private _rotateWithMatrix;
  15481. private _getNegativeRotationToRef;
  15482. /**
  15483. * Get the position of the bone in local or world space
  15484. * @param space The space that the returned position is in
  15485. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15486. * @returns The position of the bone
  15487. */
  15488. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15489. /**
  15490. * Copy the position of the bone to a vector3 in local or world space
  15491. * @param space The space that the returned position is in
  15492. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15493. * @param result The vector3 to copy the position to
  15494. */
  15495. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  15496. /**
  15497. * Get the absolute position of the bone (world space)
  15498. * @param mesh The mesh that this bone is attached to
  15499. * @returns The absolute position of the bone
  15500. */
  15501. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  15502. /**
  15503. * Copy the absolute position of the bone (world space) to the result param
  15504. * @param mesh The mesh that this bone is attached to
  15505. * @param result The vector3 to copy the absolute position to
  15506. */
  15507. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  15508. /**
  15509. * Compute the absolute transforms of this bone and its children
  15510. */
  15511. computeAbsoluteTransforms(): void;
  15512. /**
  15513. * Get the world direction from an axis that is in the local space of the bone
  15514. * @param localAxis The local direction that is used to compute the world direction
  15515. * @param mesh The mesh that this bone is attached to
  15516. * @returns The world direction
  15517. */
  15518. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15519. /**
  15520. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  15521. * @param localAxis The local direction that is used to compute the world direction
  15522. * @param mesh The mesh that this bone is attached to
  15523. * @param result The vector3 that the world direction will be copied to
  15524. */
  15525. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15526. /**
  15527. * Get the euler rotation of the bone in local or world space
  15528. * @param space The space that the rotation should be in
  15529. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15530. * @returns The euler rotation
  15531. */
  15532. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15533. /**
  15534. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  15535. * @param space The space that the rotation should be in
  15536. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15537. * @param result The vector3 that the rotation should be copied to
  15538. */
  15539. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15540. /**
  15541. * Get the quaternion rotation of the bone in either local or world space
  15542. * @param space The space that the rotation should be in
  15543. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15544. * @returns The quaternion rotation
  15545. */
  15546. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  15547. /**
  15548. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  15549. * @param space The space that the rotation should be in
  15550. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15551. * @param result The quaternion that the rotation should be copied to
  15552. */
  15553. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  15554. /**
  15555. * Get the rotation matrix of the bone in local or world space
  15556. * @param space The space that the rotation should be in
  15557. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15558. * @returns The rotation matrix
  15559. */
  15560. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  15561. /**
  15562. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  15563. * @param space The space that the rotation should be in
  15564. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15565. * @param result The quaternion that the rotation should be copied to
  15566. */
  15567. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  15568. /**
  15569. * Get the world position of a point that is in the local space of the bone
  15570. * @param position The local position
  15571. * @param mesh The mesh that this bone is attached to
  15572. * @returns The world position
  15573. */
  15574. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15575. /**
  15576. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  15577. * @param position The local position
  15578. * @param mesh The mesh that this bone is attached to
  15579. * @param result The vector3 that the world position should be copied to
  15580. */
  15581. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15582. /**
  15583. * Get the local position of a point that is in world space
  15584. * @param position The world position
  15585. * @param mesh The mesh that this bone is attached to
  15586. * @returns The local position
  15587. */
  15588. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15589. /**
  15590. * Get the local position of a point that is in world space and copy it to the result param
  15591. * @param position The world position
  15592. * @param mesh The mesh that this bone is attached to
  15593. * @param result The vector3 that the local position should be copied to
  15594. */
  15595. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15596. /**
  15597. * Set the current local matrix as the restPose for this bone.
  15598. */
  15599. setCurrentPoseAsRest(): void;
  15600. }
  15601. }
  15602. declare module BABYLON {
  15603. /**
  15604. * Defines a runtime animation
  15605. */
  15606. export class RuntimeAnimation {
  15607. private _events;
  15608. /**
  15609. * The current frame of the runtime animation
  15610. */
  15611. private _currentFrame;
  15612. /**
  15613. * The animation used by the runtime animation
  15614. */
  15615. private _animation;
  15616. /**
  15617. * The target of the runtime animation
  15618. */
  15619. private _target;
  15620. /**
  15621. * The initiating animatable
  15622. */
  15623. private _host;
  15624. /**
  15625. * The original value of the runtime animation
  15626. */
  15627. private _originalValue;
  15628. /**
  15629. * The original blend value of the runtime animation
  15630. */
  15631. private _originalBlendValue;
  15632. /**
  15633. * The offsets cache of the runtime animation
  15634. */
  15635. private _offsetsCache;
  15636. /**
  15637. * The high limits cache of the runtime animation
  15638. */
  15639. private _highLimitsCache;
  15640. /**
  15641. * Specifies if the runtime animation has been stopped
  15642. */
  15643. private _stopped;
  15644. /**
  15645. * The blending factor of the runtime animation
  15646. */
  15647. private _blendingFactor;
  15648. /**
  15649. * The BabylonJS scene
  15650. */
  15651. private _scene;
  15652. /**
  15653. * The current value of the runtime animation
  15654. */
  15655. private _currentValue;
  15656. /** @hidden */
  15657. _animationState: _IAnimationState;
  15658. /**
  15659. * The active target of the runtime animation
  15660. */
  15661. private _activeTargets;
  15662. private _currentActiveTarget;
  15663. private _directTarget;
  15664. /**
  15665. * The target path of the runtime animation
  15666. */
  15667. private _targetPath;
  15668. /**
  15669. * The weight of the runtime animation
  15670. */
  15671. private _weight;
  15672. /**
  15673. * The ratio offset of the runtime animation
  15674. */
  15675. private _ratioOffset;
  15676. /**
  15677. * The previous delay of the runtime animation
  15678. */
  15679. private _previousDelay;
  15680. /**
  15681. * The previous ratio of the runtime animation
  15682. */
  15683. private _previousRatio;
  15684. private _enableBlending;
  15685. private _keys;
  15686. private _minFrame;
  15687. private _maxFrame;
  15688. private _minValue;
  15689. private _maxValue;
  15690. private _targetIsArray;
  15691. /**
  15692. * Gets the current frame of the runtime animation
  15693. */
  15694. get currentFrame(): number;
  15695. /**
  15696. * Gets the weight of the runtime animation
  15697. */
  15698. get weight(): number;
  15699. /**
  15700. * Gets the current value of the runtime animation
  15701. */
  15702. get currentValue(): any;
  15703. /**
  15704. * Gets the target path of the runtime animation
  15705. */
  15706. get targetPath(): string;
  15707. /**
  15708. * Gets the actual target of the runtime animation
  15709. */
  15710. get target(): any;
  15711. /**
  15712. * Gets the additive state of the runtime animation
  15713. */
  15714. get isAdditive(): boolean;
  15715. /** @hidden */
  15716. _onLoop: () => void;
  15717. /**
  15718. * Create a new RuntimeAnimation object
  15719. * @param target defines the target of the animation
  15720. * @param animation defines the source animation object
  15721. * @param scene defines the hosting scene
  15722. * @param host defines the initiating Animatable
  15723. */
  15724. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  15725. private _preparePath;
  15726. /**
  15727. * Gets the animation from the runtime animation
  15728. */
  15729. get animation(): Animation;
  15730. /**
  15731. * Resets the runtime animation to the beginning
  15732. * @param restoreOriginal defines whether to restore the target property to the original value
  15733. */
  15734. reset(restoreOriginal?: boolean): void;
  15735. /**
  15736. * Specifies if the runtime animation is stopped
  15737. * @returns Boolean specifying if the runtime animation is stopped
  15738. */
  15739. isStopped(): boolean;
  15740. /**
  15741. * Disposes of the runtime animation
  15742. */
  15743. dispose(): void;
  15744. /**
  15745. * Apply the interpolated value to the target
  15746. * @param currentValue defines the value computed by the animation
  15747. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  15748. */
  15749. setValue(currentValue: any, weight: number): void;
  15750. private _getOriginalValues;
  15751. private _setValue;
  15752. /**
  15753. * Gets the loop pmode of the runtime animation
  15754. * @returns Loop Mode
  15755. */
  15756. private _getCorrectLoopMode;
  15757. /**
  15758. * Move the current animation to a given frame
  15759. * @param frame defines the frame to move to
  15760. */
  15761. goToFrame(frame: number): void;
  15762. /**
  15763. * @hidden Internal use only
  15764. */
  15765. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  15766. /**
  15767. * Execute the current animation
  15768. * @param delay defines the delay to add to the current frame
  15769. * @param from defines the lower bound of the animation range
  15770. * @param to defines the upper bound of the animation range
  15771. * @param loop defines if the current animation must loop
  15772. * @param speedRatio defines the current speed ratio
  15773. * @param weight defines the weight of the animation (default is -1 so no weight)
  15774. * @param onLoop optional callback called when animation loops
  15775. * @returns a boolean indicating if the animation is running
  15776. */
  15777. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  15778. }
  15779. }
  15780. declare module BABYLON {
  15781. /**
  15782. * Class used to store an actual running animation
  15783. */
  15784. export class Animatable {
  15785. /** defines the target object */
  15786. target: any;
  15787. /** defines the starting frame number (default is 0) */
  15788. fromFrame: number;
  15789. /** defines the ending frame number (default is 100) */
  15790. toFrame: number;
  15791. /** defines if the animation must loop (default is false) */
  15792. loopAnimation: boolean;
  15793. /** defines a callback to call when animation ends if it is not looping */
  15794. onAnimationEnd?: (() => void) | null | undefined;
  15795. /** defines a callback to call when animation loops */
  15796. onAnimationLoop?: (() => void) | null | undefined;
  15797. /** defines whether the animation should be evaluated additively */
  15798. isAdditive: boolean;
  15799. private _localDelayOffset;
  15800. private _pausedDelay;
  15801. private _runtimeAnimations;
  15802. private _paused;
  15803. private _scene;
  15804. private _speedRatio;
  15805. private _weight;
  15806. private _syncRoot;
  15807. /**
  15808. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  15809. * This will only apply for non looping animation (default is true)
  15810. */
  15811. disposeOnEnd: boolean;
  15812. /**
  15813. * Gets a boolean indicating if the animation has started
  15814. */
  15815. animationStarted: boolean;
  15816. /**
  15817. * Observer raised when the animation ends
  15818. */
  15819. onAnimationEndObservable: Observable<Animatable>;
  15820. /**
  15821. * Observer raised when the animation loops
  15822. */
  15823. onAnimationLoopObservable: Observable<Animatable>;
  15824. /**
  15825. * Gets the root Animatable used to synchronize and normalize animations
  15826. */
  15827. get syncRoot(): Nullable<Animatable>;
  15828. /**
  15829. * Gets the current frame of the first RuntimeAnimation
  15830. * Used to synchronize Animatables
  15831. */
  15832. get masterFrame(): number;
  15833. /**
  15834. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  15835. */
  15836. get weight(): number;
  15837. set weight(value: number);
  15838. /**
  15839. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  15840. */
  15841. get speedRatio(): number;
  15842. set speedRatio(value: number);
  15843. /**
  15844. * Creates a new Animatable
  15845. * @param scene defines the hosting scene
  15846. * @param target defines the target object
  15847. * @param fromFrame defines the starting frame number (default is 0)
  15848. * @param toFrame defines the ending frame number (default is 100)
  15849. * @param loopAnimation defines if the animation must loop (default is false)
  15850. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  15851. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  15852. * @param animations defines a group of animation to add to the new Animatable
  15853. * @param onAnimationLoop defines a callback to call when animation loops
  15854. * @param isAdditive defines whether the animation should be evaluated additively
  15855. */
  15856. constructor(scene: Scene,
  15857. /** defines the target object */
  15858. target: any,
  15859. /** defines the starting frame number (default is 0) */
  15860. fromFrame?: number,
  15861. /** defines the ending frame number (default is 100) */
  15862. toFrame?: number,
  15863. /** defines if the animation must loop (default is false) */
  15864. loopAnimation?: boolean, speedRatio?: number,
  15865. /** defines a callback to call when animation ends if it is not looping */
  15866. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  15867. /** defines a callback to call when animation loops */
  15868. onAnimationLoop?: (() => void) | null | undefined,
  15869. /** defines whether the animation should be evaluated additively */
  15870. isAdditive?: boolean);
  15871. /**
  15872. * Synchronize and normalize current Animatable with a source Animatable
  15873. * This is useful when using animation weights and when animations are not of the same length
  15874. * @param root defines the root Animatable to synchronize with
  15875. * @returns the current Animatable
  15876. */
  15877. syncWith(root: Animatable): Animatable;
  15878. /**
  15879. * Gets the list of runtime animations
  15880. * @returns an array of RuntimeAnimation
  15881. */
  15882. getAnimations(): RuntimeAnimation[];
  15883. /**
  15884. * Adds more animations to the current animatable
  15885. * @param target defines the target of the animations
  15886. * @param animations defines the new animations to add
  15887. */
  15888. appendAnimations(target: any, animations: Animation[]): void;
  15889. /**
  15890. * Gets the source animation for a specific property
  15891. * @param property defines the propertyu to look for
  15892. * @returns null or the source animation for the given property
  15893. */
  15894. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  15895. /**
  15896. * Gets the runtime animation for a specific property
  15897. * @param property defines the propertyu to look for
  15898. * @returns null or the runtime animation for the given property
  15899. */
  15900. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  15901. /**
  15902. * Resets the animatable to its original state
  15903. */
  15904. reset(): void;
  15905. /**
  15906. * Allows the animatable to blend with current running animations
  15907. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  15908. * @param blendingSpeed defines the blending speed to use
  15909. */
  15910. enableBlending(blendingSpeed: number): void;
  15911. /**
  15912. * Disable animation blending
  15913. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  15914. */
  15915. disableBlending(): void;
  15916. /**
  15917. * Jump directly to a given frame
  15918. * @param frame defines the frame to jump to
  15919. */
  15920. goToFrame(frame: number): void;
  15921. /**
  15922. * Pause the animation
  15923. */
  15924. pause(): void;
  15925. /**
  15926. * Restart the animation
  15927. */
  15928. restart(): void;
  15929. private _raiseOnAnimationEnd;
  15930. /**
  15931. * Stop and delete the current animation
  15932. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  15933. * @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)
  15934. */
  15935. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  15936. /**
  15937. * Wait asynchronously for the animation to end
  15938. * @returns a promise which will be fullfilled when the animation ends
  15939. */
  15940. waitAsync(): Promise<Animatable>;
  15941. /** @hidden */
  15942. _animate(delay: number): boolean;
  15943. }
  15944. interface Scene {
  15945. /** @hidden */
  15946. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  15947. /** @hidden */
  15948. _processLateAnimationBindingsForMatrices(holder: {
  15949. totalWeight: number;
  15950. totalAdditiveWeight: number;
  15951. animations: RuntimeAnimation[];
  15952. additiveAnimations: RuntimeAnimation[];
  15953. originalValue: Matrix;
  15954. }): any;
  15955. /** @hidden */
  15956. _processLateAnimationBindingsForQuaternions(holder: {
  15957. totalWeight: number;
  15958. totalAdditiveWeight: number;
  15959. animations: RuntimeAnimation[];
  15960. additiveAnimations: RuntimeAnimation[];
  15961. originalValue: Quaternion;
  15962. }, refQuaternion: Quaternion): Quaternion;
  15963. /** @hidden */
  15964. _processLateAnimationBindings(): void;
  15965. /**
  15966. * Will start the animation sequence of a given target
  15967. * @param target defines the target
  15968. * @param from defines from which frame should animation start
  15969. * @param to defines until which frame should animation run.
  15970. * @param weight defines the weight to apply to the animation (1.0 by default)
  15971. * @param loop defines if the animation loops
  15972. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15973. * @param onAnimationEnd defines the function to be executed when the animation ends
  15974. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15975. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  15976. * @param onAnimationLoop defines the callback to call when an animation loops
  15977. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15978. * @returns the animatable object created for this animation
  15979. */
  15980. 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;
  15981. /**
  15982. * Will start the animation sequence of a given target
  15983. * @param target defines the target
  15984. * @param from defines from which frame should animation start
  15985. * @param to defines until which frame should animation run.
  15986. * @param loop defines if the animation loops
  15987. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  15988. * @param onAnimationEnd defines the function to be executed when the animation ends
  15989. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  15990. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  15991. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  15992. * @param onAnimationLoop defines the callback to call when an animation loops
  15993. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  15994. * @returns the animatable object created for this animation
  15995. */
  15996. 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;
  15997. /**
  15998. * Will start the animation sequence of a given target and its hierarchy
  15999. * @param target defines the target
  16000. * @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.
  16001. * @param from defines from which frame should animation start
  16002. * @param to defines until which frame should animation run.
  16003. * @param loop defines if the animation loops
  16004. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16005. * @param onAnimationEnd defines the function to be executed when the animation ends
  16006. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16007. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16008. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16009. * @param onAnimationLoop defines the callback to call when an animation loops
  16010. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16011. * @returns the list of created animatables
  16012. */
  16013. 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[];
  16014. /**
  16015. * Begin a new animation on a given node
  16016. * @param target defines the target where the animation will take place
  16017. * @param animations defines the list of animations to start
  16018. * @param from defines the initial value
  16019. * @param to defines the final value
  16020. * @param loop defines if you want animation to loop (off by default)
  16021. * @param speedRatio defines the speed ratio to apply to all animations
  16022. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16023. * @param onAnimationLoop defines the callback to call when an animation loops
  16024. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16025. * @returns the list of created animatables
  16026. */
  16027. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  16028. /**
  16029. * Begin a new animation on a given node and its hierarchy
  16030. * @param target defines the root node where the animation will take place
  16031. * @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.
  16032. * @param animations defines the list of animations to start
  16033. * @param from defines the initial value
  16034. * @param to defines the final value
  16035. * @param loop defines if you want animation to loop (off by default)
  16036. * @param speedRatio defines the speed ratio to apply to all animations
  16037. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16038. * @param onAnimationLoop defines the callback to call when an animation loops
  16039. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16040. * @returns the list of animatables created for all nodes
  16041. */
  16042. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  16043. /**
  16044. * Gets the animatable associated with a specific target
  16045. * @param target defines the target of the animatable
  16046. * @returns the required animatable if found
  16047. */
  16048. getAnimatableByTarget(target: any): Nullable<Animatable>;
  16049. /**
  16050. * Gets all animatables associated with a given target
  16051. * @param target defines the target to look animatables for
  16052. * @returns an array of Animatables
  16053. */
  16054. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  16055. /**
  16056. * Stops and removes all animations that have been applied to the scene
  16057. */
  16058. stopAllAnimations(): void;
  16059. /**
  16060. * Gets the current delta time used by animation engine
  16061. */
  16062. deltaTime: number;
  16063. }
  16064. interface Bone {
  16065. /**
  16066. * Copy an animation range from another bone
  16067. * @param source defines the source bone
  16068. * @param rangeName defines the range name to copy
  16069. * @param frameOffset defines the frame offset
  16070. * @param rescaleAsRequired defines if rescaling must be applied if required
  16071. * @param skelDimensionsRatio defines the scaling ratio
  16072. * @returns true if operation was successful
  16073. */
  16074. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  16075. }
  16076. }
  16077. declare module BABYLON {
  16078. /**
  16079. * Class used to handle skinning animations
  16080. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  16081. */
  16082. export class Skeleton implements IAnimatable {
  16083. /** defines the skeleton name */
  16084. name: string;
  16085. /** defines the skeleton Id */
  16086. id: string;
  16087. /**
  16088. * Defines the list of child bones
  16089. */
  16090. bones: Bone[];
  16091. /**
  16092. * Defines an estimate of the dimension of the skeleton at rest
  16093. */
  16094. dimensionsAtRest: Vector3;
  16095. /**
  16096. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  16097. */
  16098. needInitialSkinMatrix: boolean;
  16099. /**
  16100. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  16101. */
  16102. overrideMesh: Nullable<AbstractMesh>;
  16103. /**
  16104. * Gets the list of animations attached to this skeleton
  16105. */
  16106. animations: Array<Animation>;
  16107. private _scene;
  16108. private _isDirty;
  16109. private _transformMatrices;
  16110. private _transformMatrixTexture;
  16111. private _meshesWithPoseMatrix;
  16112. private _animatables;
  16113. private _identity;
  16114. private _synchronizedWithMesh;
  16115. private _ranges;
  16116. private _lastAbsoluteTransformsUpdateId;
  16117. private _canUseTextureForBones;
  16118. private _uniqueId;
  16119. /** @hidden */
  16120. _numBonesWithLinkedTransformNode: number;
  16121. /** @hidden */
  16122. _hasWaitingData: Nullable<boolean>;
  16123. /** @hidden */
  16124. _waitingOverrideMeshId: Nullable<string>;
  16125. /**
  16126. * Specifies if the skeleton should be serialized
  16127. */
  16128. doNotSerialize: boolean;
  16129. private _useTextureToStoreBoneMatrices;
  16130. /**
  16131. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  16132. * Please note that this option is not available if the hardware does not support it
  16133. */
  16134. get useTextureToStoreBoneMatrices(): boolean;
  16135. set useTextureToStoreBoneMatrices(value: boolean);
  16136. private _animationPropertiesOverride;
  16137. /**
  16138. * Gets or sets the animation properties override
  16139. */
  16140. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  16141. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  16142. /**
  16143. * List of inspectable custom properties (used by the Inspector)
  16144. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16145. */
  16146. inspectableCustomProperties: IInspectable[];
  16147. /**
  16148. * An observable triggered before computing the skeleton's matrices
  16149. */
  16150. onBeforeComputeObservable: Observable<Skeleton>;
  16151. /**
  16152. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  16153. */
  16154. get isUsingTextureForMatrices(): boolean;
  16155. /**
  16156. * Gets the unique ID of this skeleton
  16157. */
  16158. get uniqueId(): number;
  16159. /**
  16160. * Creates a new skeleton
  16161. * @param name defines the skeleton name
  16162. * @param id defines the skeleton Id
  16163. * @param scene defines the hosting scene
  16164. */
  16165. constructor(
  16166. /** defines the skeleton name */
  16167. name: string,
  16168. /** defines the skeleton Id */
  16169. id: string, scene: Scene);
  16170. /**
  16171. * Gets the current object class name.
  16172. * @return the class name
  16173. */
  16174. getClassName(): string;
  16175. /**
  16176. * Returns an array containing the root bones
  16177. * @returns an array containing the root bones
  16178. */
  16179. getChildren(): Array<Bone>;
  16180. /**
  16181. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  16182. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16183. * @returns a Float32Array containing matrices data
  16184. */
  16185. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  16186. /**
  16187. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  16188. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16189. * @returns a raw texture containing the data
  16190. */
  16191. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  16192. /**
  16193. * Gets the current hosting scene
  16194. * @returns a scene object
  16195. */
  16196. getScene(): Scene;
  16197. /**
  16198. * Gets a string representing the current skeleton data
  16199. * @param fullDetails defines a boolean indicating if we want a verbose version
  16200. * @returns a string representing the current skeleton data
  16201. */
  16202. toString(fullDetails?: boolean): string;
  16203. /**
  16204. * Get bone's index searching by name
  16205. * @param name defines bone's name to search for
  16206. * @return the indice of the bone. Returns -1 if not found
  16207. */
  16208. getBoneIndexByName(name: string): number;
  16209. /**
  16210. * Creater a new animation range
  16211. * @param name defines the name of the range
  16212. * @param from defines the start key
  16213. * @param to defines the end key
  16214. */
  16215. createAnimationRange(name: string, from: number, to: number): void;
  16216. /**
  16217. * Delete a specific animation range
  16218. * @param name defines the name of the range
  16219. * @param deleteFrames defines if frames must be removed as well
  16220. */
  16221. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  16222. /**
  16223. * Gets a specific animation range
  16224. * @param name defines the name of the range to look for
  16225. * @returns the requested animation range or null if not found
  16226. */
  16227. getAnimationRange(name: string): Nullable<AnimationRange>;
  16228. /**
  16229. * Gets the list of all animation ranges defined on this skeleton
  16230. * @returns an array
  16231. */
  16232. getAnimationRanges(): Nullable<AnimationRange>[];
  16233. /**
  16234. * Copy animation range from a source skeleton.
  16235. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  16236. * @param source defines the source skeleton
  16237. * @param name defines the name of the range to copy
  16238. * @param rescaleAsRequired defines if rescaling must be applied if required
  16239. * @returns true if operation was successful
  16240. */
  16241. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  16242. /**
  16243. * Forces the skeleton to go to rest pose
  16244. */
  16245. returnToRest(): void;
  16246. private _getHighestAnimationFrame;
  16247. /**
  16248. * Begin a specific animation range
  16249. * @param name defines the name of the range to start
  16250. * @param loop defines if looping must be turned on (false by default)
  16251. * @param speedRatio defines the speed ratio to apply (1 by default)
  16252. * @param onAnimationEnd defines a callback which will be called when animation will end
  16253. * @returns a new animatable
  16254. */
  16255. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  16256. /**
  16257. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  16258. * @param skeleton defines the Skeleton containing the animation range to convert
  16259. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  16260. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  16261. * @returns the original skeleton
  16262. */
  16263. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  16264. /** @hidden */
  16265. _markAsDirty(): void;
  16266. /** @hidden */
  16267. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16268. /** @hidden */
  16269. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16270. private _computeTransformMatrices;
  16271. /**
  16272. * Build all resources required to render a skeleton
  16273. */
  16274. prepare(): void;
  16275. /**
  16276. * Gets the list of animatables currently running for this skeleton
  16277. * @returns an array of animatables
  16278. */
  16279. getAnimatables(): IAnimatable[];
  16280. /**
  16281. * Clone the current skeleton
  16282. * @param name defines the name of the new skeleton
  16283. * @param id defines the id of the new skeleton
  16284. * @returns the new skeleton
  16285. */
  16286. clone(name: string, id?: string): Skeleton;
  16287. /**
  16288. * Enable animation blending for this skeleton
  16289. * @param blendingSpeed defines the blending speed to apply
  16290. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16291. */
  16292. enableBlending(blendingSpeed?: number): void;
  16293. /**
  16294. * Releases all resources associated with the current skeleton
  16295. */
  16296. dispose(): void;
  16297. /**
  16298. * Serialize the skeleton in a JSON object
  16299. * @returns a JSON object
  16300. */
  16301. serialize(): any;
  16302. /**
  16303. * Creates a new skeleton from serialized data
  16304. * @param parsedSkeleton defines the serialized data
  16305. * @param scene defines the hosting scene
  16306. * @returns a new skeleton
  16307. */
  16308. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  16309. /**
  16310. * Compute all node absolute transforms
  16311. * @param forceUpdate defines if computation must be done even if cache is up to date
  16312. */
  16313. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  16314. /**
  16315. * Gets the root pose matrix
  16316. * @returns a matrix
  16317. */
  16318. getPoseMatrix(): Nullable<Matrix>;
  16319. /**
  16320. * Sorts bones per internal index
  16321. */
  16322. sortBones(): void;
  16323. private _sortBones;
  16324. /**
  16325. * Set the current local matrix as the restPose for all bones in the skeleton.
  16326. */
  16327. setCurrentPoseAsRest(): void;
  16328. }
  16329. }
  16330. declare module BABYLON {
  16331. /**
  16332. * Creates an instance based on a source mesh.
  16333. */
  16334. export class InstancedMesh extends AbstractMesh {
  16335. private _sourceMesh;
  16336. private _currentLOD;
  16337. /** @hidden */
  16338. _indexInSourceMeshInstanceArray: number;
  16339. constructor(name: string, source: Mesh);
  16340. /**
  16341. * Returns the string "InstancedMesh".
  16342. */
  16343. getClassName(): string;
  16344. /** Gets the list of lights affecting that mesh */
  16345. get lightSources(): Light[];
  16346. _resyncLightSources(): void;
  16347. _resyncLightSource(light: Light): void;
  16348. _removeLightSource(light: Light, dispose: boolean): void;
  16349. /**
  16350. * If the source mesh receives shadows
  16351. */
  16352. get receiveShadows(): boolean;
  16353. /**
  16354. * The material of the source mesh
  16355. */
  16356. get material(): Nullable<Material>;
  16357. /**
  16358. * Visibility of the source mesh
  16359. */
  16360. get visibility(): number;
  16361. /**
  16362. * Skeleton of the source mesh
  16363. */
  16364. get skeleton(): Nullable<Skeleton>;
  16365. /**
  16366. * Rendering ground id of the source mesh
  16367. */
  16368. get renderingGroupId(): number;
  16369. set renderingGroupId(value: number);
  16370. /**
  16371. * Returns the total number of vertices (integer).
  16372. */
  16373. getTotalVertices(): number;
  16374. /**
  16375. * Returns a positive integer : the total number of indices in this mesh geometry.
  16376. * @returns the numner of indices or zero if the mesh has no geometry.
  16377. */
  16378. getTotalIndices(): number;
  16379. /**
  16380. * The source mesh of the instance
  16381. */
  16382. get sourceMesh(): Mesh;
  16383. /**
  16384. * Creates a new InstancedMesh object from the mesh model.
  16385. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  16386. * @param name defines the name of the new instance
  16387. * @returns a new InstancedMesh
  16388. */
  16389. createInstance(name: string): InstancedMesh;
  16390. /**
  16391. * Is this node ready to be used/rendered
  16392. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16393. * @return {boolean} is it ready
  16394. */
  16395. isReady(completeCheck?: boolean): boolean;
  16396. /**
  16397. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16398. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16399. * @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.
  16400. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16401. */
  16402. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16403. /**
  16404. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16405. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16406. * The `data` are either a numeric array either a Float32Array.
  16407. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16408. * 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).
  16409. * Note that a new underlying VertexBuffer object is created each call.
  16410. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16411. *
  16412. * Possible `kind` values :
  16413. * - VertexBuffer.PositionKind
  16414. * - VertexBuffer.UVKind
  16415. * - VertexBuffer.UV2Kind
  16416. * - VertexBuffer.UV3Kind
  16417. * - VertexBuffer.UV4Kind
  16418. * - VertexBuffer.UV5Kind
  16419. * - VertexBuffer.UV6Kind
  16420. * - VertexBuffer.ColorKind
  16421. * - VertexBuffer.MatricesIndicesKind
  16422. * - VertexBuffer.MatricesIndicesExtraKind
  16423. * - VertexBuffer.MatricesWeightsKind
  16424. * - VertexBuffer.MatricesWeightsExtraKind
  16425. *
  16426. * Returns the Mesh.
  16427. */
  16428. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  16429. /**
  16430. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16431. * If the mesh has no geometry, it is simply returned as it is.
  16432. * The `data` are either a numeric array either a Float32Array.
  16433. * No new underlying VertexBuffer object is created.
  16434. * 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.
  16435. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16436. *
  16437. * Possible `kind` values :
  16438. * - VertexBuffer.PositionKind
  16439. * - VertexBuffer.UVKind
  16440. * - VertexBuffer.UV2Kind
  16441. * - VertexBuffer.UV3Kind
  16442. * - VertexBuffer.UV4Kind
  16443. * - VertexBuffer.UV5Kind
  16444. * - VertexBuffer.UV6Kind
  16445. * - VertexBuffer.ColorKind
  16446. * - VertexBuffer.MatricesIndicesKind
  16447. * - VertexBuffer.MatricesIndicesExtraKind
  16448. * - VertexBuffer.MatricesWeightsKind
  16449. * - VertexBuffer.MatricesWeightsExtraKind
  16450. *
  16451. * Returns the Mesh.
  16452. */
  16453. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16454. /**
  16455. * Sets the mesh indices.
  16456. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16457. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16458. * This method creates a new index buffer each call.
  16459. * Returns the Mesh.
  16460. */
  16461. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16462. /**
  16463. * Boolean : True if the mesh owns the requested kind of data.
  16464. */
  16465. isVerticesDataPresent(kind: string): boolean;
  16466. /**
  16467. * Returns an array of indices (IndicesArray).
  16468. */
  16469. getIndices(): Nullable<IndicesArray>;
  16470. get _positions(): Nullable<Vector3[]>;
  16471. /**
  16472. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16473. * This means the mesh underlying bounding box and sphere are recomputed.
  16474. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16475. * @returns the current mesh
  16476. */
  16477. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16478. /** @hidden */
  16479. _preActivate(): InstancedMesh;
  16480. /** @hidden */
  16481. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16482. /** @hidden */
  16483. _postActivate(): void;
  16484. getWorldMatrix(): Matrix;
  16485. get isAnInstance(): boolean;
  16486. /**
  16487. * Returns the current associated LOD AbstractMesh.
  16488. */
  16489. getLOD(camera: Camera): AbstractMesh;
  16490. /** @hidden */
  16491. _preActivateForIntermediateRendering(renderId: number): Mesh;
  16492. /** @hidden */
  16493. _syncSubMeshes(): InstancedMesh;
  16494. /** @hidden */
  16495. _generatePointsArray(): boolean;
  16496. /** @hidden */
  16497. _updateBoundingInfo(): AbstractMesh;
  16498. /**
  16499. * Creates a new InstancedMesh from the current mesh.
  16500. * - name (string) : the cloned mesh name
  16501. * - newParent (optional Node) : the optional Node to parent the clone to.
  16502. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16503. *
  16504. * Returns the clone.
  16505. */
  16506. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  16507. /**
  16508. * Disposes the InstancedMesh.
  16509. * Returns nothing.
  16510. */
  16511. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16512. }
  16513. interface Mesh {
  16514. /**
  16515. * Register a custom buffer that will be instanced
  16516. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16517. * @param kind defines the buffer kind
  16518. * @param stride defines the stride in floats
  16519. */
  16520. registerInstancedBuffer(kind: string, stride: number): void;
  16521. /**
  16522. * true to use the edge renderer for all instances of this mesh
  16523. */
  16524. edgesShareWithInstances: boolean;
  16525. /** @hidden */
  16526. _userInstancedBuffersStorage: {
  16527. data: {
  16528. [key: string]: Float32Array;
  16529. };
  16530. sizes: {
  16531. [key: string]: number;
  16532. };
  16533. vertexBuffers: {
  16534. [key: string]: Nullable<VertexBuffer>;
  16535. };
  16536. strides: {
  16537. [key: string]: number;
  16538. };
  16539. };
  16540. }
  16541. interface AbstractMesh {
  16542. /**
  16543. * Object used to store instanced buffers defined by user
  16544. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16545. */
  16546. instancedBuffers: {
  16547. [key: string]: any;
  16548. };
  16549. }
  16550. }
  16551. declare module BABYLON {
  16552. /**
  16553. * Defines the options associated with the creation of a shader material.
  16554. */
  16555. export interface IShaderMaterialOptions {
  16556. /**
  16557. * Does the material work in alpha blend mode
  16558. */
  16559. needAlphaBlending: boolean;
  16560. /**
  16561. * Does the material work in alpha test mode
  16562. */
  16563. needAlphaTesting: boolean;
  16564. /**
  16565. * The list of attribute names used in the shader
  16566. */
  16567. attributes: string[];
  16568. /**
  16569. * The list of unifrom names used in the shader
  16570. */
  16571. uniforms: string[];
  16572. /**
  16573. * The list of UBO names used in the shader
  16574. */
  16575. uniformBuffers: string[];
  16576. /**
  16577. * The list of sampler names used in the shader
  16578. */
  16579. samplers: string[];
  16580. /**
  16581. * The list of defines used in the shader
  16582. */
  16583. defines: string[];
  16584. }
  16585. /**
  16586. * 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.
  16587. *
  16588. * This returned material effects how the mesh will look based on the code in the shaders.
  16589. *
  16590. * @see https://doc.babylonjs.com/how_to/shader_material
  16591. */
  16592. export class ShaderMaterial extends Material {
  16593. private _shaderPath;
  16594. private _options;
  16595. private _textures;
  16596. private _textureArrays;
  16597. private _floats;
  16598. private _ints;
  16599. private _floatsArrays;
  16600. private _colors3;
  16601. private _colors3Arrays;
  16602. private _colors4;
  16603. private _colors4Arrays;
  16604. private _vectors2;
  16605. private _vectors3;
  16606. private _vectors4;
  16607. private _matrices;
  16608. private _matrixArrays;
  16609. private _matrices3x3;
  16610. private _matrices2x2;
  16611. private _vectors2Arrays;
  16612. private _vectors3Arrays;
  16613. private _vectors4Arrays;
  16614. private _cachedWorldViewMatrix;
  16615. private _cachedWorldViewProjectionMatrix;
  16616. private _renderId;
  16617. private _multiview;
  16618. private _cachedDefines;
  16619. /** Define the Url to load snippets */
  16620. static SnippetUrl: string;
  16621. /** Snippet ID if the material was created from the snippet server */
  16622. snippetId: string;
  16623. /**
  16624. * Instantiate a new shader material.
  16625. * 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.
  16626. * This returned material effects how the mesh will look based on the code in the shaders.
  16627. * @see https://doc.babylonjs.com/how_to/shader_material
  16628. * @param name Define the name of the material in the scene
  16629. * @param scene Define the scene the material belongs to
  16630. * @param shaderPath Defines the route to the shader code in one of three ways:
  16631. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  16632. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  16633. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  16634. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  16635. * @param options Define the options used to create the shader
  16636. */
  16637. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  16638. /**
  16639. * Gets the shader path used to define the shader code
  16640. * It can be modified to trigger a new compilation
  16641. */
  16642. get shaderPath(): any;
  16643. /**
  16644. * Sets the shader path used to define the shader code
  16645. * It can be modified to trigger a new compilation
  16646. */
  16647. set shaderPath(shaderPath: any);
  16648. /**
  16649. * Gets the options used to compile the shader.
  16650. * They can be modified to trigger a new compilation
  16651. */
  16652. get options(): IShaderMaterialOptions;
  16653. /**
  16654. * Gets the current class name of the material e.g. "ShaderMaterial"
  16655. * Mainly use in serialization.
  16656. * @returns the class name
  16657. */
  16658. getClassName(): string;
  16659. /**
  16660. * Specifies if the material will require alpha blending
  16661. * @returns a boolean specifying if alpha blending is needed
  16662. */
  16663. needAlphaBlending(): boolean;
  16664. /**
  16665. * Specifies if this material should be rendered in alpha test mode
  16666. * @returns a boolean specifying if an alpha test is needed.
  16667. */
  16668. needAlphaTesting(): boolean;
  16669. private _checkUniform;
  16670. /**
  16671. * Set a texture in the shader.
  16672. * @param name Define the name of the uniform samplers as defined in the shader
  16673. * @param texture Define the texture to bind to this sampler
  16674. * @return the material itself allowing "fluent" like uniform updates
  16675. */
  16676. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  16677. /**
  16678. * Set a texture array in the shader.
  16679. * @param name Define the name of the uniform sampler array as defined in the shader
  16680. * @param textures Define the list of textures to bind to this sampler
  16681. * @return the material itself allowing "fluent" like uniform updates
  16682. */
  16683. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  16684. /**
  16685. * Set a float in the shader.
  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. setFloat(name: string, value: number): ShaderMaterial;
  16691. /**
  16692. * Set a int in the shader.
  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. setInt(name: string, value: number): ShaderMaterial;
  16698. /**
  16699. * Set an array of floats in the shader.
  16700. * @param name Define the name of the uniform as defined in the shader
  16701. * @param value Define the value to give to the uniform
  16702. * @return the material itself allowing "fluent" like uniform updates
  16703. */
  16704. setFloats(name: string, value: number[]): ShaderMaterial;
  16705. /**
  16706. * Set a vec3 in the shader from a Color3.
  16707. * @param name Define the name of the uniform as defined in the shader
  16708. * @param value Define the value to give to the uniform
  16709. * @return the material itself allowing "fluent" like uniform updates
  16710. */
  16711. setColor3(name: string, value: Color3): ShaderMaterial;
  16712. /**
  16713. * Set a vec3 array in the shader from a Color3 array.
  16714. * @param name Define the name of the uniform as defined in the shader
  16715. * @param value Define the value to give to the uniform
  16716. * @return the material itself allowing "fluent" like uniform updates
  16717. */
  16718. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  16719. /**
  16720. * Set a vec4 in the shader from a Color4.
  16721. * @param name Define the name of the uniform as defined in the shader
  16722. * @param value Define the value to give to the uniform
  16723. * @return the material itself allowing "fluent" like uniform updates
  16724. */
  16725. setColor4(name: string, value: Color4): ShaderMaterial;
  16726. /**
  16727. * Set a vec4 array in the shader from a Color4 array.
  16728. * @param name Define the name of the uniform as defined in the shader
  16729. * @param value Define the value to give to the uniform
  16730. * @return the material itself allowing "fluent" like uniform updates
  16731. */
  16732. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  16733. /**
  16734. * Set a vec2 in the shader from a Vector2.
  16735. * @param name Define the name of the uniform as defined in the shader
  16736. * @param value Define the value to give to the uniform
  16737. * @return the material itself allowing "fluent" like uniform updates
  16738. */
  16739. setVector2(name: string, value: Vector2): ShaderMaterial;
  16740. /**
  16741. * Set a vec3 in the shader from a Vector3.
  16742. * @param name Define the name of the uniform as defined in the shader
  16743. * @param value Define the value to give to the uniform
  16744. * @return the material itself allowing "fluent" like uniform updates
  16745. */
  16746. setVector3(name: string, value: Vector3): ShaderMaterial;
  16747. /**
  16748. * Set a vec4 in the shader from a Vector4.
  16749. * @param name Define the name of the uniform as defined in the shader
  16750. * @param value Define the value to give to the uniform
  16751. * @return the material itself allowing "fluent" like uniform updates
  16752. */
  16753. setVector4(name: string, value: Vector4): ShaderMaterial;
  16754. /**
  16755. * Set a mat4 in the shader from a Matrix.
  16756. * @param name Define the name of the uniform as defined in the shader
  16757. * @param value Define the value to give to the uniform
  16758. * @return the material itself allowing "fluent" like uniform updates
  16759. */
  16760. setMatrix(name: string, value: Matrix): ShaderMaterial;
  16761. /**
  16762. * Set a float32Array in the shader from a matrix array.
  16763. * @param name Define the name of the uniform as defined in the shader
  16764. * @param value Define the value to give to the uniform
  16765. * @return the material itself allowing "fluent" like uniform updates
  16766. */
  16767. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  16768. /**
  16769. * Set a mat3 in the shader from a Float32Array.
  16770. * @param name Define the name of the uniform as defined in the shader
  16771. * @param value Define the value to give to the uniform
  16772. * @return the material itself allowing "fluent" like uniform updates
  16773. */
  16774. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  16775. /**
  16776. * Set a mat2 in the shader from a Float32Array.
  16777. * @param name Define the name of the uniform as defined in the shader
  16778. * @param value Define the value to give to the uniform
  16779. * @return the material itself allowing "fluent" like uniform updates
  16780. */
  16781. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  16782. /**
  16783. * Set a vec2 array in the shader from a number array.
  16784. * @param name Define the name of the uniform as defined in the shader
  16785. * @param value Define the value to give to the uniform
  16786. * @return the material itself allowing "fluent" like uniform updates
  16787. */
  16788. setArray2(name: string, value: number[]): ShaderMaterial;
  16789. /**
  16790. * Set a vec3 array in the shader from a number array.
  16791. * @param name Define the name of the uniform as defined in the shader
  16792. * @param value Define the value to give to the uniform
  16793. * @return the material itself allowing "fluent" like uniform updates
  16794. */
  16795. setArray3(name: string, value: number[]): ShaderMaterial;
  16796. /**
  16797. * Set a vec4 array in the shader from a number array.
  16798. * @param name Define the name of the uniform as defined in the shader
  16799. * @param value Define the value to give to the uniform
  16800. * @return the material itself allowing "fluent" like uniform updates
  16801. */
  16802. setArray4(name: string, value: number[]): ShaderMaterial;
  16803. private _checkCache;
  16804. /**
  16805. * Specifies that the submesh is ready to be used
  16806. * @param mesh defines the mesh to check
  16807. * @param subMesh defines which submesh to check
  16808. * @param useInstances specifies that instances should be used
  16809. * @returns a boolean indicating that the submesh is ready or not
  16810. */
  16811. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  16812. /**
  16813. * Checks if the material is ready to render the requested mesh
  16814. * @param mesh Define the mesh to render
  16815. * @param useInstances Define whether or not the material is used with instances
  16816. * @returns true if ready, otherwise false
  16817. */
  16818. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  16819. /**
  16820. * Binds the world matrix to the material
  16821. * @param world defines the world transformation matrix
  16822. * @param effectOverride - If provided, use this effect instead of internal effect
  16823. */
  16824. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  16825. /**
  16826. * Binds the submesh to this material by preparing the effect and shader to draw
  16827. * @param world defines the world transformation matrix
  16828. * @param mesh defines the mesh containing the submesh
  16829. * @param subMesh defines the submesh to bind the material to
  16830. */
  16831. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  16832. /**
  16833. * Binds the material to the mesh
  16834. * @param world defines the world transformation matrix
  16835. * @param mesh defines the mesh to bind the material to
  16836. * @param effectOverride - If provided, use this effect instead of internal effect
  16837. */
  16838. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  16839. protected _afterBind(mesh?: Mesh): void;
  16840. /**
  16841. * Gets the active textures from the material
  16842. * @returns an array of textures
  16843. */
  16844. getActiveTextures(): BaseTexture[];
  16845. /**
  16846. * Specifies if the material uses a texture
  16847. * @param texture defines the texture to check against the material
  16848. * @returns a boolean specifying if the material uses the texture
  16849. */
  16850. hasTexture(texture: BaseTexture): boolean;
  16851. /**
  16852. * Makes a duplicate of the material, and gives it a new name
  16853. * @param name defines the new name for the duplicated material
  16854. * @returns the cloned material
  16855. */
  16856. clone(name: string): ShaderMaterial;
  16857. /**
  16858. * Disposes the material
  16859. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  16860. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  16861. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  16862. */
  16863. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  16864. /**
  16865. * Serializes this material in a JSON representation
  16866. * @returns the serialized material object
  16867. */
  16868. serialize(): any;
  16869. /**
  16870. * Creates a shader material from parsed shader material data
  16871. * @param source defines the JSON represnetation of the material
  16872. * @param scene defines the hosting scene
  16873. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16874. * @returns a new material
  16875. */
  16876. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  16877. /**
  16878. * Creates a new ShaderMaterial from a snippet saved in a remote file
  16879. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  16880. * @param url defines the url to load from
  16881. * @param scene defines the hosting scene
  16882. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16883. * @returns a promise that will resolve to the new ShaderMaterial
  16884. */
  16885. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  16886. /**
  16887. * Creates a ShaderMaterial from a snippet saved by the Inspector
  16888. * @param snippetId defines the snippet to load
  16889. * @param scene defines the hosting scene
  16890. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  16891. * @returns a promise that will resolve to the new ShaderMaterial
  16892. */
  16893. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  16894. }
  16895. }
  16896. declare module BABYLON {
  16897. /** @hidden */
  16898. export var colorPixelShader: {
  16899. name: string;
  16900. shader: string;
  16901. };
  16902. }
  16903. declare module BABYLON {
  16904. /** @hidden */
  16905. export var colorVertexShader: {
  16906. name: string;
  16907. shader: string;
  16908. };
  16909. }
  16910. declare module BABYLON {
  16911. /**
  16912. * Line mesh
  16913. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  16914. */
  16915. export class LinesMesh extends Mesh {
  16916. /**
  16917. * If vertex color should be applied to the mesh
  16918. */
  16919. readonly useVertexColor?: boolean | undefined;
  16920. /**
  16921. * If vertex alpha should be applied to the mesh
  16922. */
  16923. readonly useVertexAlpha?: boolean | undefined;
  16924. /**
  16925. * Color of the line (Default: White)
  16926. */
  16927. color: Color3;
  16928. /**
  16929. * Alpha of the line (Default: 1)
  16930. */
  16931. alpha: number;
  16932. /**
  16933. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  16934. * This margin is expressed in world space coordinates, so its value may vary.
  16935. * Default value is 0.1
  16936. */
  16937. intersectionThreshold: number;
  16938. private _colorShader;
  16939. private color4;
  16940. /**
  16941. * Creates a new LinesMesh
  16942. * @param name defines the name
  16943. * @param scene defines the hosting scene
  16944. * @param parent defines the parent mesh if any
  16945. * @param source defines the optional source LinesMesh used to clone data from
  16946. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  16947. * When false, achieved by calling a clone(), also passing False.
  16948. * This will make creation of children, recursive.
  16949. * @param useVertexColor defines if this LinesMesh supports vertex color
  16950. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  16951. */
  16952. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  16953. /**
  16954. * If vertex color should be applied to the mesh
  16955. */
  16956. useVertexColor?: boolean | undefined,
  16957. /**
  16958. * If vertex alpha should be applied to the mesh
  16959. */
  16960. useVertexAlpha?: boolean | undefined);
  16961. private _addClipPlaneDefine;
  16962. private _removeClipPlaneDefine;
  16963. isReady(): boolean;
  16964. /**
  16965. * Returns the string "LineMesh"
  16966. */
  16967. getClassName(): string;
  16968. /**
  16969. * @hidden
  16970. */
  16971. get material(): Material;
  16972. /**
  16973. * @hidden
  16974. */
  16975. set material(value: Material);
  16976. /**
  16977. * @hidden
  16978. */
  16979. get checkCollisions(): boolean;
  16980. /** @hidden */
  16981. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  16982. /** @hidden */
  16983. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  16984. /**
  16985. * Disposes of the line mesh
  16986. * @param doNotRecurse If children should be disposed
  16987. */
  16988. dispose(doNotRecurse?: boolean): void;
  16989. /**
  16990. * Returns a new LineMesh object cloned from the current one.
  16991. */
  16992. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  16993. /**
  16994. * Creates a new InstancedLinesMesh object from the mesh model.
  16995. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  16996. * @param name defines the name of the new instance
  16997. * @returns a new InstancedLinesMesh
  16998. */
  16999. createInstance(name: string): InstancedLinesMesh;
  17000. }
  17001. /**
  17002. * Creates an instance based on a source LinesMesh
  17003. */
  17004. export class InstancedLinesMesh extends InstancedMesh {
  17005. /**
  17006. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17007. * This margin is expressed in world space coordinates, so its value may vary.
  17008. * Initilized with the intersectionThreshold value of the source LinesMesh
  17009. */
  17010. intersectionThreshold: number;
  17011. constructor(name: string, source: LinesMesh);
  17012. /**
  17013. * Returns the string "InstancedLinesMesh".
  17014. */
  17015. getClassName(): string;
  17016. }
  17017. }
  17018. declare module BABYLON {
  17019. /** @hidden */
  17020. export var linePixelShader: {
  17021. name: string;
  17022. shader: string;
  17023. };
  17024. }
  17025. declare module BABYLON {
  17026. /** @hidden */
  17027. export var lineVertexShader: {
  17028. name: string;
  17029. shader: string;
  17030. };
  17031. }
  17032. declare module BABYLON {
  17033. interface Scene {
  17034. /** @hidden */
  17035. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  17036. }
  17037. interface AbstractMesh {
  17038. /**
  17039. * Gets the edgesRenderer associated with the mesh
  17040. */
  17041. edgesRenderer: Nullable<EdgesRenderer>;
  17042. }
  17043. interface LinesMesh {
  17044. /**
  17045. * Enables the edge rendering mode on the mesh.
  17046. * This mode makes the mesh edges visible
  17047. * @param epsilon defines the maximal distance between two angles to detect a face
  17048. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17049. * @returns the currentAbstractMesh
  17050. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17051. */
  17052. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17053. }
  17054. interface InstancedLinesMesh {
  17055. /**
  17056. * Enables the edge rendering mode on the mesh.
  17057. * This mode makes the mesh edges visible
  17058. * @param epsilon defines the maximal distance between two angles to detect a face
  17059. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17060. * @returns the current InstancedLinesMesh
  17061. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17062. */
  17063. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17064. }
  17065. /**
  17066. * Defines the minimum contract an Edges renderer should follow.
  17067. */
  17068. export interface IEdgesRenderer extends IDisposable {
  17069. /**
  17070. * Gets or sets a boolean indicating if the edgesRenderer is active
  17071. */
  17072. isEnabled: boolean;
  17073. /**
  17074. * Renders the edges of the attached mesh,
  17075. */
  17076. render(): void;
  17077. /**
  17078. * Checks wether or not the edges renderer is ready to render.
  17079. * @return true if ready, otherwise false.
  17080. */
  17081. isReady(): boolean;
  17082. /**
  17083. * List of instances to render in case the source mesh has instances
  17084. */
  17085. customInstances: SmartArray<Matrix>;
  17086. }
  17087. /**
  17088. * Defines the additional options of the edges renderer
  17089. */
  17090. export interface IEdgesRendererOptions {
  17091. /**
  17092. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  17093. * If not defined, the default value is true
  17094. */
  17095. useAlternateEdgeFinder?: boolean;
  17096. /**
  17097. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  17098. * If not defined, the default value is true.
  17099. * 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)
  17100. * This option is used only if useAlternateEdgeFinder = true
  17101. */
  17102. useFastVertexMerger?: boolean;
  17103. /**
  17104. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  17105. * The default value is 1e-6
  17106. * This option is used only if useAlternateEdgeFinder = true
  17107. */
  17108. epsilonVertexMerge?: number;
  17109. /**
  17110. * 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
  17111. * 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.
  17112. * This option is used only if useAlternateEdgeFinder = true
  17113. */
  17114. applyTessellation?: boolean;
  17115. /**
  17116. * 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
  17117. * The default value is 1e-6
  17118. * This option is used only if useAlternateEdgeFinder = true
  17119. */
  17120. epsilonVertexAligned?: number;
  17121. }
  17122. /**
  17123. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17124. */
  17125. export class EdgesRenderer implements IEdgesRenderer {
  17126. /**
  17127. * Define the size of the edges with an orthographic camera
  17128. */
  17129. edgesWidthScalerForOrthographic: number;
  17130. /**
  17131. * Define the size of the edges with a perspective camera
  17132. */
  17133. edgesWidthScalerForPerspective: number;
  17134. protected _source: AbstractMesh;
  17135. protected _linesPositions: number[];
  17136. protected _linesNormals: number[];
  17137. protected _linesIndices: number[];
  17138. protected _epsilon: number;
  17139. protected _indicesCount: number;
  17140. protected _lineShader: ShaderMaterial;
  17141. protected _ib: DataBuffer;
  17142. protected _buffers: {
  17143. [key: string]: Nullable<VertexBuffer>;
  17144. };
  17145. protected _buffersForInstances: {
  17146. [key: string]: Nullable<VertexBuffer>;
  17147. };
  17148. protected _checkVerticesInsteadOfIndices: boolean;
  17149. protected _options: Nullable<IEdgesRendererOptions>;
  17150. private _meshRebuildObserver;
  17151. private _meshDisposeObserver;
  17152. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17153. isEnabled: boolean;
  17154. /**
  17155. * List of instances to render in case the source mesh has instances
  17156. */
  17157. customInstances: SmartArray<Matrix>;
  17158. private static GetShader;
  17159. /**
  17160. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17161. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17162. * @param source Mesh used to create edges
  17163. * @param epsilon sum of angles in adjacency to check for edge
  17164. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  17165. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17166. * @param options The options to apply when generating the edges
  17167. */
  17168. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  17169. protected _prepareRessources(): void;
  17170. /** @hidden */
  17171. _rebuild(): void;
  17172. /**
  17173. * Releases the required resources for the edges renderer
  17174. */
  17175. dispose(): void;
  17176. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17177. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17178. /**
  17179. * Checks if the pair of p0 and p1 is en edge
  17180. * @param faceIndex
  17181. * @param edge
  17182. * @param faceNormals
  17183. * @param p0
  17184. * @param p1
  17185. * @private
  17186. */
  17187. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17188. /**
  17189. * push line into the position, normal and index buffer
  17190. * @protected
  17191. */
  17192. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17193. /**
  17194. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  17195. */
  17196. private _tessellateTriangle;
  17197. private _generateEdgesLinesAlternate;
  17198. /**
  17199. * Generates lines edges from adjacencjes
  17200. * @private
  17201. */
  17202. _generateEdgesLines(): void;
  17203. /**
  17204. * Checks wether or not the edges renderer is ready to render.
  17205. * @return true if ready, otherwise false.
  17206. */
  17207. isReady(): boolean;
  17208. /**
  17209. * Renders the edges of the attached mesh,
  17210. */
  17211. render(): void;
  17212. }
  17213. /**
  17214. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17215. */
  17216. export class LineEdgesRenderer extends EdgesRenderer {
  17217. /**
  17218. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17219. * @param source LineMesh used to generate edges
  17220. * @param epsilon not important (specified angle for edge detection)
  17221. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17222. */
  17223. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17224. /**
  17225. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17226. */
  17227. _generateEdgesLines(): void;
  17228. }
  17229. }
  17230. declare module BABYLON {
  17231. /**
  17232. * This represents the object necessary to create a rendering group.
  17233. * This is exclusively used and created by the rendering manager.
  17234. * To modify the behavior, you use the available helpers in your scene or meshes.
  17235. * @hidden
  17236. */
  17237. export class RenderingGroup {
  17238. index: number;
  17239. private static _zeroVector;
  17240. private _scene;
  17241. private _opaqueSubMeshes;
  17242. private _transparentSubMeshes;
  17243. private _alphaTestSubMeshes;
  17244. private _depthOnlySubMeshes;
  17245. private _particleSystems;
  17246. private _spriteManagers;
  17247. private _opaqueSortCompareFn;
  17248. private _alphaTestSortCompareFn;
  17249. private _transparentSortCompareFn;
  17250. private _renderOpaque;
  17251. private _renderAlphaTest;
  17252. private _renderTransparent;
  17253. /** @hidden */
  17254. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  17255. onBeforeTransparentRendering: () => void;
  17256. /**
  17257. * Set the opaque sort comparison function.
  17258. * If null the sub meshes will be render in the order they were created
  17259. */
  17260. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17261. /**
  17262. * Set the alpha test sort comparison function.
  17263. * If null the sub meshes will be render in the order they were created
  17264. */
  17265. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17266. /**
  17267. * Set the transparent sort comparison function.
  17268. * If null the sub meshes will be render in the order they were created
  17269. */
  17270. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17271. /**
  17272. * Creates a new rendering group.
  17273. * @param index The rendering group index
  17274. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17275. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17276. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17277. */
  17278. 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>);
  17279. /**
  17280. * Render all the sub meshes contained in the group.
  17281. * @param customRenderFunction Used to override the default render behaviour of the group.
  17282. * @returns true if rendered some submeshes.
  17283. */
  17284. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17285. /**
  17286. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17287. * @param subMeshes The submeshes to render
  17288. */
  17289. private renderOpaqueSorted;
  17290. /**
  17291. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17292. * @param subMeshes The submeshes to render
  17293. */
  17294. private renderAlphaTestSorted;
  17295. /**
  17296. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17297. * @param subMeshes The submeshes to render
  17298. */
  17299. private renderTransparentSorted;
  17300. /**
  17301. * Renders the submeshes in a specified order.
  17302. * @param subMeshes The submeshes to sort before render
  17303. * @param sortCompareFn The comparison function use to sort
  17304. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17305. * @param transparent Specifies to activate blending if true
  17306. */
  17307. private static renderSorted;
  17308. /**
  17309. * Renders the submeshes in the order they were dispatched (no sort applied).
  17310. * @param subMeshes The submeshes to render
  17311. */
  17312. private static renderUnsorted;
  17313. /**
  17314. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17315. * are rendered back to front if in the same alpha index.
  17316. *
  17317. * @param a The first submesh
  17318. * @param b The second submesh
  17319. * @returns The result of the comparison
  17320. */
  17321. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17322. /**
  17323. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17324. * are rendered back to front.
  17325. *
  17326. * @param a The first submesh
  17327. * @param b The second submesh
  17328. * @returns The result of the comparison
  17329. */
  17330. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17331. /**
  17332. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17333. * are rendered front to back (prevent overdraw).
  17334. *
  17335. * @param a The first submesh
  17336. * @param b The second submesh
  17337. * @returns The result of the comparison
  17338. */
  17339. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17340. /**
  17341. * Resets the different lists of submeshes to prepare a new frame.
  17342. */
  17343. prepare(): void;
  17344. dispose(): void;
  17345. /**
  17346. * Inserts the submesh in its correct queue depending on its material.
  17347. * @param subMesh The submesh to dispatch
  17348. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17349. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17350. */
  17351. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17352. dispatchSprites(spriteManager: ISpriteManager): void;
  17353. dispatchParticles(particleSystem: IParticleSystem): void;
  17354. private _renderParticles;
  17355. private _renderSprites;
  17356. }
  17357. }
  17358. declare module BABYLON {
  17359. /**
  17360. * Interface describing the different options available in the rendering manager
  17361. * regarding Auto Clear between groups.
  17362. */
  17363. export interface IRenderingManagerAutoClearSetup {
  17364. /**
  17365. * Defines whether or not autoclear is enable.
  17366. */
  17367. autoClear: boolean;
  17368. /**
  17369. * Defines whether or not to autoclear the depth buffer.
  17370. */
  17371. depth: boolean;
  17372. /**
  17373. * Defines whether or not to autoclear the stencil buffer.
  17374. */
  17375. stencil: boolean;
  17376. }
  17377. /**
  17378. * This class is used by the onRenderingGroupObservable
  17379. */
  17380. export class RenderingGroupInfo {
  17381. /**
  17382. * The Scene that being rendered
  17383. */
  17384. scene: Scene;
  17385. /**
  17386. * The camera currently used for the rendering pass
  17387. */
  17388. camera: Nullable<Camera>;
  17389. /**
  17390. * The ID of the renderingGroup being processed
  17391. */
  17392. renderingGroupId: number;
  17393. }
  17394. /**
  17395. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17396. * It is enable to manage the different groups as well as the different necessary sort functions.
  17397. * This should not be used directly aside of the few static configurations
  17398. */
  17399. export class RenderingManager {
  17400. /**
  17401. * The max id used for rendering groups (not included)
  17402. */
  17403. static MAX_RENDERINGGROUPS: number;
  17404. /**
  17405. * The min id used for rendering groups (included)
  17406. */
  17407. static MIN_RENDERINGGROUPS: number;
  17408. /**
  17409. * Used to globally prevent autoclearing scenes.
  17410. */
  17411. static AUTOCLEAR: boolean;
  17412. /**
  17413. * @hidden
  17414. */
  17415. _useSceneAutoClearSetup: boolean;
  17416. private _scene;
  17417. private _renderingGroups;
  17418. private _depthStencilBufferAlreadyCleaned;
  17419. private _autoClearDepthStencil;
  17420. private _customOpaqueSortCompareFn;
  17421. private _customAlphaTestSortCompareFn;
  17422. private _customTransparentSortCompareFn;
  17423. private _renderingGroupInfo;
  17424. /**
  17425. * Instantiates a new rendering group for a particular scene
  17426. * @param scene Defines the scene the groups belongs to
  17427. */
  17428. constructor(scene: Scene);
  17429. private _clearDepthStencilBuffer;
  17430. /**
  17431. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17432. * @hidden
  17433. */
  17434. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17435. /**
  17436. * Resets the different information of the group to prepare a new frame
  17437. * @hidden
  17438. */
  17439. reset(): void;
  17440. /**
  17441. * Dispose and release the group and its associated resources.
  17442. * @hidden
  17443. */
  17444. dispose(): void;
  17445. /**
  17446. * Clear the info related to rendering groups preventing retention points during dispose.
  17447. */
  17448. freeRenderingGroups(): void;
  17449. private _prepareRenderingGroup;
  17450. /**
  17451. * Add a sprite manager to the rendering manager in order to render it this frame.
  17452. * @param spriteManager Define the sprite manager to render
  17453. */
  17454. dispatchSprites(spriteManager: ISpriteManager): void;
  17455. /**
  17456. * Add a particle system to the rendering manager in order to render it this frame.
  17457. * @param particleSystem Define the particle system to render
  17458. */
  17459. dispatchParticles(particleSystem: IParticleSystem): void;
  17460. /**
  17461. * Add a submesh to the manager in order to render it this frame
  17462. * @param subMesh The submesh to dispatch
  17463. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17464. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17465. */
  17466. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17467. /**
  17468. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17469. * This allowed control for front to back rendering or reversly depending of the special needs.
  17470. *
  17471. * @param renderingGroupId The rendering group id corresponding to its index
  17472. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17473. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17474. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17475. */
  17476. 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;
  17477. /**
  17478. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17479. *
  17480. * @param renderingGroupId The rendering group id corresponding to its index
  17481. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17482. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17483. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17484. */
  17485. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17486. /**
  17487. * Gets the current auto clear configuration for one rendering group of the rendering
  17488. * manager.
  17489. * @param index the rendering group index to get the information for
  17490. * @returns The auto clear setup for the requested rendering group
  17491. */
  17492. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17493. }
  17494. }
  17495. declare module BABYLON {
  17496. /**
  17497. * Defines the options associated with the creation of a custom shader for a shadow generator.
  17498. */
  17499. export interface ICustomShaderOptions {
  17500. /**
  17501. * Gets or sets the custom shader name to use
  17502. */
  17503. shaderName: string;
  17504. /**
  17505. * The list of attribute names used in the shader
  17506. */
  17507. attributes?: string[];
  17508. /**
  17509. * The list of unifrom names used in the shader
  17510. */
  17511. uniforms?: string[];
  17512. /**
  17513. * The list of sampler names used in the shader
  17514. */
  17515. samplers?: string[];
  17516. /**
  17517. * The list of defines used in the shader
  17518. */
  17519. defines?: string[];
  17520. }
  17521. /**
  17522. * Interface to implement to create a shadow generator compatible with BJS.
  17523. */
  17524. export interface IShadowGenerator {
  17525. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  17526. id: string;
  17527. /**
  17528. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17529. * @returns The render target texture if present otherwise, null
  17530. */
  17531. getShadowMap(): Nullable<RenderTargetTexture>;
  17532. /**
  17533. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  17534. * @param subMesh The submesh we want to render in the shadow map
  17535. * @param useInstances Defines wether will draw in the map using instances
  17536. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  17537. * @returns true if ready otherwise, false
  17538. */
  17539. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  17540. /**
  17541. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  17542. * @param defines Defines of the material we want to update
  17543. * @param lightIndex Index of the light in the enabled light list of the material
  17544. */
  17545. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  17546. /**
  17547. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  17548. * defined in the generator but impacting the effect).
  17549. * It implies the unifroms available on the materials are the standard BJS ones.
  17550. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  17551. * @param effect The effect we are binfing the information for
  17552. */
  17553. bindShadowLight(lightIndex: string, effect: Effect): void;
  17554. /**
  17555. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  17556. * (eq to shadow prjection matrix * light transform matrix)
  17557. * @returns The transform matrix used to create the shadow map
  17558. */
  17559. getTransformMatrix(): Matrix;
  17560. /**
  17561. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  17562. * Cube and 2D textures for instance.
  17563. */
  17564. recreateShadowMap(): void;
  17565. /**
  17566. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17567. * @param onCompiled Callback triggered at the and of the effects compilation
  17568. * @param options Sets of optional options forcing the compilation with different modes
  17569. */
  17570. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  17571. useInstances: boolean;
  17572. }>): void;
  17573. /**
  17574. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17575. * @param options Sets of optional options forcing the compilation with different modes
  17576. * @returns A promise that resolves when the compilation completes
  17577. */
  17578. forceCompilationAsync(options?: Partial<{
  17579. useInstances: boolean;
  17580. }>): Promise<void>;
  17581. /**
  17582. * Serializes the shadow generator setup to a json object.
  17583. * @returns The serialized JSON object
  17584. */
  17585. serialize(): any;
  17586. /**
  17587. * Disposes the Shadow map and related Textures and effects.
  17588. */
  17589. dispose(): void;
  17590. }
  17591. /**
  17592. * Default implementation IShadowGenerator.
  17593. * This is the main object responsible of generating shadows in the framework.
  17594. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  17595. */
  17596. export class ShadowGenerator implements IShadowGenerator {
  17597. /**
  17598. * Name of the shadow generator class
  17599. */
  17600. static CLASSNAME: string;
  17601. /**
  17602. * Shadow generator mode None: no filtering applied.
  17603. */
  17604. static readonly FILTER_NONE: number;
  17605. /**
  17606. * Shadow generator mode ESM: Exponential Shadow Mapping.
  17607. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17608. */
  17609. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  17610. /**
  17611. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  17612. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  17613. */
  17614. static readonly FILTER_POISSONSAMPLING: number;
  17615. /**
  17616. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  17617. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17618. */
  17619. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  17620. /**
  17621. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  17622. * edge artifacts on steep falloff.
  17623. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17624. */
  17625. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  17626. /**
  17627. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  17628. * edge artifacts on steep falloff.
  17629. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  17630. */
  17631. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  17632. /**
  17633. * Shadow generator mode PCF: Percentage Closer Filtering
  17634. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17635. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  17636. */
  17637. static readonly FILTER_PCF: number;
  17638. /**
  17639. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  17640. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  17641. * Contact Hardening
  17642. */
  17643. static readonly FILTER_PCSS: number;
  17644. /**
  17645. * Reserved for PCF and PCSS
  17646. * Highest Quality.
  17647. *
  17648. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  17649. *
  17650. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  17651. */
  17652. static readonly QUALITY_HIGH: number;
  17653. /**
  17654. * Reserved for PCF and PCSS
  17655. * Good tradeoff for quality/perf cross devices
  17656. *
  17657. * Execute PCF on a 3*3 kernel.
  17658. *
  17659. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  17660. */
  17661. static readonly QUALITY_MEDIUM: number;
  17662. /**
  17663. * Reserved for PCF and PCSS
  17664. * The lowest quality but the fastest.
  17665. *
  17666. * Execute PCF on a 1*1 kernel.
  17667. *
  17668. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  17669. */
  17670. static readonly QUALITY_LOW: number;
  17671. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  17672. id: string;
  17673. /** Gets or sets the custom shader name to use */
  17674. customShaderOptions: ICustomShaderOptions;
  17675. /**
  17676. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  17677. */
  17678. onBeforeShadowMapRenderObservable: Observable<Effect>;
  17679. /**
  17680. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  17681. */
  17682. onAfterShadowMapRenderObservable: Observable<Effect>;
  17683. /**
  17684. * Observable triggered before a mesh is rendered in the shadow map.
  17685. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  17686. */
  17687. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  17688. /**
  17689. * Observable triggered after a mesh is rendered in the shadow map.
  17690. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  17691. */
  17692. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  17693. protected _bias: number;
  17694. /**
  17695. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  17696. */
  17697. get bias(): number;
  17698. /**
  17699. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  17700. */
  17701. set bias(bias: number);
  17702. protected _normalBias: number;
  17703. /**
  17704. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17705. */
  17706. get normalBias(): number;
  17707. /**
  17708. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  17709. */
  17710. set normalBias(normalBias: number);
  17711. protected _blurBoxOffset: number;
  17712. /**
  17713. * Gets the blur box offset: offset applied during the blur pass.
  17714. * Only useful if useKernelBlur = false
  17715. */
  17716. get blurBoxOffset(): number;
  17717. /**
  17718. * Sets the blur box offset: offset applied during the blur pass.
  17719. * Only useful if useKernelBlur = false
  17720. */
  17721. set blurBoxOffset(value: number);
  17722. protected _blurScale: number;
  17723. /**
  17724. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  17725. * 2 means half of the size.
  17726. */
  17727. get blurScale(): number;
  17728. /**
  17729. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  17730. * 2 means half of the size.
  17731. */
  17732. set blurScale(value: number);
  17733. protected _blurKernel: number;
  17734. /**
  17735. * Gets the blur kernel: kernel size of the blur pass.
  17736. * Only useful if useKernelBlur = true
  17737. */
  17738. get blurKernel(): number;
  17739. /**
  17740. * Sets the blur kernel: kernel size of the blur pass.
  17741. * Only useful if useKernelBlur = true
  17742. */
  17743. set blurKernel(value: number);
  17744. protected _useKernelBlur: boolean;
  17745. /**
  17746. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  17747. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17748. */
  17749. get useKernelBlur(): boolean;
  17750. /**
  17751. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  17752. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  17753. */
  17754. set useKernelBlur(value: boolean);
  17755. protected _depthScale: number;
  17756. /**
  17757. * Gets the depth scale used in ESM mode.
  17758. */
  17759. get depthScale(): number;
  17760. /**
  17761. * Sets the depth scale used in ESM mode.
  17762. * This can override the scale stored on the light.
  17763. */
  17764. set depthScale(value: number);
  17765. protected _validateFilter(filter: number): number;
  17766. protected _filter: number;
  17767. /**
  17768. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  17769. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17770. */
  17771. get filter(): number;
  17772. /**
  17773. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  17774. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  17775. */
  17776. set filter(value: number);
  17777. /**
  17778. * Gets if the current filter is set to Poisson Sampling.
  17779. */
  17780. get usePoissonSampling(): boolean;
  17781. /**
  17782. * Sets the current filter to Poisson Sampling.
  17783. */
  17784. set usePoissonSampling(value: boolean);
  17785. /**
  17786. * Gets if the current filter is set to ESM.
  17787. */
  17788. get useExponentialShadowMap(): boolean;
  17789. /**
  17790. * Sets the current filter is to ESM.
  17791. */
  17792. set useExponentialShadowMap(value: boolean);
  17793. /**
  17794. * Gets if the current filter is set to filtered ESM.
  17795. */
  17796. get useBlurExponentialShadowMap(): boolean;
  17797. /**
  17798. * Gets if the current filter is set to filtered ESM.
  17799. */
  17800. set useBlurExponentialShadowMap(value: boolean);
  17801. /**
  17802. * Gets if the current filter is set to "close ESM" (using the inverse of the
  17803. * exponential to prevent steep falloff artifacts).
  17804. */
  17805. get useCloseExponentialShadowMap(): boolean;
  17806. /**
  17807. * Sets the current filter to "close ESM" (using the inverse of the
  17808. * exponential to prevent steep falloff artifacts).
  17809. */
  17810. set useCloseExponentialShadowMap(value: boolean);
  17811. /**
  17812. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  17813. * exponential to prevent steep falloff artifacts).
  17814. */
  17815. get useBlurCloseExponentialShadowMap(): boolean;
  17816. /**
  17817. * Sets the current filter to filtered "close ESM" (using the inverse of the
  17818. * exponential to prevent steep falloff artifacts).
  17819. */
  17820. set useBlurCloseExponentialShadowMap(value: boolean);
  17821. /**
  17822. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  17823. */
  17824. get usePercentageCloserFiltering(): boolean;
  17825. /**
  17826. * Sets the current filter to "PCF" (percentage closer filtering).
  17827. */
  17828. set usePercentageCloserFiltering(value: boolean);
  17829. protected _filteringQuality: number;
  17830. /**
  17831. * Gets the PCF or PCSS Quality.
  17832. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17833. */
  17834. get filteringQuality(): number;
  17835. /**
  17836. * Sets the PCF or PCSS Quality.
  17837. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  17838. */
  17839. set filteringQuality(filteringQuality: number);
  17840. /**
  17841. * Gets if the current filter is set to "PCSS" (contact hardening).
  17842. */
  17843. get useContactHardeningShadow(): boolean;
  17844. /**
  17845. * Sets the current filter to "PCSS" (contact hardening).
  17846. */
  17847. set useContactHardeningShadow(value: boolean);
  17848. protected _contactHardeningLightSizeUVRatio: number;
  17849. /**
  17850. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17851. * Using a ratio helps keeping shape stability independently of the map size.
  17852. *
  17853. * It does not account for the light projection as it was having too much
  17854. * instability during the light setup or during light position changes.
  17855. *
  17856. * Only valid if useContactHardeningShadow is true.
  17857. */
  17858. get contactHardeningLightSizeUVRatio(): number;
  17859. /**
  17860. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  17861. * Using a ratio helps keeping shape stability independently of the map size.
  17862. *
  17863. * It does not account for the light projection as it was having too much
  17864. * instability during the light setup or during light position changes.
  17865. *
  17866. * Only valid if useContactHardeningShadow is true.
  17867. */
  17868. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  17869. protected _darkness: number;
  17870. /** Gets or sets the actual darkness of a shadow */
  17871. get darkness(): number;
  17872. set darkness(value: number);
  17873. /**
  17874. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  17875. * 0 means strongest and 1 would means no shadow.
  17876. * @returns the darkness.
  17877. */
  17878. getDarkness(): number;
  17879. /**
  17880. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  17881. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  17882. * @returns the shadow generator allowing fluent coding.
  17883. */
  17884. setDarkness(darkness: number): ShadowGenerator;
  17885. protected _transparencyShadow: boolean;
  17886. /** Gets or sets the ability to have transparent shadow */
  17887. get transparencyShadow(): boolean;
  17888. set transparencyShadow(value: boolean);
  17889. /**
  17890. * Sets the ability to have transparent shadow (boolean).
  17891. * @param transparent True if transparent else False
  17892. * @returns the shadow generator allowing fluent coding
  17893. */
  17894. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  17895. /**
  17896. * Enables or disables shadows with varying strength based on the transparency
  17897. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  17898. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  17899. * mesh.visibility * alphaTexture.a
  17900. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  17901. */
  17902. enableSoftTransparentShadow: boolean;
  17903. protected _shadowMap: Nullable<RenderTargetTexture>;
  17904. protected _shadowMap2: Nullable<RenderTargetTexture>;
  17905. /**
  17906. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  17907. * @returns The render target texture if present otherwise, null
  17908. */
  17909. getShadowMap(): Nullable<RenderTargetTexture>;
  17910. /**
  17911. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  17912. * @returns The render target texture if the shadow map is present otherwise, null
  17913. */
  17914. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  17915. /**
  17916. * Gets the class name of that object
  17917. * @returns "ShadowGenerator"
  17918. */
  17919. getClassName(): string;
  17920. /**
  17921. * Helper function to add a mesh and its descendants to the list of shadow casters.
  17922. * @param mesh Mesh to add
  17923. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  17924. * @returns the Shadow Generator itself
  17925. */
  17926. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17927. /**
  17928. * Helper function to remove a mesh and its descendants from the list of shadow casters
  17929. * @param mesh Mesh to remove
  17930. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  17931. * @returns the Shadow Generator itself
  17932. */
  17933. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  17934. /**
  17935. * Controls the extent to which the shadows fade out at the edge of the frustum
  17936. */
  17937. frustumEdgeFalloff: number;
  17938. protected _light: IShadowLight;
  17939. /**
  17940. * Returns the associated light object.
  17941. * @returns the light generating the shadow
  17942. */
  17943. getLight(): IShadowLight;
  17944. /**
  17945. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  17946. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  17947. * It might on the other hand introduce peter panning.
  17948. */
  17949. forceBackFacesOnly: boolean;
  17950. protected _scene: Scene;
  17951. protected _lightDirection: Vector3;
  17952. protected _effect: Effect;
  17953. protected _viewMatrix: Matrix;
  17954. protected _projectionMatrix: Matrix;
  17955. protected _transformMatrix: Matrix;
  17956. protected _cachedPosition: Vector3;
  17957. protected _cachedDirection: Vector3;
  17958. protected _cachedDefines: string;
  17959. protected _currentRenderID: number;
  17960. protected _boxBlurPostprocess: Nullable<PostProcess>;
  17961. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  17962. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  17963. protected _blurPostProcesses: PostProcess[];
  17964. protected _mapSize: number;
  17965. protected _currentFaceIndex: number;
  17966. protected _currentFaceIndexCache: number;
  17967. protected _textureType: number;
  17968. protected _defaultTextureMatrix: Matrix;
  17969. protected _storedUniqueId: Nullable<number>;
  17970. /** @hidden */
  17971. static _SceneComponentInitialization: (scene: Scene) => void;
  17972. /**
  17973. * Gets or sets the size of the texture what stores the shadows
  17974. */
  17975. get mapSize(): number;
  17976. set mapSize(size: number);
  17977. /**
  17978. * Creates a ShadowGenerator object.
  17979. * A ShadowGenerator is the required tool to use the shadows.
  17980. * Each light casting shadows needs to use its own ShadowGenerator.
  17981. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  17982. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  17983. * @param light The light object generating the shadows.
  17984. * @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.
  17985. */
  17986. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  17987. protected _initializeGenerator(): void;
  17988. protected _createTargetRenderTexture(): void;
  17989. protected _initializeShadowMap(): void;
  17990. protected _initializeBlurRTTAndPostProcesses(): void;
  17991. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  17992. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  17993. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  17994. protected _applyFilterValues(): void;
  17995. /**
  17996. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  17997. * @param onCompiled Callback triggered at the and of the effects compilation
  17998. * @param options Sets of optional options forcing the compilation with different modes
  17999. */
  18000. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  18001. useInstances: boolean;
  18002. }>): void;
  18003. /**
  18004. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18005. * @param options Sets of optional options forcing the compilation with different modes
  18006. * @returns A promise that resolves when the compilation completes
  18007. */
  18008. forceCompilationAsync(options?: Partial<{
  18009. useInstances: boolean;
  18010. }>): Promise<void>;
  18011. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  18012. private _prepareShadowDefines;
  18013. /**
  18014. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  18015. * @param subMesh The submesh we want to render in the shadow map
  18016. * @param useInstances Defines wether will draw in the map using instances
  18017. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  18018. * @returns true if ready otherwise, false
  18019. */
  18020. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  18021. /**
  18022. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  18023. * @param defines Defines of the material we want to update
  18024. * @param lightIndex Index of the light in the enabled light list of the material
  18025. */
  18026. prepareDefines(defines: any, lightIndex: number): void;
  18027. /**
  18028. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  18029. * defined in the generator but impacting the effect).
  18030. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  18031. * @param effect The effect we are binfing the information for
  18032. */
  18033. bindShadowLight(lightIndex: string, effect: Effect): void;
  18034. /**
  18035. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  18036. * (eq to shadow prjection matrix * light transform matrix)
  18037. * @returns The transform matrix used to create the shadow map
  18038. */
  18039. getTransformMatrix(): Matrix;
  18040. /**
  18041. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  18042. * Cube and 2D textures for instance.
  18043. */
  18044. recreateShadowMap(): void;
  18045. protected _disposeBlurPostProcesses(): void;
  18046. protected _disposeRTTandPostProcesses(): void;
  18047. /**
  18048. * Disposes the ShadowGenerator.
  18049. * Returns nothing.
  18050. */
  18051. dispose(): void;
  18052. /**
  18053. * Serializes the shadow generator setup to a json object.
  18054. * @returns The serialized JSON object
  18055. */
  18056. serialize(): any;
  18057. /**
  18058. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  18059. * @param parsedShadowGenerator The JSON object to parse
  18060. * @param scene The scene to create the shadow map for
  18061. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  18062. * @returns The parsed shadow generator
  18063. */
  18064. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  18065. }
  18066. }
  18067. declare module BABYLON {
  18068. /**
  18069. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  18070. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  18071. * 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.
  18072. */
  18073. export abstract class Light extends Node {
  18074. /**
  18075. * Falloff Default: light is falling off following the material specification:
  18076. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  18077. */
  18078. static readonly FALLOFF_DEFAULT: number;
  18079. /**
  18080. * Falloff Physical: light is falling off following the inverse squared distance law.
  18081. */
  18082. static readonly FALLOFF_PHYSICAL: number;
  18083. /**
  18084. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  18085. * to enhance interoperability with other engines.
  18086. */
  18087. static readonly FALLOFF_GLTF: number;
  18088. /**
  18089. * Falloff Standard: light is falling off like in the standard material
  18090. * to enhance interoperability with other materials.
  18091. */
  18092. static readonly FALLOFF_STANDARD: number;
  18093. /**
  18094. * If every light affecting the material is in this lightmapMode,
  18095. * material.lightmapTexture adds or multiplies
  18096. * (depends on material.useLightmapAsShadowmap)
  18097. * after every other light calculations.
  18098. */
  18099. static readonly LIGHTMAP_DEFAULT: number;
  18100. /**
  18101. * material.lightmapTexture as only diffuse lighting from this light
  18102. * adds only specular lighting from this light
  18103. * adds dynamic shadows
  18104. */
  18105. static readonly LIGHTMAP_SPECULAR: number;
  18106. /**
  18107. * material.lightmapTexture as only lighting
  18108. * no light calculation from this light
  18109. * only adds dynamic shadows from this light
  18110. */
  18111. static readonly LIGHTMAP_SHADOWSONLY: number;
  18112. /**
  18113. * Each light type uses the default quantity according to its type:
  18114. * point/spot lights use luminous intensity
  18115. * directional lights use illuminance
  18116. */
  18117. static readonly INTENSITYMODE_AUTOMATIC: number;
  18118. /**
  18119. * lumen (lm)
  18120. */
  18121. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  18122. /**
  18123. * candela (lm/sr)
  18124. */
  18125. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  18126. /**
  18127. * lux (lm/m^2)
  18128. */
  18129. static readonly INTENSITYMODE_ILLUMINANCE: number;
  18130. /**
  18131. * nit (cd/m^2)
  18132. */
  18133. static readonly INTENSITYMODE_LUMINANCE: number;
  18134. /**
  18135. * Light type const id of the point light.
  18136. */
  18137. static readonly LIGHTTYPEID_POINTLIGHT: number;
  18138. /**
  18139. * Light type const id of the directional light.
  18140. */
  18141. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  18142. /**
  18143. * Light type const id of the spot light.
  18144. */
  18145. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  18146. /**
  18147. * Light type const id of the hemispheric light.
  18148. */
  18149. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  18150. /**
  18151. * Diffuse gives the basic color to an object.
  18152. */
  18153. diffuse: Color3;
  18154. /**
  18155. * Specular produces a highlight color on an object.
  18156. * Note: This is note affecting PBR materials.
  18157. */
  18158. specular: Color3;
  18159. /**
  18160. * Defines the falloff type for this light. This lets overrriding how punctual light are
  18161. * falling off base on range or angle.
  18162. * This can be set to any values in Light.FALLOFF_x.
  18163. *
  18164. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  18165. * other types of materials.
  18166. */
  18167. falloffType: number;
  18168. /**
  18169. * Strength of the light.
  18170. * Note: By default it is define in the framework own unit.
  18171. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  18172. */
  18173. intensity: number;
  18174. private _range;
  18175. protected _inverseSquaredRange: number;
  18176. /**
  18177. * Defines how far from the source the light is impacting in scene units.
  18178. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18179. */
  18180. get range(): number;
  18181. /**
  18182. * Defines how far from the source the light is impacting in scene units.
  18183. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18184. */
  18185. set range(value: number);
  18186. /**
  18187. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  18188. * of light.
  18189. */
  18190. private _photometricScale;
  18191. private _intensityMode;
  18192. /**
  18193. * Gets the photometric scale used to interpret the intensity.
  18194. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18195. */
  18196. get intensityMode(): number;
  18197. /**
  18198. * Sets the photometric scale used to interpret the intensity.
  18199. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18200. */
  18201. set intensityMode(value: number);
  18202. private _radius;
  18203. /**
  18204. * Gets the light radius used by PBR Materials to simulate soft area lights.
  18205. */
  18206. get radius(): number;
  18207. /**
  18208. * sets the light radius used by PBR Materials to simulate soft area lights.
  18209. */
  18210. set radius(value: number);
  18211. private _renderPriority;
  18212. /**
  18213. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  18214. * exceeding the number allowed of the materials.
  18215. */
  18216. renderPriority: number;
  18217. private _shadowEnabled;
  18218. /**
  18219. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18220. * the current shadow generator.
  18221. */
  18222. get shadowEnabled(): boolean;
  18223. /**
  18224. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18225. * the current shadow generator.
  18226. */
  18227. set shadowEnabled(value: boolean);
  18228. private _includedOnlyMeshes;
  18229. /**
  18230. * Gets the only meshes impacted by this light.
  18231. */
  18232. get includedOnlyMeshes(): AbstractMesh[];
  18233. /**
  18234. * Sets the only meshes impacted by this light.
  18235. */
  18236. set includedOnlyMeshes(value: AbstractMesh[]);
  18237. private _excludedMeshes;
  18238. /**
  18239. * Gets the meshes not impacted by this light.
  18240. */
  18241. get excludedMeshes(): AbstractMesh[];
  18242. /**
  18243. * Sets the meshes not impacted by this light.
  18244. */
  18245. set excludedMeshes(value: AbstractMesh[]);
  18246. private _excludeWithLayerMask;
  18247. /**
  18248. * Gets the layer id use to find what meshes are not impacted by the light.
  18249. * Inactive if 0
  18250. */
  18251. get excludeWithLayerMask(): number;
  18252. /**
  18253. * Sets the layer id use to find what meshes are not impacted by the light.
  18254. * Inactive if 0
  18255. */
  18256. set excludeWithLayerMask(value: number);
  18257. private _includeOnlyWithLayerMask;
  18258. /**
  18259. * Gets the layer id use to find what meshes are impacted by the light.
  18260. * Inactive if 0
  18261. */
  18262. get includeOnlyWithLayerMask(): number;
  18263. /**
  18264. * Sets the layer id use to find what meshes are impacted by the light.
  18265. * Inactive if 0
  18266. */
  18267. set includeOnlyWithLayerMask(value: number);
  18268. private _lightmapMode;
  18269. /**
  18270. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18271. */
  18272. get lightmapMode(): number;
  18273. /**
  18274. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18275. */
  18276. set lightmapMode(value: number);
  18277. /**
  18278. * Shadow generator associted to the light.
  18279. * @hidden Internal use only.
  18280. */
  18281. _shadowGenerator: Nullable<IShadowGenerator>;
  18282. /**
  18283. * @hidden Internal use only.
  18284. */
  18285. _excludedMeshesIds: string[];
  18286. /**
  18287. * @hidden Internal use only.
  18288. */
  18289. _includedOnlyMeshesIds: string[];
  18290. /**
  18291. * The current light unifom buffer.
  18292. * @hidden Internal use only.
  18293. */
  18294. _uniformBuffer: UniformBuffer;
  18295. /** @hidden */
  18296. _renderId: number;
  18297. /**
  18298. * Creates a Light object in the scene.
  18299. * Documentation : https://doc.babylonjs.com/babylon101/lights
  18300. * @param name The firendly name of the light
  18301. * @param scene The scene the light belongs too
  18302. */
  18303. constructor(name: string, scene: Scene);
  18304. protected abstract _buildUniformLayout(): void;
  18305. /**
  18306. * Sets the passed Effect "effect" with the Light information.
  18307. * @param effect The effect to update
  18308. * @param lightIndex The index of the light in the effect to update
  18309. * @returns The light
  18310. */
  18311. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  18312. /**
  18313. * Sets the passed Effect "effect" with the Light textures.
  18314. * @param effect The effect to update
  18315. * @param lightIndex The index of the light in the effect to update
  18316. * @returns The light
  18317. */
  18318. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  18319. /**
  18320. * Binds the lights information from the scene to the effect for the given mesh.
  18321. * @param lightIndex Light index
  18322. * @param scene The scene where the light belongs to
  18323. * @param effect The effect we are binding the data to
  18324. * @param useSpecular Defines if specular is supported
  18325. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  18326. */
  18327. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  18328. /**
  18329. * Sets the passed Effect "effect" with the Light information.
  18330. * @param effect The effect to update
  18331. * @param lightDataUniformName The uniform used to store light data (position or direction)
  18332. * @returns The light
  18333. */
  18334. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  18335. /**
  18336. * Returns the string "Light".
  18337. * @returns the class name
  18338. */
  18339. getClassName(): string;
  18340. /** @hidden */
  18341. readonly _isLight: boolean;
  18342. /**
  18343. * Converts the light information to a readable string for debug purpose.
  18344. * @param fullDetails Supports for multiple levels of logging within scene loading
  18345. * @returns the human readable light info
  18346. */
  18347. toString(fullDetails?: boolean): string;
  18348. /** @hidden */
  18349. protected _syncParentEnabledState(): void;
  18350. /**
  18351. * Set the enabled state of this node.
  18352. * @param value - the new enabled state
  18353. */
  18354. setEnabled(value: boolean): void;
  18355. /**
  18356. * Returns the Light associated shadow generator if any.
  18357. * @return the associated shadow generator.
  18358. */
  18359. getShadowGenerator(): Nullable<IShadowGenerator>;
  18360. /**
  18361. * Returns a Vector3, the absolute light position in the World.
  18362. * @returns the world space position of the light
  18363. */
  18364. getAbsolutePosition(): Vector3;
  18365. /**
  18366. * Specifies if the light will affect the passed mesh.
  18367. * @param mesh The mesh to test against the light
  18368. * @return true the mesh is affected otherwise, false.
  18369. */
  18370. canAffectMesh(mesh: AbstractMesh): boolean;
  18371. /**
  18372. * Sort function to order lights for rendering.
  18373. * @param a First Light object to compare to second.
  18374. * @param b Second Light object to compare first.
  18375. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  18376. */
  18377. static CompareLightsPriority(a: Light, b: Light): number;
  18378. /**
  18379. * Releases resources associated with this node.
  18380. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18381. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18382. */
  18383. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18384. /**
  18385. * Returns the light type ID (integer).
  18386. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18387. */
  18388. getTypeID(): number;
  18389. /**
  18390. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  18391. * @returns the scaled intensity in intensity mode unit
  18392. */
  18393. getScaledIntensity(): number;
  18394. /**
  18395. * Returns a new Light object, named "name", from the current one.
  18396. * @param name The name of the cloned light
  18397. * @param newParent The parent of this light, if it has one
  18398. * @returns the new created light
  18399. */
  18400. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  18401. /**
  18402. * Serializes the current light into a Serialization object.
  18403. * @returns the serialized object.
  18404. */
  18405. serialize(): any;
  18406. /**
  18407. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  18408. * This new light is named "name" and added to the passed scene.
  18409. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  18410. * @param name The friendly name of the light
  18411. * @param scene The scene the new light will belong to
  18412. * @returns the constructor function
  18413. */
  18414. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  18415. /**
  18416. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  18417. * @param parsedLight The JSON representation of the light
  18418. * @param scene The scene to create the parsed light in
  18419. * @returns the created light after parsing
  18420. */
  18421. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  18422. private _hookArrayForExcluded;
  18423. private _hookArrayForIncludedOnly;
  18424. private _resyncMeshes;
  18425. /**
  18426. * Forces the meshes to update their light related information in their rendering used effects
  18427. * @hidden Internal Use Only
  18428. */
  18429. _markMeshesAsLightDirty(): void;
  18430. /**
  18431. * Recomputes the cached photometric scale if needed.
  18432. */
  18433. private _computePhotometricScale;
  18434. /**
  18435. * Returns the Photometric Scale according to the light type and intensity mode.
  18436. */
  18437. private _getPhotometricScale;
  18438. /**
  18439. * Reorder the light in the scene according to their defined priority.
  18440. * @hidden Internal Use Only
  18441. */
  18442. _reorderLightsInScene(): void;
  18443. /**
  18444. * Prepares the list of defines specific to the light type.
  18445. * @param defines the list of defines
  18446. * @param lightIndex defines the index of the light for the effect
  18447. */
  18448. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  18449. }
  18450. }
  18451. declare module BABYLON {
  18452. /**
  18453. * Configuration needed for prepass-capable materials
  18454. */
  18455. export class PrePassConfiguration {
  18456. /**
  18457. * Previous world matrices of meshes carrying this material
  18458. * Used for computing velocity
  18459. */
  18460. previousWorldMatrices: {
  18461. [index: number]: Matrix;
  18462. };
  18463. /**
  18464. * Previous view project matrix
  18465. * Used for computing velocity
  18466. */
  18467. previousViewProjection: Matrix;
  18468. /**
  18469. * Previous bones of meshes carrying this material
  18470. * Used for computing velocity
  18471. */
  18472. previousBones: {
  18473. [index: number]: Float32Array;
  18474. };
  18475. /**
  18476. * Add the required uniforms to the current list.
  18477. * @param uniforms defines the current uniform list.
  18478. */
  18479. static AddUniforms(uniforms: string[]): void;
  18480. /**
  18481. * Add the required samplers to the current list.
  18482. * @param samplers defines the current sampler list.
  18483. */
  18484. static AddSamplers(samplers: string[]): void;
  18485. /**
  18486. * Binds the material data.
  18487. * @param effect defines the effect to update
  18488. * @param scene defines the scene the material belongs to.
  18489. * @param mesh The mesh
  18490. * @param world World matrix of this mesh
  18491. * @param isFrozen Is the material frozen
  18492. */
  18493. bindForSubMesh(effect: Effect, scene: Scene, mesh: Mesh, world: Matrix, isFrozen: boolean): void;
  18494. }
  18495. }
  18496. declare module BABYLON {
  18497. /**
  18498. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  18499. * This is the base of the follow, arc rotate cameras and Free camera
  18500. * @see https://doc.babylonjs.com/features/cameras
  18501. */
  18502. export class TargetCamera extends Camera {
  18503. private static _RigCamTransformMatrix;
  18504. private static _TargetTransformMatrix;
  18505. private static _TargetFocalPoint;
  18506. private _tmpUpVector;
  18507. private _tmpTargetVector;
  18508. /**
  18509. * Define the current direction the camera is moving to
  18510. */
  18511. cameraDirection: Vector3;
  18512. /**
  18513. * Define the current rotation the camera is rotating to
  18514. */
  18515. cameraRotation: Vector2;
  18516. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  18517. ignoreParentScaling: boolean;
  18518. /**
  18519. * When set, the up vector of the camera will be updated by the rotation of the camera
  18520. */
  18521. updateUpVectorFromRotation: boolean;
  18522. private _tmpQuaternion;
  18523. /**
  18524. * Define the current rotation of the camera
  18525. */
  18526. rotation: Vector3;
  18527. /**
  18528. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  18529. */
  18530. rotationQuaternion: Quaternion;
  18531. /**
  18532. * Define the current speed of the camera
  18533. */
  18534. speed: number;
  18535. /**
  18536. * Add constraint to the camera to prevent it to move freely in all directions and
  18537. * around all axis.
  18538. */
  18539. noRotationConstraint: boolean;
  18540. /**
  18541. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  18542. * panning
  18543. */
  18544. invertRotation: boolean;
  18545. /**
  18546. * Speed multiplier for inverse camera panning
  18547. */
  18548. inverseRotationSpeed: number;
  18549. /**
  18550. * Define the current target of the camera as an object or a position.
  18551. */
  18552. lockedTarget: any;
  18553. /** @hidden */
  18554. _currentTarget: Vector3;
  18555. /** @hidden */
  18556. _initialFocalDistance: number;
  18557. /** @hidden */
  18558. _viewMatrix: Matrix;
  18559. /** @hidden */
  18560. _camMatrix: Matrix;
  18561. /** @hidden */
  18562. _cameraTransformMatrix: Matrix;
  18563. /** @hidden */
  18564. _cameraRotationMatrix: Matrix;
  18565. /** @hidden */
  18566. _referencePoint: Vector3;
  18567. /** @hidden */
  18568. _transformedReferencePoint: Vector3;
  18569. /** @hidden */
  18570. _reset: () => void;
  18571. private _defaultUp;
  18572. /**
  18573. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  18574. * This is the base of the follow, arc rotate cameras and Free camera
  18575. * @see https://doc.babylonjs.com/features/cameras
  18576. * @param name Defines the name of the camera in the scene
  18577. * @param position Defines the start position of the camera in the scene
  18578. * @param scene Defines the scene the camera belongs to
  18579. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18580. */
  18581. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  18582. /**
  18583. * Gets the position in front of the camera at a given distance.
  18584. * @param distance The distance from the camera we want the position to be
  18585. * @returns the position
  18586. */
  18587. getFrontPosition(distance: number): Vector3;
  18588. /** @hidden */
  18589. _getLockedTargetPosition(): Nullable<Vector3>;
  18590. private _storedPosition;
  18591. private _storedRotation;
  18592. private _storedRotationQuaternion;
  18593. /**
  18594. * Store current camera state of the camera (fov, position, rotation, etc..)
  18595. * @returns the camera
  18596. */
  18597. storeState(): Camera;
  18598. /**
  18599. * Restored camera state. You must call storeState() first
  18600. * @returns whether it was successful or not
  18601. * @hidden
  18602. */
  18603. _restoreStateValues(): boolean;
  18604. /** @hidden */
  18605. _initCache(): void;
  18606. /** @hidden */
  18607. _updateCache(ignoreParentClass?: boolean): void;
  18608. /** @hidden */
  18609. _isSynchronizedViewMatrix(): boolean;
  18610. /** @hidden */
  18611. _computeLocalCameraSpeed(): number;
  18612. /**
  18613. * Defines the target the camera should look at.
  18614. * @param target Defines the new target as a Vector or a mesh
  18615. */
  18616. setTarget(target: Vector3): void;
  18617. /**
  18618. * Defines the target point of the camera.
  18619. * The camera looks towards it form the radius distance.
  18620. */
  18621. get target(): Vector3;
  18622. set target(value: Vector3);
  18623. /**
  18624. * Return the current target position of the camera. This value is expressed in local space.
  18625. * @returns the target position
  18626. */
  18627. getTarget(): Vector3;
  18628. /** @hidden */
  18629. _decideIfNeedsToMove(): boolean;
  18630. /** @hidden */
  18631. _updatePosition(): void;
  18632. /** @hidden */
  18633. _checkInputs(): void;
  18634. protected _updateCameraRotationMatrix(): void;
  18635. /**
  18636. * 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)
  18637. * @returns the current camera
  18638. */
  18639. private _rotateUpVectorWithCameraRotationMatrix;
  18640. private _cachedRotationZ;
  18641. private _cachedQuaternionRotationZ;
  18642. /** @hidden */
  18643. _getViewMatrix(): Matrix;
  18644. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  18645. /**
  18646. * @hidden
  18647. */
  18648. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  18649. /**
  18650. * @hidden
  18651. */
  18652. _updateRigCameras(): void;
  18653. private _getRigCamPositionAndTarget;
  18654. /**
  18655. * Gets the current object class name.
  18656. * @return the class name
  18657. */
  18658. getClassName(): string;
  18659. }
  18660. }
  18661. declare module BABYLON {
  18662. /**
  18663. * Gather the list of keyboard event types as constants.
  18664. */
  18665. export class KeyboardEventTypes {
  18666. /**
  18667. * The keydown event is fired when a key becomes active (pressed).
  18668. */
  18669. static readonly KEYDOWN: number;
  18670. /**
  18671. * The keyup event is fired when a key has been released.
  18672. */
  18673. static readonly KEYUP: number;
  18674. }
  18675. /**
  18676. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18677. */
  18678. export class KeyboardInfo {
  18679. /**
  18680. * Defines the type of event (KeyboardEventTypes)
  18681. */
  18682. type: number;
  18683. /**
  18684. * Defines the related dom event
  18685. */
  18686. event: KeyboardEvent;
  18687. /**
  18688. * Instantiates a new keyboard info.
  18689. * This class is used to store keyboard related info for the onKeyboardObservable event.
  18690. * @param type Defines the type of event (KeyboardEventTypes)
  18691. * @param event Defines the related dom event
  18692. */
  18693. constructor(
  18694. /**
  18695. * Defines the type of event (KeyboardEventTypes)
  18696. */
  18697. type: number,
  18698. /**
  18699. * Defines the related dom event
  18700. */
  18701. event: KeyboardEvent);
  18702. }
  18703. /**
  18704. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18705. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  18706. */
  18707. export class KeyboardInfoPre extends KeyboardInfo {
  18708. /**
  18709. * Defines the type of event (KeyboardEventTypes)
  18710. */
  18711. type: number;
  18712. /**
  18713. * Defines the related dom event
  18714. */
  18715. event: KeyboardEvent;
  18716. /**
  18717. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  18718. */
  18719. skipOnPointerObservable: boolean;
  18720. /**
  18721. * Instantiates a new keyboard pre info.
  18722. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  18723. * @param type Defines the type of event (KeyboardEventTypes)
  18724. * @param event Defines the related dom event
  18725. */
  18726. constructor(
  18727. /**
  18728. * Defines the type of event (KeyboardEventTypes)
  18729. */
  18730. type: number,
  18731. /**
  18732. * Defines the related dom event
  18733. */
  18734. event: KeyboardEvent);
  18735. }
  18736. }
  18737. declare module BABYLON {
  18738. /**
  18739. * Manage the keyboard inputs to control the movement of a free camera.
  18740. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18741. */
  18742. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  18743. /**
  18744. * Defines the camera the input is attached to.
  18745. */
  18746. camera: FreeCamera;
  18747. /**
  18748. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  18749. */
  18750. keysUp: number[];
  18751. /**
  18752. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  18753. */
  18754. keysUpward: number[];
  18755. /**
  18756. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  18757. */
  18758. keysDown: number[];
  18759. /**
  18760. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  18761. */
  18762. keysDownward: number[];
  18763. /**
  18764. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  18765. */
  18766. keysLeft: number[];
  18767. /**
  18768. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  18769. */
  18770. keysRight: number[];
  18771. private _keys;
  18772. private _onCanvasBlurObserver;
  18773. private _onKeyboardObserver;
  18774. private _engine;
  18775. private _scene;
  18776. /**
  18777. * Attach the input controls to a specific dom element to get the input from.
  18778. * @param element Defines the element the controls should be listened from
  18779. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18780. */
  18781. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18782. /**
  18783. * Detach the current controls from the specified dom element.
  18784. * @param element Defines the element to stop listening the inputs from
  18785. */
  18786. detachControl(element: Nullable<HTMLElement>): void;
  18787. /**
  18788. * Update the current camera state depending on the inputs that have been used this frame.
  18789. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  18790. */
  18791. checkInputs(): void;
  18792. /**
  18793. * Gets the class name of the current intput.
  18794. * @returns the class name
  18795. */
  18796. getClassName(): string;
  18797. /** @hidden */
  18798. _onLostFocus(): void;
  18799. /**
  18800. * Get the friendly name associated with the input class.
  18801. * @returns the input friendly name
  18802. */
  18803. getSimpleName(): string;
  18804. }
  18805. }
  18806. declare module BABYLON {
  18807. /**
  18808. * Gather the list of pointer event types as constants.
  18809. */
  18810. export class PointerEventTypes {
  18811. /**
  18812. * 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.
  18813. */
  18814. static readonly POINTERDOWN: number;
  18815. /**
  18816. * The pointerup event is fired when a pointer is no longer active.
  18817. */
  18818. static readonly POINTERUP: number;
  18819. /**
  18820. * The pointermove event is fired when a pointer changes coordinates.
  18821. */
  18822. static readonly POINTERMOVE: number;
  18823. /**
  18824. * The pointerwheel event is fired when a mouse wheel has been rotated.
  18825. */
  18826. static readonly POINTERWHEEL: number;
  18827. /**
  18828. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  18829. */
  18830. static readonly POINTERPICK: number;
  18831. /**
  18832. * The pointertap event is fired when a the object has been touched and released without drag.
  18833. */
  18834. static readonly POINTERTAP: number;
  18835. /**
  18836. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  18837. */
  18838. static readonly POINTERDOUBLETAP: number;
  18839. }
  18840. /**
  18841. * Base class of pointer info types.
  18842. */
  18843. export class PointerInfoBase {
  18844. /**
  18845. * Defines the type of event (PointerEventTypes)
  18846. */
  18847. type: number;
  18848. /**
  18849. * Defines the related dom event
  18850. */
  18851. event: PointerEvent | MouseWheelEvent;
  18852. /**
  18853. * Instantiates the base class of pointers info.
  18854. * @param type Defines the type of event (PointerEventTypes)
  18855. * @param event Defines the related dom event
  18856. */
  18857. constructor(
  18858. /**
  18859. * Defines the type of event (PointerEventTypes)
  18860. */
  18861. type: number,
  18862. /**
  18863. * Defines the related dom event
  18864. */
  18865. event: PointerEvent | MouseWheelEvent);
  18866. }
  18867. /**
  18868. * This class is used to store pointer related info for the onPrePointerObservable event.
  18869. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  18870. */
  18871. export class PointerInfoPre extends PointerInfoBase {
  18872. /**
  18873. * Ray from a pointer if availible (eg. 6dof controller)
  18874. */
  18875. ray: Nullable<Ray>;
  18876. /**
  18877. * Defines the local position of the pointer on the canvas.
  18878. */
  18879. localPosition: Vector2;
  18880. /**
  18881. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  18882. */
  18883. skipOnPointerObservable: boolean;
  18884. /**
  18885. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  18886. * @param type Defines the type of event (PointerEventTypes)
  18887. * @param event Defines the related dom event
  18888. * @param localX Defines the local x coordinates of the pointer when the event occured
  18889. * @param localY Defines the local y coordinates of the pointer when the event occured
  18890. */
  18891. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  18892. }
  18893. /**
  18894. * This type contains all the data related to a pointer event in Babylon.js.
  18895. * 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.
  18896. */
  18897. export class PointerInfo extends PointerInfoBase {
  18898. /**
  18899. * Defines the picking info associated to the info (if any)\
  18900. */
  18901. pickInfo: Nullable<PickingInfo>;
  18902. /**
  18903. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  18904. * @param type Defines the type of event (PointerEventTypes)
  18905. * @param event Defines the related dom event
  18906. * @param pickInfo Defines the picking info associated to the info (if any)\
  18907. */
  18908. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  18909. /**
  18910. * Defines the picking info associated to the info (if any)\
  18911. */
  18912. pickInfo: Nullable<PickingInfo>);
  18913. }
  18914. /**
  18915. * Data relating to a touch event on the screen.
  18916. */
  18917. export interface PointerTouch {
  18918. /**
  18919. * X coordinate of touch.
  18920. */
  18921. x: number;
  18922. /**
  18923. * Y coordinate of touch.
  18924. */
  18925. y: number;
  18926. /**
  18927. * Id of touch. Unique for each finger.
  18928. */
  18929. pointerId: number;
  18930. /**
  18931. * Event type passed from DOM.
  18932. */
  18933. type: any;
  18934. }
  18935. }
  18936. declare module BABYLON {
  18937. /**
  18938. * Manage the mouse inputs to control the movement of a free camera.
  18939. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18940. */
  18941. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  18942. /**
  18943. * Define if touch is enabled in the mouse input
  18944. */
  18945. touchEnabled: boolean;
  18946. /**
  18947. * Defines the camera the input is attached to.
  18948. */
  18949. camera: FreeCamera;
  18950. /**
  18951. * Defines the buttons associated with the input to handle camera move.
  18952. */
  18953. buttons: number[];
  18954. /**
  18955. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  18956. */
  18957. angularSensibility: number;
  18958. private _pointerInput;
  18959. private _onMouseMove;
  18960. private _observer;
  18961. private previousPosition;
  18962. /**
  18963. * Observable for when a pointer move event occurs containing the move offset
  18964. */
  18965. onPointerMovedObservable: Observable<{
  18966. offsetX: number;
  18967. offsetY: number;
  18968. }>;
  18969. /**
  18970. * @hidden
  18971. * If the camera should be rotated automatically based on pointer movement
  18972. */
  18973. _allowCameraRotation: boolean;
  18974. /**
  18975. * Manage the mouse inputs to control the movement of a free camera.
  18976. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  18977. * @param touchEnabled Defines if touch is enabled or not
  18978. */
  18979. constructor(
  18980. /**
  18981. * Define if touch is enabled in the mouse input
  18982. */
  18983. touchEnabled?: boolean);
  18984. /**
  18985. * Attach the input controls to a specific dom element to get the input from.
  18986. * @param element Defines the element the controls should be listened from
  18987. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  18988. */
  18989. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  18990. /**
  18991. * Called on JS contextmenu event.
  18992. * Override this method to provide functionality.
  18993. */
  18994. protected onContextMenu(evt: PointerEvent): void;
  18995. /**
  18996. * Detach the current controls from the specified dom element.
  18997. * @param element Defines the element to stop listening the inputs from
  18998. */
  18999. detachControl(element: Nullable<HTMLElement>): void;
  19000. /**
  19001. * Gets the class name of the current intput.
  19002. * @returns the class name
  19003. */
  19004. getClassName(): string;
  19005. /**
  19006. * Get the friendly name associated with the input class.
  19007. * @returns the input friendly name
  19008. */
  19009. getSimpleName(): string;
  19010. }
  19011. }
  19012. declare module BABYLON {
  19013. /**
  19014. * Manage the touch inputs to control the movement of a free camera.
  19015. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19016. */
  19017. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  19018. /**
  19019. * Define if mouse events can be treated as touch events
  19020. */
  19021. allowMouse: boolean;
  19022. /**
  19023. * Defines the camera the input is attached to.
  19024. */
  19025. camera: FreeCamera;
  19026. /**
  19027. * Defines the touch sensibility for rotation.
  19028. * The higher the faster.
  19029. */
  19030. touchAngularSensibility: number;
  19031. /**
  19032. * Defines the touch sensibility for move.
  19033. * The higher the faster.
  19034. */
  19035. touchMoveSensibility: number;
  19036. private _offsetX;
  19037. private _offsetY;
  19038. private _pointerPressed;
  19039. private _pointerInput;
  19040. private _observer;
  19041. private _onLostFocus;
  19042. /**
  19043. * Manage the touch inputs to control the movement of a free camera.
  19044. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19045. * @param allowMouse Defines if mouse events can be treated as touch events
  19046. */
  19047. constructor(
  19048. /**
  19049. * Define if mouse events can be treated as touch events
  19050. */
  19051. allowMouse?: boolean);
  19052. /**
  19053. * Attach the input controls to a specific dom element to get the input from.
  19054. * @param element Defines the element the controls should be listened from
  19055. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19056. */
  19057. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19058. /**
  19059. * Detach the current controls from the specified dom element.
  19060. * @param element Defines the element to stop listening the inputs from
  19061. */
  19062. detachControl(element: Nullable<HTMLElement>): void;
  19063. /**
  19064. * Update the current camera state depending on the inputs that have been used this frame.
  19065. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  19066. */
  19067. checkInputs(): void;
  19068. /**
  19069. * Gets the class name of the current intput.
  19070. * @returns the class name
  19071. */
  19072. getClassName(): string;
  19073. /**
  19074. * Get the friendly name associated with the input class.
  19075. * @returns the input friendly name
  19076. */
  19077. getSimpleName(): string;
  19078. }
  19079. }
  19080. declare module BABYLON {
  19081. /**
  19082. * Default Inputs manager for the FreeCamera.
  19083. * It groups all the default supported inputs for ease of use.
  19084. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19085. */
  19086. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  19087. /**
  19088. * @hidden
  19089. */
  19090. _mouseInput: Nullable<FreeCameraMouseInput>;
  19091. /**
  19092. * Instantiates a new FreeCameraInputsManager.
  19093. * @param camera Defines the camera the inputs belong to
  19094. */
  19095. constructor(camera: FreeCamera);
  19096. /**
  19097. * Add keyboard input support to the input manager.
  19098. * @returns the current input manager
  19099. */
  19100. addKeyboard(): FreeCameraInputsManager;
  19101. /**
  19102. * Add mouse input support to the input manager.
  19103. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  19104. * @returns the current input manager
  19105. */
  19106. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  19107. /**
  19108. * Removes the mouse input support from the manager
  19109. * @returns the current input manager
  19110. */
  19111. removeMouse(): FreeCameraInputsManager;
  19112. /**
  19113. * Add touch input support to the input manager.
  19114. * @returns the current input manager
  19115. */
  19116. addTouch(): FreeCameraInputsManager;
  19117. /**
  19118. * Remove all attached input methods from a camera
  19119. */
  19120. clear(): void;
  19121. }
  19122. }
  19123. declare module BABYLON {
  19124. /**
  19125. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19126. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  19127. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19128. */
  19129. export class FreeCamera extends TargetCamera {
  19130. /**
  19131. * Define the collision ellipsoid of the camera.
  19132. * This is helpful to simulate a camera body like the player body around the camera
  19133. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  19134. */
  19135. ellipsoid: Vector3;
  19136. /**
  19137. * Define an offset for the position of the ellipsoid around the camera.
  19138. * This can be helpful to determine the center of the body near the gravity center of the body
  19139. * instead of its head.
  19140. */
  19141. ellipsoidOffset: Vector3;
  19142. /**
  19143. * Enable or disable collisions of the camera with the rest of the scene objects.
  19144. */
  19145. checkCollisions: boolean;
  19146. /**
  19147. * Enable or disable gravity on the camera.
  19148. */
  19149. applyGravity: boolean;
  19150. /**
  19151. * Define the input manager associated to the camera.
  19152. */
  19153. inputs: FreeCameraInputsManager;
  19154. /**
  19155. * Gets the input sensibility for a mouse input. (default is 2000.0)
  19156. * Higher values reduce sensitivity.
  19157. */
  19158. get angularSensibility(): number;
  19159. /**
  19160. * Sets the input sensibility for a mouse input. (default is 2000.0)
  19161. * Higher values reduce sensitivity.
  19162. */
  19163. set angularSensibility(value: number);
  19164. /**
  19165. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19166. */
  19167. get keysUp(): number[];
  19168. set keysUp(value: number[]);
  19169. /**
  19170. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19171. */
  19172. get keysUpward(): number[];
  19173. set keysUpward(value: number[]);
  19174. /**
  19175. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19176. */
  19177. get keysDown(): number[];
  19178. set keysDown(value: number[]);
  19179. /**
  19180. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19181. */
  19182. get keysDownward(): number[];
  19183. set keysDownward(value: number[]);
  19184. /**
  19185. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19186. */
  19187. get keysLeft(): number[];
  19188. set keysLeft(value: number[]);
  19189. /**
  19190. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19191. */
  19192. get keysRight(): number[];
  19193. set keysRight(value: number[]);
  19194. /**
  19195. * Event raised when the camera collide with a mesh in the scene.
  19196. */
  19197. onCollide: (collidedMesh: AbstractMesh) => void;
  19198. private _collider;
  19199. private _needMoveForGravity;
  19200. private _oldPosition;
  19201. private _diffPosition;
  19202. private _newPosition;
  19203. /** @hidden */
  19204. _localDirection: Vector3;
  19205. /** @hidden */
  19206. _transformedDirection: Vector3;
  19207. /**
  19208. * Instantiates a Free Camera.
  19209. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19210. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  19211. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19212. * @param name Define the name of the camera in the scene
  19213. * @param position Define the start position of the camera in the scene
  19214. * @param scene Define the scene the camera belongs to
  19215. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19216. */
  19217. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19218. /**
  19219. * Attached controls to the current camera.
  19220. * @param element Defines the element the controls should be listened from
  19221. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19222. */
  19223. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19224. /**
  19225. * Detach the current controls from the camera.
  19226. * The camera will stop reacting to inputs.
  19227. * @param element Defines the element to stop listening the inputs from
  19228. */
  19229. detachControl(element: HTMLElement): void;
  19230. private _collisionMask;
  19231. /**
  19232. * Define a collision mask to limit the list of object the camera can collide with
  19233. */
  19234. get collisionMask(): number;
  19235. set collisionMask(mask: number);
  19236. /** @hidden */
  19237. _collideWithWorld(displacement: Vector3): void;
  19238. private _onCollisionPositionChange;
  19239. /** @hidden */
  19240. _checkInputs(): void;
  19241. /** @hidden */
  19242. _decideIfNeedsToMove(): boolean;
  19243. /** @hidden */
  19244. _updatePosition(): void;
  19245. /**
  19246. * Destroy the camera and release the current resources hold by it.
  19247. */
  19248. dispose(): void;
  19249. /**
  19250. * Gets the current object class name.
  19251. * @return the class name
  19252. */
  19253. getClassName(): string;
  19254. }
  19255. }
  19256. declare module BABYLON {
  19257. /**
  19258. * Represents a gamepad control stick position
  19259. */
  19260. export class StickValues {
  19261. /**
  19262. * The x component of the control stick
  19263. */
  19264. x: number;
  19265. /**
  19266. * The y component of the control stick
  19267. */
  19268. y: number;
  19269. /**
  19270. * Initializes the gamepad x and y control stick values
  19271. * @param x The x component of the gamepad control stick value
  19272. * @param y The y component of the gamepad control stick value
  19273. */
  19274. constructor(
  19275. /**
  19276. * The x component of the control stick
  19277. */
  19278. x: number,
  19279. /**
  19280. * The y component of the control stick
  19281. */
  19282. y: number);
  19283. }
  19284. /**
  19285. * An interface which manages callbacks for gamepad button changes
  19286. */
  19287. export interface GamepadButtonChanges {
  19288. /**
  19289. * Called when a gamepad has been changed
  19290. */
  19291. changed: boolean;
  19292. /**
  19293. * Called when a gamepad press event has been triggered
  19294. */
  19295. pressChanged: boolean;
  19296. /**
  19297. * Called when a touch event has been triggered
  19298. */
  19299. touchChanged: boolean;
  19300. /**
  19301. * Called when a value has changed
  19302. */
  19303. valueChanged: boolean;
  19304. }
  19305. /**
  19306. * Represents a gamepad
  19307. */
  19308. export class Gamepad {
  19309. /**
  19310. * The id of the gamepad
  19311. */
  19312. id: string;
  19313. /**
  19314. * The index of the gamepad
  19315. */
  19316. index: number;
  19317. /**
  19318. * The browser gamepad
  19319. */
  19320. browserGamepad: any;
  19321. /**
  19322. * Specifies what type of gamepad this represents
  19323. */
  19324. type: number;
  19325. private _leftStick;
  19326. private _rightStick;
  19327. /** @hidden */
  19328. _isConnected: boolean;
  19329. private _leftStickAxisX;
  19330. private _leftStickAxisY;
  19331. private _rightStickAxisX;
  19332. private _rightStickAxisY;
  19333. /**
  19334. * Triggered when the left control stick has been changed
  19335. */
  19336. private _onleftstickchanged;
  19337. /**
  19338. * Triggered when the right control stick has been changed
  19339. */
  19340. private _onrightstickchanged;
  19341. /**
  19342. * Represents a gamepad controller
  19343. */
  19344. static GAMEPAD: number;
  19345. /**
  19346. * Represents a generic controller
  19347. */
  19348. static GENERIC: number;
  19349. /**
  19350. * Represents an XBox controller
  19351. */
  19352. static XBOX: number;
  19353. /**
  19354. * Represents a pose-enabled controller
  19355. */
  19356. static POSE_ENABLED: number;
  19357. /**
  19358. * Represents an Dual Shock controller
  19359. */
  19360. static DUALSHOCK: number;
  19361. /**
  19362. * Specifies whether the left control stick should be Y-inverted
  19363. */
  19364. protected _invertLeftStickY: boolean;
  19365. /**
  19366. * Specifies if the gamepad has been connected
  19367. */
  19368. get isConnected(): boolean;
  19369. /**
  19370. * Initializes the gamepad
  19371. * @param id The id of the gamepad
  19372. * @param index The index of the gamepad
  19373. * @param browserGamepad The browser gamepad
  19374. * @param leftStickX The x component of the left joystick
  19375. * @param leftStickY The y component of the left joystick
  19376. * @param rightStickX The x component of the right joystick
  19377. * @param rightStickY The y component of the right joystick
  19378. */
  19379. constructor(
  19380. /**
  19381. * The id of the gamepad
  19382. */
  19383. id: string,
  19384. /**
  19385. * The index of the gamepad
  19386. */
  19387. index: number,
  19388. /**
  19389. * The browser gamepad
  19390. */
  19391. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19392. /**
  19393. * Callback triggered when the left joystick has changed
  19394. * @param callback
  19395. */
  19396. onleftstickchanged(callback: (values: StickValues) => void): void;
  19397. /**
  19398. * Callback triggered when the right joystick has changed
  19399. * @param callback
  19400. */
  19401. onrightstickchanged(callback: (values: StickValues) => void): void;
  19402. /**
  19403. * Gets the left joystick
  19404. */
  19405. get leftStick(): StickValues;
  19406. /**
  19407. * Sets the left joystick values
  19408. */
  19409. set leftStick(newValues: StickValues);
  19410. /**
  19411. * Gets the right joystick
  19412. */
  19413. get rightStick(): StickValues;
  19414. /**
  19415. * Sets the right joystick value
  19416. */
  19417. set rightStick(newValues: StickValues);
  19418. /**
  19419. * Updates the gamepad joystick positions
  19420. */
  19421. update(): void;
  19422. /**
  19423. * Disposes the gamepad
  19424. */
  19425. dispose(): void;
  19426. }
  19427. /**
  19428. * Represents a generic gamepad
  19429. */
  19430. export class GenericPad extends Gamepad {
  19431. private _buttons;
  19432. private _onbuttondown;
  19433. private _onbuttonup;
  19434. /**
  19435. * Observable triggered when a button has been pressed
  19436. */
  19437. onButtonDownObservable: Observable<number>;
  19438. /**
  19439. * Observable triggered when a button has been released
  19440. */
  19441. onButtonUpObservable: Observable<number>;
  19442. /**
  19443. * Callback triggered when a button has been pressed
  19444. * @param callback Called when a button has been pressed
  19445. */
  19446. onbuttondown(callback: (buttonPressed: number) => void): void;
  19447. /**
  19448. * Callback triggered when a button has been released
  19449. * @param callback Called when a button has been released
  19450. */
  19451. onbuttonup(callback: (buttonReleased: number) => void): void;
  19452. /**
  19453. * Initializes the generic gamepad
  19454. * @param id The id of the generic gamepad
  19455. * @param index The index of the generic gamepad
  19456. * @param browserGamepad The browser gamepad
  19457. */
  19458. constructor(id: string, index: number, browserGamepad: any);
  19459. private _setButtonValue;
  19460. /**
  19461. * Updates the generic gamepad
  19462. */
  19463. update(): void;
  19464. /**
  19465. * Disposes the generic gamepad
  19466. */
  19467. dispose(): void;
  19468. }
  19469. }
  19470. declare module BABYLON {
  19471. /**
  19472. * Defines the types of pose enabled controllers that are supported
  19473. */
  19474. export enum PoseEnabledControllerType {
  19475. /**
  19476. * HTC Vive
  19477. */
  19478. VIVE = 0,
  19479. /**
  19480. * Oculus Rift
  19481. */
  19482. OCULUS = 1,
  19483. /**
  19484. * Windows mixed reality
  19485. */
  19486. WINDOWS = 2,
  19487. /**
  19488. * Samsung gear VR
  19489. */
  19490. GEAR_VR = 3,
  19491. /**
  19492. * Google Daydream
  19493. */
  19494. DAYDREAM = 4,
  19495. /**
  19496. * Generic
  19497. */
  19498. GENERIC = 5
  19499. }
  19500. /**
  19501. * Defines the MutableGamepadButton interface for the state of a gamepad button
  19502. */
  19503. export interface MutableGamepadButton {
  19504. /**
  19505. * Value of the button/trigger
  19506. */
  19507. value: number;
  19508. /**
  19509. * If the button/trigger is currently touched
  19510. */
  19511. touched: boolean;
  19512. /**
  19513. * If the button/trigger is currently pressed
  19514. */
  19515. pressed: boolean;
  19516. }
  19517. /**
  19518. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  19519. * @hidden
  19520. */
  19521. export interface ExtendedGamepadButton extends GamepadButton {
  19522. /**
  19523. * If the button/trigger is currently pressed
  19524. */
  19525. readonly pressed: boolean;
  19526. /**
  19527. * If the button/trigger is currently touched
  19528. */
  19529. readonly touched: boolean;
  19530. /**
  19531. * Value of the button/trigger
  19532. */
  19533. readonly value: number;
  19534. }
  19535. /** @hidden */
  19536. export interface _GamePadFactory {
  19537. /**
  19538. * Returns whether or not the current gamepad can be created for this type of controller.
  19539. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19540. * @returns true if it can be created, otherwise false
  19541. */
  19542. canCreate(gamepadInfo: any): boolean;
  19543. /**
  19544. * Creates a new instance of the Gamepad.
  19545. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  19546. * @returns the new gamepad instance
  19547. */
  19548. create(gamepadInfo: any): Gamepad;
  19549. }
  19550. /**
  19551. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19552. */
  19553. export class PoseEnabledControllerHelper {
  19554. /** @hidden */
  19555. static _ControllerFactories: _GamePadFactory[];
  19556. /** @hidden */
  19557. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  19558. /**
  19559. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  19560. * @param vrGamepad the gamepad to initialized
  19561. * @returns a vr controller of the type the gamepad identified as
  19562. */
  19563. static InitiateController(vrGamepad: any): Gamepad;
  19564. }
  19565. /**
  19566. * Defines the PoseEnabledController object that contains state of a vr capable controller
  19567. */
  19568. export class PoseEnabledController extends Gamepad implements PoseControlled {
  19569. /**
  19570. * If the controller is used in a webXR session
  19571. */
  19572. isXR: boolean;
  19573. private _deviceRoomPosition;
  19574. private _deviceRoomRotationQuaternion;
  19575. /**
  19576. * The device position in babylon space
  19577. */
  19578. devicePosition: Vector3;
  19579. /**
  19580. * The device rotation in babylon space
  19581. */
  19582. deviceRotationQuaternion: Quaternion;
  19583. /**
  19584. * The scale factor of the device in babylon space
  19585. */
  19586. deviceScaleFactor: number;
  19587. /**
  19588. * (Likely devicePosition should be used instead) The device position in its room space
  19589. */
  19590. position: Vector3;
  19591. /**
  19592. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  19593. */
  19594. rotationQuaternion: Quaternion;
  19595. /**
  19596. * The type of controller (Eg. Windows mixed reality)
  19597. */
  19598. controllerType: PoseEnabledControllerType;
  19599. protected _calculatedPosition: Vector3;
  19600. private _calculatedRotation;
  19601. /**
  19602. * The raw pose from the device
  19603. */
  19604. rawPose: DevicePose;
  19605. private _trackPosition;
  19606. private _maxRotationDistFromHeadset;
  19607. private _draggedRoomRotation;
  19608. /**
  19609. * @hidden
  19610. */
  19611. _disableTrackPosition(fixedPosition: Vector3): void;
  19612. /**
  19613. * Internal, the mesh attached to the controller
  19614. * @hidden
  19615. */
  19616. _mesh: Nullable<AbstractMesh>;
  19617. private _poseControlledCamera;
  19618. private _leftHandSystemQuaternion;
  19619. /**
  19620. * Internal, matrix used to convert room space to babylon space
  19621. * @hidden
  19622. */
  19623. _deviceToWorld: Matrix;
  19624. /**
  19625. * Node to be used when casting a ray from the controller
  19626. * @hidden
  19627. */
  19628. _pointingPoseNode: Nullable<TransformNode>;
  19629. /**
  19630. * Name of the child mesh that can be used to cast a ray from the controller
  19631. */
  19632. static readonly POINTING_POSE: string;
  19633. /**
  19634. * Creates a new PoseEnabledController from a gamepad
  19635. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  19636. */
  19637. constructor(browserGamepad: any);
  19638. private _workingMatrix;
  19639. /**
  19640. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  19641. */
  19642. update(): void;
  19643. /**
  19644. * Updates only the pose device and mesh without doing any button event checking
  19645. */
  19646. protected _updatePoseAndMesh(): void;
  19647. /**
  19648. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  19649. * @param poseData raw pose fromthe device
  19650. */
  19651. updateFromDevice(poseData: DevicePose): void;
  19652. /**
  19653. * @hidden
  19654. */
  19655. _meshAttachedObservable: Observable<AbstractMesh>;
  19656. /**
  19657. * Attaches a mesh to the controller
  19658. * @param mesh the mesh to be attached
  19659. */
  19660. attachToMesh(mesh: AbstractMesh): void;
  19661. /**
  19662. * Attaches the controllers mesh to a camera
  19663. * @param camera the camera the mesh should be attached to
  19664. */
  19665. attachToPoseControlledCamera(camera: TargetCamera): void;
  19666. /**
  19667. * Disposes of the controller
  19668. */
  19669. dispose(): void;
  19670. /**
  19671. * The mesh that is attached to the controller
  19672. */
  19673. get mesh(): Nullable<AbstractMesh>;
  19674. /**
  19675. * Gets the ray of the controller in the direction the controller is pointing
  19676. * @param length the length the resulting ray should be
  19677. * @returns a ray in the direction the controller is pointing
  19678. */
  19679. getForwardRay(length?: number): Ray;
  19680. }
  19681. }
  19682. declare module BABYLON {
  19683. /**
  19684. * Defines the WebVRController object that represents controllers tracked in 3D space
  19685. */
  19686. export abstract class WebVRController extends PoseEnabledController {
  19687. /**
  19688. * Internal, the default controller model for the controller
  19689. */
  19690. protected _defaultModel: Nullable<AbstractMesh>;
  19691. /**
  19692. * Fired when the trigger state has changed
  19693. */
  19694. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19695. /**
  19696. * Fired when the main button state has changed
  19697. */
  19698. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19699. /**
  19700. * Fired when the secondary button state has changed
  19701. */
  19702. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19703. /**
  19704. * Fired when the pad state has changed
  19705. */
  19706. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19707. /**
  19708. * Fired when controllers stick values have changed
  19709. */
  19710. onPadValuesChangedObservable: Observable<StickValues>;
  19711. /**
  19712. * Array of button availible on the controller
  19713. */
  19714. protected _buttons: Array<MutableGamepadButton>;
  19715. private _onButtonStateChange;
  19716. /**
  19717. * Fired when a controller button's state has changed
  19718. * @param callback the callback containing the button that was modified
  19719. */
  19720. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19721. /**
  19722. * X and Y axis corresponding to the controllers joystick
  19723. */
  19724. pad: StickValues;
  19725. /**
  19726. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  19727. */
  19728. hand: string;
  19729. /**
  19730. * The default controller model for the controller
  19731. */
  19732. get defaultModel(): Nullable<AbstractMesh>;
  19733. /**
  19734. * Creates a new WebVRController from a gamepad
  19735. * @param vrGamepad the gamepad that the WebVRController should be created from
  19736. */
  19737. constructor(vrGamepad: any);
  19738. /**
  19739. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  19740. */
  19741. update(): void;
  19742. /**
  19743. * Function to be called when a button is modified
  19744. */
  19745. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19746. /**
  19747. * Loads a mesh and attaches it to the controller
  19748. * @param scene the scene the mesh should be added to
  19749. * @param meshLoaded callback for when the mesh has been loaded
  19750. */
  19751. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19752. private _setButtonValue;
  19753. private _changes;
  19754. private _checkChanges;
  19755. /**
  19756. * Disposes of th webVRCOntroller
  19757. */
  19758. dispose(): void;
  19759. }
  19760. }
  19761. declare module BABYLON {
  19762. /**
  19763. * The HemisphericLight simulates the ambient environment light,
  19764. * so the passed direction is the light reflection direction, not the incoming direction.
  19765. */
  19766. export class HemisphericLight extends Light {
  19767. /**
  19768. * The groundColor is the light in the opposite direction to the one specified during creation.
  19769. * 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.
  19770. */
  19771. groundColor: Color3;
  19772. /**
  19773. * The light reflection direction, not the incoming direction.
  19774. */
  19775. direction: Vector3;
  19776. /**
  19777. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  19778. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  19779. * The HemisphericLight can't cast shadows.
  19780. * Documentation : https://doc.babylonjs.com/babylon101/lights
  19781. * @param name The friendly name of the light
  19782. * @param direction The direction of the light reflection
  19783. * @param scene The scene the light belongs to
  19784. */
  19785. constructor(name: string, direction: Vector3, scene: Scene);
  19786. protected _buildUniformLayout(): void;
  19787. /**
  19788. * Returns the string "HemisphericLight".
  19789. * @return The class name
  19790. */
  19791. getClassName(): string;
  19792. /**
  19793. * Sets the HemisphericLight direction towards the passed target (Vector3).
  19794. * Returns the updated direction.
  19795. * @param target The target the direction should point to
  19796. * @return The computed direction
  19797. */
  19798. setDirectionToTarget(target: Vector3): Vector3;
  19799. /**
  19800. * Returns the shadow generator associated to the light.
  19801. * @returns Always null for hemispheric lights because it does not support shadows.
  19802. */
  19803. getShadowGenerator(): Nullable<IShadowGenerator>;
  19804. /**
  19805. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  19806. * @param effect The effect to update
  19807. * @param lightIndex The index of the light in the effect to update
  19808. * @returns The hemispheric light
  19809. */
  19810. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  19811. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  19812. /**
  19813. * Computes the world matrix of the node
  19814. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  19815. * @param useWasUpdatedFlag defines a reserved property
  19816. * @returns the world matrix
  19817. */
  19818. computeWorldMatrix(): Matrix;
  19819. /**
  19820. * Returns the integer 3.
  19821. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  19822. */
  19823. getTypeID(): number;
  19824. /**
  19825. * Prepares the list of defines specific to the light type.
  19826. * @param defines the list of defines
  19827. * @param lightIndex defines the index of the light for the effect
  19828. */
  19829. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  19830. }
  19831. }
  19832. declare module BABYLON {
  19833. /** @hidden */
  19834. export var vrMultiviewToSingleviewPixelShader: {
  19835. name: string;
  19836. shader: string;
  19837. };
  19838. }
  19839. declare module BABYLON {
  19840. /**
  19841. * Renders to multiple views with a single draw call
  19842. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  19843. */
  19844. export class MultiviewRenderTarget extends RenderTargetTexture {
  19845. /**
  19846. * Creates a multiview render target
  19847. * @param scene scene used with the render target
  19848. * @param size the size of the render target (used for each view)
  19849. */
  19850. constructor(scene: Scene, size?: number | {
  19851. width: number;
  19852. height: number;
  19853. } | {
  19854. ratio: number;
  19855. });
  19856. /**
  19857. * @hidden
  19858. * @param faceIndex the face index, if its a cube texture
  19859. */
  19860. _bindFrameBuffer(faceIndex?: number): void;
  19861. /**
  19862. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19863. * @returns the view count
  19864. */
  19865. getViewCount(): number;
  19866. }
  19867. }
  19868. declare module BABYLON {
  19869. interface Engine {
  19870. /**
  19871. * Creates a new multiview render target
  19872. * @param width defines the width of the texture
  19873. * @param height defines the height of the texture
  19874. * @returns the created multiview texture
  19875. */
  19876. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  19877. /**
  19878. * Binds a multiview framebuffer to be drawn to
  19879. * @param multiviewTexture texture to bind
  19880. */
  19881. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  19882. }
  19883. interface Camera {
  19884. /**
  19885. * @hidden
  19886. * 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)
  19887. */
  19888. _useMultiviewToSingleView: boolean;
  19889. /**
  19890. * @hidden
  19891. * 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)
  19892. */
  19893. _multiviewTexture: Nullable<RenderTargetTexture>;
  19894. /**
  19895. * @hidden
  19896. * ensures the multiview texture of the camera exists and has the specified width/height
  19897. * @param width height to set on the multiview texture
  19898. * @param height width to set on the multiview texture
  19899. */
  19900. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  19901. }
  19902. interface Scene {
  19903. /** @hidden */
  19904. _transformMatrixR: Matrix;
  19905. /** @hidden */
  19906. _multiviewSceneUbo: Nullable<UniformBuffer>;
  19907. /** @hidden */
  19908. _createMultiviewUbo(): void;
  19909. /** @hidden */
  19910. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  19911. /** @hidden */
  19912. _renderMultiviewToSingleView(camera: Camera): void;
  19913. }
  19914. }
  19915. declare module BABYLON {
  19916. /**
  19917. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  19918. * This will not be used for webXR as it supports displaying texture arrays directly
  19919. */
  19920. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  19921. /**
  19922. * Gets a string identifying the name of the class
  19923. * @returns "VRMultiviewToSingleviewPostProcess" string
  19924. */
  19925. getClassName(): string;
  19926. /**
  19927. * Initializes a VRMultiviewToSingleview
  19928. * @param name name of the post process
  19929. * @param camera camera to be applied to
  19930. * @param scaleFactor scaling factor to the size of the output texture
  19931. */
  19932. constructor(name: string, camera: Camera, scaleFactor: number);
  19933. }
  19934. }
  19935. declare module BABYLON {
  19936. /**
  19937. * Interface used to define additional presentation attributes
  19938. */
  19939. export interface IVRPresentationAttributes {
  19940. /**
  19941. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  19942. */
  19943. highRefreshRate: boolean;
  19944. /**
  19945. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  19946. */
  19947. foveationLevel: number;
  19948. }
  19949. interface Engine {
  19950. /** @hidden */
  19951. _vrDisplay: any;
  19952. /** @hidden */
  19953. _vrSupported: boolean;
  19954. /** @hidden */
  19955. _oldSize: Size;
  19956. /** @hidden */
  19957. _oldHardwareScaleFactor: number;
  19958. /** @hidden */
  19959. _vrExclusivePointerMode: boolean;
  19960. /** @hidden */
  19961. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  19962. /** @hidden */
  19963. _onVRDisplayPointerRestricted: () => void;
  19964. /** @hidden */
  19965. _onVRDisplayPointerUnrestricted: () => void;
  19966. /** @hidden */
  19967. _onVrDisplayConnect: Nullable<(display: any) => void>;
  19968. /** @hidden */
  19969. _onVrDisplayDisconnect: Nullable<() => void>;
  19970. /** @hidden */
  19971. _onVrDisplayPresentChange: Nullable<() => void>;
  19972. /**
  19973. * Observable signaled when VR display mode changes
  19974. */
  19975. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  19976. /**
  19977. * Observable signaled when VR request present is complete
  19978. */
  19979. onVRRequestPresentComplete: Observable<boolean>;
  19980. /**
  19981. * Observable signaled when VR request present starts
  19982. */
  19983. onVRRequestPresentStart: Observable<Engine>;
  19984. /**
  19985. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  19986. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  19987. */
  19988. isInVRExclusivePointerMode: boolean;
  19989. /**
  19990. * Gets a boolean indicating if a webVR device was detected
  19991. * @returns true if a webVR device was detected
  19992. */
  19993. isVRDevicePresent(): boolean;
  19994. /**
  19995. * Gets the current webVR device
  19996. * @returns the current webVR device (or null)
  19997. */
  19998. getVRDevice(): any;
  19999. /**
  20000. * Initializes a webVR display and starts listening to display change events
  20001. * The onVRDisplayChangedObservable will be notified upon these changes
  20002. * @returns A promise containing a VRDisplay and if vr is supported
  20003. */
  20004. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  20005. /** @hidden */
  20006. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  20007. /**
  20008. * Gets or sets the presentation attributes used to configure VR rendering
  20009. */
  20010. vrPresentationAttributes?: IVRPresentationAttributes;
  20011. /**
  20012. * Call this function to switch to webVR mode
  20013. * Will do nothing if webVR is not supported or if there is no webVR device
  20014. * @param options the webvr options provided to the camera. mainly used for multiview
  20015. * @see https://doc.babylonjs.com/how_to/webvr_camera
  20016. */
  20017. enableVR(options: WebVROptions): void;
  20018. /** @hidden */
  20019. _onVRFullScreenTriggered(): void;
  20020. }
  20021. }
  20022. declare module BABYLON {
  20023. /**
  20024. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  20025. * IMPORTANT!! The data is right-hand data.
  20026. * @export
  20027. * @interface DevicePose
  20028. */
  20029. export interface DevicePose {
  20030. /**
  20031. * The position of the device, values in array are [x,y,z].
  20032. */
  20033. readonly position: Nullable<Float32Array>;
  20034. /**
  20035. * The linearVelocity of the device, values in array are [x,y,z].
  20036. */
  20037. readonly linearVelocity: Nullable<Float32Array>;
  20038. /**
  20039. * The linearAcceleration of the device, values in array are [x,y,z].
  20040. */
  20041. readonly linearAcceleration: Nullable<Float32Array>;
  20042. /**
  20043. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  20044. */
  20045. readonly orientation: Nullable<Float32Array>;
  20046. /**
  20047. * The angularVelocity of the device, values in array are [x,y,z].
  20048. */
  20049. readonly angularVelocity: Nullable<Float32Array>;
  20050. /**
  20051. * The angularAcceleration of the device, values in array are [x,y,z].
  20052. */
  20053. readonly angularAcceleration: Nullable<Float32Array>;
  20054. }
  20055. /**
  20056. * Interface representing a pose controlled object in Babylon.
  20057. * A pose controlled object has both regular pose values as well as pose values
  20058. * from an external device such as a VR head mounted display
  20059. */
  20060. export interface PoseControlled {
  20061. /**
  20062. * The position of the object in babylon space.
  20063. */
  20064. position: Vector3;
  20065. /**
  20066. * The rotation quaternion of the object in babylon space.
  20067. */
  20068. rotationQuaternion: Quaternion;
  20069. /**
  20070. * The position of the device in babylon space.
  20071. */
  20072. devicePosition?: Vector3;
  20073. /**
  20074. * The rotation quaternion of the device in babylon space.
  20075. */
  20076. deviceRotationQuaternion: Quaternion;
  20077. /**
  20078. * The raw pose coming from the device.
  20079. */
  20080. rawPose: Nullable<DevicePose>;
  20081. /**
  20082. * The scale of the device to be used when translating from device space to babylon space.
  20083. */
  20084. deviceScaleFactor: number;
  20085. /**
  20086. * Updates the poseControlled values based on the input device pose.
  20087. * @param poseData the pose data to update the object with
  20088. */
  20089. updateFromDevice(poseData: DevicePose): void;
  20090. }
  20091. /**
  20092. * Set of options to customize the webVRCamera
  20093. */
  20094. export interface WebVROptions {
  20095. /**
  20096. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  20097. */
  20098. trackPosition?: boolean;
  20099. /**
  20100. * Sets the scale of the vrDevice in babylon space. (default: 1)
  20101. */
  20102. positionScale?: number;
  20103. /**
  20104. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  20105. */
  20106. displayName?: string;
  20107. /**
  20108. * Should the native controller meshes be initialized. (default: true)
  20109. */
  20110. controllerMeshes?: boolean;
  20111. /**
  20112. * Creating a default HemiLight only on controllers. (default: true)
  20113. */
  20114. defaultLightingOnControllers?: boolean;
  20115. /**
  20116. * If you don't want to use the default VR button of the helper. (default: false)
  20117. */
  20118. useCustomVRButton?: boolean;
  20119. /**
  20120. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  20121. */
  20122. customVRButton?: HTMLButtonElement;
  20123. /**
  20124. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  20125. */
  20126. rayLength?: number;
  20127. /**
  20128. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  20129. */
  20130. defaultHeight?: number;
  20131. /**
  20132. * If multiview should be used if availible (default: false)
  20133. */
  20134. useMultiview?: boolean;
  20135. }
  20136. /**
  20137. * This represents a WebVR camera.
  20138. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  20139. * @example https://doc.babylonjs.com/how_to/webvr_camera
  20140. */
  20141. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  20142. private webVROptions;
  20143. /**
  20144. * @hidden
  20145. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  20146. */
  20147. _vrDevice: any;
  20148. /**
  20149. * The rawPose of the vrDevice.
  20150. */
  20151. rawPose: Nullable<DevicePose>;
  20152. private _onVREnabled;
  20153. private _specsVersion;
  20154. private _attached;
  20155. private _frameData;
  20156. protected _descendants: Array<Node>;
  20157. private _deviceRoomPosition;
  20158. /** @hidden */
  20159. _deviceRoomRotationQuaternion: Quaternion;
  20160. private _standingMatrix;
  20161. /**
  20162. * Represents device position in babylon space.
  20163. */
  20164. devicePosition: Vector3;
  20165. /**
  20166. * Represents device rotation in babylon space.
  20167. */
  20168. deviceRotationQuaternion: Quaternion;
  20169. /**
  20170. * The scale of the device to be used when translating from device space to babylon space.
  20171. */
  20172. deviceScaleFactor: number;
  20173. private _deviceToWorld;
  20174. private _worldToDevice;
  20175. /**
  20176. * References to the webVR controllers for the vrDevice.
  20177. */
  20178. controllers: Array<WebVRController>;
  20179. /**
  20180. * Emits an event when a controller is attached.
  20181. */
  20182. onControllersAttachedObservable: Observable<WebVRController[]>;
  20183. /**
  20184. * Emits an event when a controller's mesh has been loaded;
  20185. */
  20186. onControllerMeshLoadedObservable: Observable<WebVRController>;
  20187. /**
  20188. * Emits an event when the HMD's pose has been updated.
  20189. */
  20190. onPoseUpdatedFromDeviceObservable: Observable<any>;
  20191. private _poseSet;
  20192. /**
  20193. * If the rig cameras be used as parent instead of this camera.
  20194. */
  20195. rigParenting: boolean;
  20196. private _lightOnControllers;
  20197. private _defaultHeight?;
  20198. /**
  20199. * Instantiates a WebVRFreeCamera.
  20200. * @param name The name of the WebVRFreeCamera
  20201. * @param position The starting anchor position for the camera
  20202. * @param scene The scene the camera belongs to
  20203. * @param webVROptions a set of customizable options for the webVRCamera
  20204. */
  20205. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  20206. /**
  20207. * Gets the device distance from the ground in meters.
  20208. * @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.
  20209. */
  20210. deviceDistanceToRoomGround(): number;
  20211. /**
  20212. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20213. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  20214. */
  20215. useStandingMatrix(callback?: (bool: boolean) => void): void;
  20216. /**
  20217. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20218. * @returns A promise with a boolean set to if the standing matrix is supported.
  20219. */
  20220. useStandingMatrixAsync(): Promise<boolean>;
  20221. /**
  20222. * Disposes the camera
  20223. */
  20224. dispose(): void;
  20225. /**
  20226. * Gets a vrController by name.
  20227. * @param name The name of the controller to retreive
  20228. * @returns the controller matching the name specified or null if not found
  20229. */
  20230. getControllerByName(name: string): Nullable<WebVRController>;
  20231. private _leftController;
  20232. /**
  20233. * The controller corresponding to the users left hand.
  20234. */
  20235. get leftController(): Nullable<WebVRController>;
  20236. private _rightController;
  20237. /**
  20238. * The controller corresponding to the users right hand.
  20239. */
  20240. get rightController(): Nullable<WebVRController>;
  20241. /**
  20242. * Casts a ray forward from the vrCamera's gaze.
  20243. * @param length Length of the ray (default: 100)
  20244. * @returns the ray corresponding to the gaze
  20245. */
  20246. getForwardRay(length?: number): Ray;
  20247. /**
  20248. * @hidden
  20249. * Updates the camera based on device's frame data
  20250. */
  20251. _checkInputs(): void;
  20252. /**
  20253. * Updates the poseControlled values based on the input device pose.
  20254. * @param poseData Pose coming from the device
  20255. */
  20256. updateFromDevice(poseData: DevicePose): void;
  20257. private _htmlElementAttached;
  20258. private _detachIfAttached;
  20259. /**
  20260. * WebVR's attach control will start broadcasting frames to the device.
  20261. * Note that in certain browsers (chrome for example) this function must be called
  20262. * within a user-interaction callback. Example:
  20263. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  20264. *
  20265. * @param element html element to attach the vrDevice to
  20266. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  20267. */
  20268. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  20269. /**
  20270. * Detaches the camera from the html element and disables VR
  20271. *
  20272. * @param element html element to detach from
  20273. */
  20274. detachControl(element: HTMLElement): void;
  20275. /**
  20276. * @returns the name of this class
  20277. */
  20278. getClassName(): string;
  20279. /**
  20280. * Calls resetPose on the vrDisplay
  20281. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  20282. */
  20283. resetToCurrentRotation(): void;
  20284. /**
  20285. * @hidden
  20286. * Updates the rig cameras (left and right eye)
  20287. */
  20288. _updateRigCameras(): void;
  20289. private _workingVector;
  20290. private _oneVector;
  20291. private _workingMatrix;
  20292. private updateCacheCalled;
  20293. private _correctPositionIfNotTrackPosition;
  20294. /**
  20295. * @hidden
  20296. * Updates the cached values of the camera
  20297. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  20298. */
  20299. _updateCache(ignoreParentClass?: boolean): void;
  20300. /**
  20301. * @hidden
  20302. * Get current device position in babylon world
  20303. */
  20304. _computeDevicePosition(): void;
  20305. /**
  20306. * Updates the current device position and rotation in the babylon world
  20307. */
  20308. update(): void;
  20309. /**
  20310. * @hidden
  20311. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  20312. * @returns an identity matrix
  20313. */
  20314. _getViewMatrix(): Matrix;
  20315. private _tmpMatrix;
  20316. /**
  20317. * This function is called by the two RIG cameras.
  20318. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  20319. * @hidden
  20320. */
  20321. _getWebVRViewMatrix(): Matrix;
  20322. /** @hidden */
  20323. _getWebVRProjectionMatrix(): Matrix;
  20324. private _onGamepadConnectedObserver;
  20325. private _onGamepadDisconnectedObserver;
  20326. private _updateCacheWhenTrackingDisabledObserver;
  20327. /**
  20328. * Initializes the controllers and their meshes
  20329. */
  20330. initControllers(): void;
  20331. }
  20332. }
  20333. declare module BABYLON {
  20334. /**
  20335. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  20336. *
  20337. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  20338. *
  20339. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  20340. */
  20341. export class MaterialHelper {
  20342. /**
  20343. * Bind the current view position to an effect.
  20344. * @param effect The effect to be bound
  20345. * @param scene The scene the eyes position is used from
  20346. * @param variableName name of the shader variable that will hold the eye position
  20347. */
  20348. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  20349. /**
  20350. * Helps preparing the defines values about the UVs in used in the effect.
  20351. * UVs are shared as much as we can accross channels in the shaders.
  20352. * @param texture The texture we are preparing the UVs for
  20353. * @param defines The defines to update
  20354. * @param key The channel key "diffuse", "specular"... used in the shader
  20355. */
  20356. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  20357. /**
  20358. * Binds a texture matrix value to its corrsponding uniform
  20359. * @param texture The texture to bind the matrix for
  20360. * @param uniformBuffer The uniform buffer receivin the data
  20361. * @param key The channel key "diffuse", "specular"... used in the shader
  20362. */
  20363. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  20364. /**
  20365. * Gets the current status of the fog (should it be enabled?)
  20366. * @param mesh defines the mesh to evaluate for fog support
  20367. * @param scene defines the hosting scene
  20368. * @returns true if fog must be enabled
  20369. */
  20370. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  20371. /**
  20372. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  20373. * @param mesh defines the current mesh
  20374. * @param scene defines the current scene
  20375. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  20376. * @param pointsCloud defines if point cloud rendering has to be turned on
  20377. * @param fogEnabled defines if fog has to be turned on
  20378. * @param alphaTest defines if alpha testing has to be turned on
  20379. * @param defines defines the current list of defines
  20380. */
  20381. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  20382. /**
  20383. * Helper used to prepare the list of defines associated with frame values for shader compilation
  20384. * @param scene defines the current scene
  20385. * @param engine defines the current engine
  20386. * @param defines specifies the list of active defines
  20387. * @param useInstances defines if instances have to be turned on
  20388. * @param useClipPlane defines if clip plane have to be turned on
  20389. * @param useInstances defines if instances have to be turned on
  20390. * @param useThinInstances defines if thin instances have to be turned on
  20391. */
  20392. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  20393. /**
  20394. * Prepares the defines for bones
  20395. * @param mesh The mesh containing the geometry data we will draw
  20396. * @param defines The defines to update
  20397. */
  20398. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  20399. /**
  20400. * Prepares the defines for morph targets
  20401. * @param mesh The mesh containing the geometry data we will draw
  20402. * @param defines The defines to update
  20403. */
  20404. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  20405. /**
  20406. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  20407. * @param mesh The mesh containing the geometry data we will draw
  20408. * @param defines The defines to update
  20409. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  20410. * @param useBones Precise whether bones should be used or not (override mesh info)
  20411. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  20412. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  20413. * @returns false if defines are considered not dirty and have not been checked
  20414. */
  20415. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  20416. /**
  20417. * Prepares the defines related to multiview
  20418. * @param scene The scene we are intending to draw
  20419. * @param defines The defines to update
  20420. */
  20421. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  20422. /**
  20423. * Prepares the defines related to the prepass
  20424. * @param scene The scene we are intending to draw
  20425. * @param defines The defines to update
  20426. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  20427. */
  20428. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  20429. /**
  20430. * Prepares the defines related to the light information passed in parameter
  20431. * @param scene The scene we are intending to draw
  20432. * @param mesh The mesh the effect is compiling for
  20433. * @param light The light the effect is compiling for
  20434. * @param lightIndex The index of the light
  20435. * @param defines The defines to update
  20436. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20437. * @param state Defines the current state regarding what is needed (normals, etc...)
  20438. */
  20439. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  20440. needNormals: boolean;
  20441. needRebuild: boolean;
  20442. shadowEnabled: boolean;
  20443. specularEnabled: boolean;
  20444. lightmapMode: boolean;
  20445. }): void;
  20446. /**
  20447. * Prepares the defines related to the light information passed in parameter
  20448. * @param scene The scene we are intending to draw
  20449. * @param mesh The mesh the effect is compiling for
  20450. * @param defines The defines to update
  20451. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  20452. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  20453. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  20454. * @returns true if normals will be required for the rest of the effect
  20455. */
  20456. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  20457. /**
  20458. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  20459. * @param lightIndex defines the light index
  20460. * @param uniformsList The uniform list
  20461. * @param samplersList The sampler list
  20462. * @param projectedLightTexture defines if projected texture must be used
  20463. * @param uniformBuffersList defines an optional list of uniform buffers
  20464. */
  20465. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  20466. /**
  20467. * Prepares the uniforms and samplers list to be used in the effect
  20468. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  20469. * @param samplersList The sampler list
  20470. * @param defines The defines helping in the list generation
  20471. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  20472. */
  20473. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  20474. /**
  20475. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  20476. * @param defines The defines to update while falling back
  20477. * @param fallbacks The authorized effect fallbacks
  20478. * @param maxSimultaneousLights The maximum number of lights allowed
  20479. * @param rank the current rank of the Effect
  20480. * @returns The newly affected rank
  20481. */
  20482. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  20483. private static _TmpMorphInfluencers;
  20484. /**
  20485. * Prepares the list of attributes required for morph targets according to the effect defines.
  20486. * @param attribs The current list of supported attribs
  20487. * @param mesh The mesh to prepare the morph targets attributes for
  20488. * @param influencers The number of influencers
  20489. */
  20490. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  20491. /**
  20492. * Prepares the list of attributes required for morph targets according to the effect defines.
  20493. * @param attribs The current list of supported attribs
  20494. * @param mesh The mesh to prepare the morph targets attributes for
  20495. * @param defines The current Defines of the effect
  20496. */
  20497. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  20498. /**
  20499. * Prepares the list of attributes required for bones according to the effect defines.
  20500. * @param attribs The current list of supported attribs
  20501. * @param mesh The mesh to prepare the bones attributes for
  20502. * @param defines The current Defines of the effect
  20503. * @param fallbacks The current efffect fallback strategy
  20504. */
  20505. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  20506. /**
  20507. * Check and prepare the list of attributes required for instances according to the effect defines.
  20508. * @param attribs The current list of supported attribs
  20509. * @param defines The current MaterialDefines of the effect
  20510. */
  20511. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  20512. /**
  20513. * Add the list of attributes required for instances to the attribs array.
  20514. * @param attribs The current list of supported attribs
  20515. */
  20516. static PushAttributesForInstances(attribs: string[]): void;
  20517. /**
  20518. * Binds the light information to the effect.
  20519. * @param light The light containing the generator
  20520. * @param effect The effect we are binding the data to
  20521. * @param lightIndex The light index in the effect used to render
  20522. */
  20523. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  20524. /**
  20525. * Binds the lights information from the scene to the effect for the given mesh.
  20526. * @param light Light to bind
  20527. * @param lightIndex Light index
  20528. * @param scene The scene where the light belongs to
  20529. * @param effect The effect we are binding the data to
  20530. * @param useSpecular Defines if specular is supported
  20531. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20532. */
  20533. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  20534. /**
  20535. * Binds the lights information from the scene to the effect for the given mesh.
  20536. * @param scene The scene the lights belongs to
  20537. * @param mesh The mesh we are binding the information to render
  20538. * @param effect The effect we are binding the data to
  20539. * @param defines The generated defines for the effect
  20540. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  20541. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  20542. */
  20543. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  20544. private static _tempFogColor;
  20545. /**
  20546. * Binds the fog information from the scene to the effect for the given mesh.
  20547. * @param scene The scene the lights belongs to
  20548. * @param mesh The mesh we are binding the information to render
  20549. * @param effect The effect we are binding the data to
  20550. * @param linearSpace Defines if the fog effect is applied in linear space
  20551. */
  20552. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  20553. /**
  20554. * Binds the bones information from the mesh to the effect.
  20555. * @param mesh The mesh we are binding the information to render
  20556. * @param effect The effect we are binding the data to
  20557. * @param prePassConfiguration Configuration for the prepass, in case prepass is activated
  20558. */
  20559. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect, prePassConfiguration?: PrePassConfiguration): void;
  20560. private static _CopyBonesTransformationMatrices;
  20561. /**
  20562. * Binds the morph targets information from the mesh to the effect.
  20563. * @param abstractMesh The mesh we are binding the information to render
  20564. * @param effect The effect we are binding the data to
  20565. */
  20566. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  20567. /**
  20568. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  20569. * @param defines The generated defines used in the effect
  20570. * @param effect The effect we are binding the data to
  20571. * @param scene The scene we are willing to render with logarithmic scale for
  20572. */
  20573. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  20574. /**
  20575. * Binds the clip plane information from the scene to the effect.
  20576. * @param scene The scene the clip plane information are extracted from
  20577. * @param effect The effect we are binding the data to
  20578. */
  20579. static BindClipPlane(effect: Effect, scene: Scene): void;
  20580. }
  20581. }
  20582. declare module BABYLON {
  20583. /**
  20584. * Block used to expose an input value
  20585. */
  20586. export class InputBlock extends NodeMaterialBlock {
  20587. private _mode;
  20588. private _associatedVariableName;
  20589. private _storedValue;
  20590. private _valueCallback;
  20591. private _type;
  20592. private _animationType;
  20593. /** Gets or set a value used to limit the range of float values */
  20594. min: number;
  20595. /** Gets or set a value used to limit the range of float values */
  20596. max: number;
  20597. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  20598. isBoolean: boolean;
  20599. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  20600. matrixMode: number;
  20601. /** @hidden */
  20602. _systemValue: Nullable<NodeMaterialSystemValues>;
  20603. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  20604. isConstant: boolean;
  20605. /** Gets or sets the group to use to display this block in the Inspector */
  20606. groupInInspector: string;
  20607. /** Gets an observable raised when the value is changed */
  20608. onValueChangedObservable: Observable<InputBlock>;
  20609. /**
  20610. * Gets or sets the connection point type (default is float)
  20611. */
  20612. get type(): NodeMaterialBlockConnectionPointTypes;
  20613. /**
  20614. * Creates a new InputBlock
  20615. * @param name defines the block name
  20616. * @param target defines the target of that block (Vertex by default)
  20617. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  20618. */
  20619. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  20620. /**
  20621. * Validates if a name is a reserve word.
  20622. * @param newName the new name to be given to the node.
  20623. * @returns false if the name is a reserve word, else true.
  20624. */
  20625. validateBlockName(newName: string): boolean;
  20626. /**
  20627. * Gets the output component
  20628. */
  20629. get output(): NodeMaterialConnectionPoint;
  20630. /**
  20631. * Set the source of this connection point to a vertex attribute
  20632. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  20633. * @returns the current connection point
  20634. */
  20635. setAsAttribute(attributeName?: string): InputBlock;
  20636. /**
  20637. * Set the source of this connection point to a system value
  20638. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  20639. * @returns the current connection point
  20640. */
  20641. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  20642. /**
  20643. * Gets or sets the value of that point.
  20644. * Please note that this value will be ignored if valueCallback is defined
  20645. */
  20646. get value(): any;
  20647. set value(value: any);
  20648. /**
  20649. * Gets or sets a callback used to get the value of that point.
  20650. * Please note that setting this value will force the connection point to ignore the value property
  20651. */
  20652. get valueCallback(): () => any;
  20653. set valueCallback(value: () => any);
  20654. /**
  20655. * Gets or sets the associated variable name in the shader
  20656. */
  20657. get associatedVariableName(): string;
  20658. set associatedVariableName(value: string);
  20659. /** Gets or sets the type of animation applied to the input */
  20660. get animationType(): AnimatedInputBlockTypes;
  20661. set animationType(value: AnimatedInputBlockTypes);
  20662. /**
  20663. * Gets a boolean indicating that this connection point not defined yet
  20664. */
  20665. get isUndefined(): boolean;
  20666. /**
  20667. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  20668. * In this case the connection point name must be the name of the uniform to use.
  20669. * Can only be set on inputs
  20670. */
  20671. get isUniform(): boolean;
  20672. set isUniform(value: boolean);
  20673. /**
  20674. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  20675. * In this case the connection point name must be the name of the attribute to use
  20676. * Can only be set on inputs
  20677. */
  20678. get isAttribute(): boolean;
  20679. set isAttribute(value: boolean);
  20680. /**
  20681. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  20682. * Can only be set on exit points
  20683. */
  20684. get isVarying(): boolean;
  20685. set isVarying(value: boolean);
  20686. /**
  20687. * Gets a boolean indicating that the current connection point is a system value
  20688. */
  20689. get isSystemValue(): boolean;
  20690. /**
  20691. * Gets or sets the current well known value or null if not defined as a system value
  20692. */
  20693. get systemValue(): Nullable<NodeMaterialSystemValues>;
  20694. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  20695. /**
  20696. * Gets the current class name
  20697. * @returns the class name
  20698. */
  20699. getClassName(): string;
  20700. /**
  20701. * Animate the input if animationType !== None
  20702. * @param scene defines the rendering scene
  20703. */
  20704. animate(scene: Scene): void;
  20705. private _emitDefine;
  20706. initialize(state: NodeMaterialBuildState): void;
  20707. /**
  20708. * Set the input block to its default value (based on its type)
  20709. */
  20710. setDefaultValue(): void;
  20711. private _emitConstant;
  20712. /** @hidden */
  20713. get _noContextSwitch(): boolean;
  20714. private _emit;
  20715. /** @hidden */
  20716. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  20717. /** @hidden */
  20718. _transmit(effect: Effect, scene: Scene): void;
  20719. protected _buildBlock(state: NodeMaterialBuildState): void;
  20720. protected _dumpPropertiesCode(): string;
  20721. dispose(): void;
  20722. serialize(): any;
  20723. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  20724. }
  20725. }
  20726. declare module BABYLON {
  20727. /**
  20728. * Enum used to define the compatibility state between two connection points
  20729. */
  20730. export enum NodeMaterialConnectionPointCompatibilityStates {
  20731. /** Points are compatibles */
  20732. Compatible = 0,
  20733. /** Points are incompatible because of their types */
  20734. TypeIncompatible = 1,
  20735. /** Points are incompatible because of their targets (vertex vs fragment) */
  20736. TargetIncompatible = 2
  20737. }
  20738. /**
  20739. * Defines the direction of a connection point
  20740. */
  20741. export enum NodeMaterialConnectionPointDirection {
  20742. /** Input */
  20743. Input = 0,
  20744. /** Output */
  20745. Output = 1
  20746. }
  20747. /**
  20748. * Defines a connection point for a block
  20749. */
  20750. export class NodeMaterialConnectionPoint {
  20751. /** @hidden */
  20752. _ownerBlock: NodeMaterialBlock;
  20753. /** @hidden */
  20754. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  20755. private _endpoints;
  20756. private _associatedVariableName;
  20757. private _direction;
  20758. /** @hidden */
  20759. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20760. /** @hidden */
  20761. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  20762. private _type;
  20763. /** @hidden */
  20764. _enforceAssociatedVariableName: boolean;
  20765. /** Gets the direction of the point */
  20766. get direction(): NodeMaterialConnectionPointDirection;
  20767. /** Indicates that this connection point needs dual validation before being connected to another point */
  20768. needDualDirectionValidation: boolean;
  20769. /**
  20770. * Gets or sets the additional types supported by this connection point
  20771. */
  20772. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20773. /**
  20774. * Gets or sets the additional types excluded by this connection point
  20775. */
  20776. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  20777. /**
  20778. * Observable triggered when this point is connected
  20779. */
  20780. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  20781. /**
  20782. * Gets or sets the associated variable name in the shader
  20783. */
  20784. get associatedVariableName(): string;
  20785. set associatedVariableName(value: string);
  20786. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  20787. get innerType(): NodeMaterialBlockConnectionPointTypes;
  20788. /**
  20789. * Gets or sets the connection point type (default is float)
  20790. */
  20791. get type(): NodeMaterialBlockConnectionPointTypes;
  20792. set type(value: NodeMaterialBlockConnectionPointTypes);
  20793. /**
  20794. * Gets or sets the connection point name
  20795. */
  20796. name: string;
  20797. /**
  20798. * Gets or sets the connection point name
  20799. */
  20800. displayName: string;
  20801. /**
  20802. * Gets or sets a boolean indicating that this connection point can be omitted
  20803. */
  20804. isOptional: boolean;
  20805. /**
  20806. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  20807. */
  20808. isExposedOnFrame: boolean;
  20809. /**
  20810. * Gets or sets number indicating the position that the port is exposed to on a frame
  20811. */
  20812. exposedPortPosition: number;
  20813. /**
  20814. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  20815. */
  20816. define: string;
  20817. /** @hidden */
  20818. _prioritizeVertex: boolean;
  20819. private _target;
  20820. /** Gets or sets the target of that connection point */
  20821. get target(): NodeMaterialBlockTargets;
  20822. set target(value: NodeMaterialBlockTargets);
  20823. /**
  20824. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  20825. */
  20826. get isConnected(): boolean;
  20827. /**
  20828. * Gets a boolean indicating that the current point is connected to an input block
  20829. */
  20830. get isConnectedToInputBlock(): boolean;
  20831. /**
  20832. * Gets a the connected input block (if any)
  20833. */
  20834. get connectInputBlock(): Nullable<InputBlock>;
  20835. /** Get the other side of the connection (if any) */
  20836. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  20837. /** Get the block that owns this connection point */
  20838. get ownerBlock(): NodeMaterialBlock;
  20839. /** Get the block connected on the other side of this connection (if any) */
  20840. get sourceBlock(): Nullable<NodeMaterialBlock>;
  20841. /** Get the block connected on the endpoints of this connection (if any) */
  20842. get connectedBlocks(): Array<NodeMaterialBlock>;
  20843. /** Gets the list of connected endpoints */
  20844. get endpoints(): NodeMaterialConnectionPoint[];
  20845. /** Gets a boolean indicating if that output point is connected to at least one input */
  20846. get hasEndpoints(): boolean;
  20847. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  20848. get isConnectedInVertexShader(): boolean;
  20849. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  20850. get isConnectedInFragmentShader(): boolean;
  20851. /**
  20852. * Creates a block suitable to be used as an input for this input point.
  20853. * If null is returned, a block based on the point type will be created.
  20854. * @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
  20855. */
  20856. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  20857. /**
  20858. * Creates a new connection point
  20859. * @param name defines the connection point name
  20860. * @param ownerBlock defines the block hosting this connection point
  20861. * @param direction defines the direction of the connection point
  20862. */
  20863. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  20864. /**
  20865. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  20866. * @returns the class name
  20867. */
  20868. getClassName(): string;
  20869. /**
  20870. * Gets a boolean indicating if the current point can be connected to another point
  20871. * @param connectionPoint defines the other connection point
  20872. * @returns a boolean
  20873. */
  20874. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  20875. /**
  20876. * Gets a number indicating if the current point can be connected to another point
  20877. * @param connectionPoint defines the other connection point
  20878. * @returns a number defining the compatibility state
  20879. */
  20880. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  20881. /**
  20882. * Connect this point to another connection point
  20883. * @param connectionPoint defines the other connection point
  20884. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  20885. * @returns the current connection point
  20886. */
  20887. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  20888. /**
  20889. * Disconnect this point from one of his endpoint
  20890. * @param endpoint defines the other connection point
  20891. * @returns the current connection point
  20892. */
  20893. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  20894. /**
  20895. * Serializes this point in a JSON representation
  20896. * @param isInput defines if the connection point is an input (default is true)
  20897. * @returns the serialized point object
  20898. */
  20899. serialize(isInput?: boolean): any;
  20900. /**
  20901. * Release resources
  20902. */
  20903. dispose(): void;
  20904. }
  20905. }
  20906. declare module BABYLON {
  20907. /**
  20908. * Enum used to define the material modes
  20909. */
  20910. export enum NodeMaterialModes {
  20911. /** Regular material */
  20912. Material = 0,
  20913. /** For post process */
  20914. PostProcess = 1,
  20915. /** For particle system */
  20916. Particle = 2,
  20917. /** For procedural texture */
  20918. ProceduralTexture = 3
  20919. }
  20920. }
  20921. declare module BABYLON {
  20922. /**
  20923. * Block used to read a texture from a sampler
  20924. */
  20925. export class TextureBlock extends NodeMaterialBlock {
  20926. private _defineName;
  20927. private _linearDefineName;
  20928. private _gammaDefineName;
  20929. private _tempTextureRead;
  20930. private _samplerName;
  20931. private _transformedUVName;
  20932. private _textureTransformName;
  20933. private _textureInfoName;
  20934. private _mainUVName;
  20935. private _mainUVDefineName;
  20936. private _fragmentOnly;
  20937. /**
  20938. * Gets or sets the texture associated with the node
  20939. */
  20940. texture: Nullable<Texture>;
  20941. /**
  20942. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  20943. */
  20944. convertToGammaSpace: boolean;
  20945. /**
  20946. * Gets or sets a boolean indicating if content needs to be converted to linear space
  20947. */
  20948. convertToLinearSpace: boolean;
  20949. /**
  20950. * Create a new TextureBlock
  20951. * @param name defines the block name
  20952. */
  20953. constructor(name: string, fragmentOnly?: boolean);
  20954. /**
  20955. * Gets the current class name
  20956. * @returns the class name
  20957. */
  20958. getClassName(): string;
  20959. /**
  20960. * Gets the uv input component
  20961. */
  20962. get uv(): NodeMaterialConnectionPoint;
  20963. /**
  20964. * Gets the rgba output component
  20965. */
  20966. get rgba(): NodeMaterialConnectionPoint;
  20967. /**
  20968. * Gets the rgb output component
  20969. */
  20970. get rgb(): NodeMaterialConnectionPoint;
  20971. /**
  20972. * Gets the r output component
  20973. */
  20974. get r(): NodeMaterialConnectionPoint;
  20975. /**
  20976. * Gets the g output component
  20977. */
  20978. get g(): NodeMaterialConnectionPoint;
  20979. /**
  20980. * Gets the b output component
  20981. */
  20982. get b(): NodeMaterialConnectionPoint;
  20983. /**
  20984. * Gets the a output component
  20985. */
  20986. get a(): NodeMaterialConnectionPoint;
  20987. get target(): NodeMaterialBlockTargets;
  20988. autoConfigure(material: NodeMaterial): void;
  20989. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  20990. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  20991. isReady(): boolean;
  20992. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  20993. private get _isMixed();
  20994. private _injectVertexCode;
  20995. private _writeTextureRead;
  20996. private _writeOutput;
  20997. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  20998. protected _dumpPropertiesCode(): string;
  20999. serialize(): any;
  21000. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21001. }
  21002. }
  21003. declare module BABYLON {
  21004. /** @hidden */
  21005. export var reflectionFunction: {
  21006. name: string;
  21007. shader: string;
  21008. };
  21009. }
  21010. declare module BABYLON {
  21011. /**
  21012. * Base block used to read a reflection texture from a sampler
  21013. */
  21014. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  21015. /** @hidden */
  21016. _define3DName: string;
  21017. /** @hidden */
  21018. _defineCubicName: string;
  21019. /** @hidden */
  21020. _defineExplicitName: string;
  21021. /** @hidden */
  21022. _defineProjectionName: string;
  21023. /** @hidden */
  21024. _defineLocalCubicName: string;
  21025. /** @hidden */
  21026. _defineSphericalName: string;
  21027. /** @hidden */
  21028. _definePlanarName: string;
  21029. /** @hidden */
  21030. _defineEquirectangularName: string;
  21031. /** @hidden */
  21032. _defineMirroredEquirectangularFixedName: string;
  21033. /** @hidden */
  21034. _defineEquirectangularFixedName: string;
  21035. /** @hidden */
  21036. _defineSkyboxName: string;
  21037. /** @hidden */
  21038. _defineOppositeZ: string;
  21039. /** @hidden */
  21040. _cubeSamplerName: string;
  21041. /** @hidden */
  21042. _2DSamplerName: string;
  21043. protected _positionUVWName: string;
  21044. protected _directionWName: string;
  21045. protected _reflectionVectorName: string;
  21046. /** @hidden */
  21047. _reflectionCoordsName: string;
  21048. /** @hidden */
  21049. _reflectionMatrixName: string;
  21050. protected _reflectionColorName: string;
  21051. /**
  21052. * Gets or sets the texture associated with the node
  21053. */
  21054. texture: Nullable<BaseTexture>;
  21055. /**
  21056. * Create a new ReflectionTextureBaseBlock
  21057. * @param name defines the block name
  21058. */
  21059. constructor(name: string);
  21060. /**
  21061. * Gets the current class name
  21062. * @returns the class name
  21063. */
  21064. getClassName(): string;
  21065. /**
  21066. * Gets the world position input component
  21067. */
  21068. abstract get position(): NodeMaterialConnectionPoint;
  21069. /**
  21070. * Gets the world position input component
  21071. */
  21072. abstract get worldPosition(): NodeMaterialConnectionPoint;
  21073. /**
  21074. * Gets the world normal input component
  21075. */
  21076. abstract get worldNormal(): NodeMaterialConnectionPoint;
  21077. /**
  21078. * Gets the world input component
  21079. */
  21080. abstract get world(): NodeMaterialConnectionPoint;
  21081. /**
  21082. * Gets the camera (or eye) position component
  21083. */
  21084. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  21085. /**
  21086. * Gets the view input component
  21087. */
  21088. abstract get view(): NodeMaterialConnectionPoint;
  21089. protected _getTexture(): Nullable<BaseTexture>;
  21090. autoConfigure(material: NodeMaterial): void;
  21091. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21092. isReady(): boolean;
  21093. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21094. /**
  21095. * Gets the code to inject in the vertex shader
  21096. * @param state current state of the node material building
  21097. * @returns the shader code
  21098. */
  21099. handleVertexSide(state: NodeMaterialBuildState): string;
  21100. /**
  21101. * Handles the inits for the fragment code path
  21102. * @param state node material build state
  21103. */
  21104. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  21105. /**
  21106. * Generates the reflection coords code for the fragment code path
  21107. * @param worldNormalVarName name of the world normal variable
  21108. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  21109. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  21110. * @returns the shader code
  21111. */
  21112. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  21113. /**
  21114. * Generates the reflection color code for the fragment code path
  21115. * @param lodVarName name of the lod variable
  21116. * @param swizzleLookupTexture swizzle to use for the final color variable
  21117. * @returns the shader code
  21118. */
  21119. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  21120. /**
  21121. * Generates the code corresponding to the connected output points
  21122. * @param state node material build state
  21123. * @param varName name of the variable to output
  21124. * @returns the shader code
  21125. */
  21126. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  21127. protected _buildBlock(state: NodeMaterialBuildState): this;
  21128. protected _dumpPropertiesCode(): string;
  21129. serialize(): any;
  21130. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21131. }
  21132. }
  21133. declare module BABYLON {
  21134. /**
  21135. * Defines a connection point to be used for points with a custom object type
  21136. */
  21137. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  21138. private _blockType;
  21139. private _blockName;
  21140. private _nameForCheking?;
  21141. /**
  21142. * Creates a new connection point
  21143. * @param name defines the connection point name
  21144. * @param ownerBlock defines the block hosting this connection point
  21145. * @param direction defines the direction of the connection point
  21146. */
  21147. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  21148. /**
  21149. * Gets a number indicating if the current point can be connected to another point
  21150. * @param connectionPoint defines the other connection point
  21151. * @returns a number defining the compatibility state
  21152. */
  21153. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21154. /**
  21155. * Creates a block suitable to be used as an input for this input point.
  21156. * If null is returned, a block based on the point type will be created.
  21157. * @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
  21158. */
  21159. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21160. }
  21161. }
  21162. declare module BABYLON {
  21163. /**
  21164. * Enum defining the type of properties that can be edited in the property pages in the NME
  21165. */
  21166. export enum PropertyTypeForEdition {
  21167. /** property is a boolean */
  21168. Boolean = 0,
  21169. /** property is a float */
  21170. Float = 1,
  21171. /** property is a Vector2 */
  21172. Vector2 = 2,
  21173. /** property is a list of values */
  21174. List = 3
  21175. }
  21176. /**
  21177. * Interface that defines an option in a variable of type list
  21178. */
  21179. export interface IEditablePropertyListOption {
  21180. /** label of the option */
  21181. "label": string;
  21182. /** value of the option */
  21183. "value": number;
  21184. }
  21185. /**
  21186. * Interface that defines the options available for an editable property
  21187. */
  21188. export interface IEditablePropertyOption {
  21189. /** min value */
  21190. "min"?: number;
  21191. /** max value */
  21192. "max"?: number;
  21193. /** notifiers: indicates which actions to take when the property is changed */
  21194. "notifiers"?: {
  21195. /** the material should be rebuilt */
  21196. "rebuild"?: boolean;
  21197. /** the preview should be updated */
  21198. "update"?: boolean;
  21199. };
  21200. /** list of the options for a variable of type list */
  21201. "options"?: IEditablePropertyListOption[];
  21202. }
  21203. /**
  21204. * Interface that describes an editable property
  21205. */
  21206. export interface IPropertyDescriptionForEdition {
  21207. /** name of the property */
  21208. "propertyName": string;
  21209. /** display name of the property */
  21210. "displayName": string;
  21211. /** type of the property */
  21212. "type": PropertyTypeForEdition;
  21213. /** group of the property - all properties with the same group value will be displayed in a specific section */
  21214. "groupName": string;
  21215. /** options for the property */
  21216. "options": IEditablePropertyOption;
  21217. }
  21218. /**
  21219. * Decorator that flags a property in a node material block as being editable
  21220. */
  21221. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  21222. }
  21223. declare module BABYLON {
  21224. /**
  21225. * Block used to implement the refraction part of the sub surface module of the PBR material
  21226. */
  21227. export class RefractionBlock extends NodeMaterialBlock {
  21228. /** @hidden */
  21229. _define3DName: string;
  21230. /** @hidden */
  21231. _refractionMatrixName: string;
  21232. /** @hidden */
  21233. _defineLODRefractionAlpha: string;
  21234. /** @hidden */
  21235. _defineLinearSpecularRefraction: string;
  21236. /** @hidden */
  21237. _defineOppositeZ: string;
  21238. /** @hidden */
  21239. _cubeSamplerName: string;
  21240. /** @hidden */
  21241. _2DSamplerName: string;
  21242. /** @hidden */
  21243. _vRefractionMicrosurfaceInfosName: string;
  21244. /** @hidden */
  21245. _vRefractionInfosName: string;
  21246. private _scene;
  21247. /**
  21248. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  21249. * Materials half opaque for instance using refraction could benefit from this control.
  21250. */
  21251. linkRefractionWithTransparency: boolean;
  21252. /**
  21253. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  21254. */
  21255. invertRefractionY: boolean;
  21256. /**
  21257. * Gets or sets the texture associated with the node
  21258. */
  21259. texture: Nullable<BaseTexture>;
  21260. /**
  21261. * Create a new RefractionBlock
  21262. * @param name defines the block name
  21263. */
  21264. constructor(name: string);
  21265. /**
  21266. * Gets the current class name
  21267. * @returns the class name
  21268. */
  21269. getClassName(): string;
  21270. /**
  21271. * Gets the intensity input component
  21272. */
  21273. get intensity(): NodeMaterialConnectionPoint;
  21274. /**
  21275. * Gets the index of refraction input component
  21276. */
  21277. get indexOfRefraction(): NodeMaterialConnectionPoint;
  21278. /**
  21279. * Gets the tint at distance input component
  21280. */
  21281. get tintAtDistance(): NodeMaterialConnectionPoint;
  21282. /**
  21283. * Gets the view input component
  21284. */
  21285. get view(): NodeMaterialConnectionPoint;
  21286. /**
  21287. * Gets the refraction object output component
  21288. */
  21289. get refraction(): NodeMaterialConnectionPoint;
  21290. /**
  21291. * Returns true if the block has a texture
  21292. */
  21293. get hasTexture(): boolean;
  21294. protected _getTexture(): Nullable<BaseTexture>;
  21295. autoConfigure(material: NodeMaterial): void;
  21296. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21297. isReady(): boolean;
  21298. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21299. /**
  21300. * Gets the main code of the block (fragment side)
  21301. * @param state current state of the node material building
  21302. * @returns the shader code
  21303. */
  21304. getCode(state: NodeMaterialBuildState): string;
  21305. protected _buildBlock(state: NodeMaterialBuildState): this;
  21306. protected _dumpPropertiesCode(): string;
  21307. serialize(): any;
  21308. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21309. }
  21310. }
  21311. declare module BABYLON {
  21312. /**
  21313. * Base block used as input for post process
  21314. */
  21315. export class CurrentScreenBlock extends NodeMaterialBlock {
  21316. private _samplerName;
  21317. private _linearDefineName;
  21318. private _gammaDefineName;
  21319. private _mainUVName;
  21320. private _tempTextureRead;
  21321. /**
  21322. * Gets or sets the texture associated with the node
  21323. */
  21324. texture: Nullable<BaseTexture>;
  21325. /**
  21326. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21327. */
  21328. convertToGammaSpace: boolean;
  21329. /**
  21330. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21331. */
  21332. convertToLinearSpace: boolean;
  21333. /**
  21334. * Create a new CurrentScreenBlock
  21335. * @param name defines the block name
  21336. */
  21337. constructor(name: string);
  21338. /**
  21339. * Gets the current class name
  21340. * @returns the class name
  21341. */
  21342. getClassName(): string;
  21343. /**
  21344. * Gets the uv input component
  21345. */
  21346. get uv(): NodeMaterialConnectionPoint;
  21347. /**
  21348. * Gets the rgba output component
  21349. */
  21350. get rgba(): NodeMaterialConnectionPoint;
  21351. /**
  21352. * Gets the rgb output component
  21353. */
  21354. get rgb(): NodeMaterialConnectionPoint;
  21355. /**
  21356. * Gets the r output component
  21357. */
  21358. get r(): NodeMaterialConnectionPoint;
  21359. /**
  21360. * Gets the g output component
  21361. */
  21362. get g(): NodeMaterialConnectionPoint;
  21363. /**
  21364. * Gets the b output component
  21365. */
  21366. get b(): NodeMaterialConnectionPoint;
  21367. /**
  21368. * Gets the a output component
  21369. */
  21370. get a(): NodeMaterialConnectionPoint;
  21371. /**
  21372. * Initialize the block and prepare the context for build
  21373. * @param state defines the state that will be used for the build
  21374. */
  21375. initialize(state: NodeMaterialBuildState): void;
  21376. get target(): NodeMaterialBlockTargets;
  21377. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21378. isReady(): boolean;
  21379. private _injectVertexCode;
  21380. private _writeTextureRead;
  21381. private _writeOutput;
  21382. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21383. serialize(): any;
  21384. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21385. }
  21386. }
  21387. declare module BABYLON {
  21388. /**
  21389. * Base block used for the particle texture
  21390. */
  21391. export class ParticleTextureBlock extends NodeMaterialBlock {
  21392. private _samplerName;
  21393. private _linearDefineName;
  21394. private _gammaDefineName;
  21395. private _tempTextureRead;
  21396. /**
  21397. * Gets or sets the texture associated with the node
  21398. */
  21399. texture: Nullable<BaseTexture>;
  21400. /**
  21401. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21402. */
  21403. convertToGammaSpace: boolean;
  21404. /**
  21405. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21406. */
  21407. convertToLinearSpace: boolean;
  21408. /**
  21409. * Create a new ParticleTextureBlock
  21410. * @param name defines the block name
  21411. */
  21412. constructor(name: string);
  21413. /**
  21414. * Gets the current class name
  21415. * @returns the class name
  21416. */
  21417. getClassName(): string;
  21418. /**
  21419. * Gets the uv input component
  21420. */
  21421. get uv(): NodeMaterialConnectionPoint;
  21422. /**
  21423. * Gets the rgba output component
  21424. */
  21425. get rgba(): NodeMaterialConnectionPoint;
  21426. /**
  21427. * Gets the rgb output component
  21428. */
  21429. get rgb(): NodeMaterialConnectionPoint;
  21430. /**
  21431. * Gets the r output component
  21432. */
  21433. get r(): NodeMaterialConnectionPoint;
  21434. /**
  21435. * Gets the g output component
  21436. */
  21437. get g(): NodeMaterialConnectionPoint;
  21438. /**
  21439. * Gets the b output component
  21440. */
  21441. get b(): NodeMaterialConnectionPoint;
  21442. /**
  21443. * Gets the a output component
  21444. */
  21445. get a(): NodeMaterialConnectionPoint;
  21446. /**
  21447. * Initialize the block and prepare the context for build
  21448. * @param state defines the state that will be used for the build
  21449. */
  21450. initialize(state: NodeMaterialBuildState): void;
  21451. autoConfigure(material: NodeMaterial): void;
  21452. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21453. isReady(): boolean;
  21454. private _writeOutput;
  21455. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21456. serialize(): any;
  21457. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21458. }
  21459. }
  21460. declare module BABYLON {
  21461. /**
  21462. * Class used to store shared data between 2 NodeMaterialBuildState
  21463. */
  21464. export class NodeMaterialBuildStateSharedData {
  21465. /**
  21466. * Gets the list of emitted varyings
  21467. */
  21468. temps: string[];
  21469. /**
  21470. * Gets the list of emitted varyings
  21471. */
  21472. varyings: string[];
  21473. /**
  21474. * Gets the varying declaration string
  21475. */
  21476. varyingDeclaration: string;
  21477. /**
  21478. * Input blocks
  21479. */
  21480. inputBlocks: InputBlock[];
  21481. /**
  21482. * Input blocks
  21483. */
  21484. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  21485. /**
  21486. * Bindable blocks (Blocks that need to set data to the effect)
  21487. */
  21488. bindableBlocks: NodeMaterialBlock[];
  21489. /**
  21490. * List of blocks that can provide a compilation fallback
  21491. */
  21492. blocksWithFallbacks: NodeMaterialBlock[];
  21493. /**
  21494. * List of blocks that can provide a define update
  21495. */
  21496. blocksWithDefines: NodeMaterialBlock[];
  21497. /**
  21498. * List of blocks that can provide a repeatable content
  21499. */
  21500. repeatableContentBlocks: NodeMaterialBlock[];
  21501. /**
  21502. * List of blocks that can provide a dynamic list of uniforms
  21503. */
  21504. dynamicUniformBlocks: NodeMaterialBlock[];
  21505. /**
  21506. * List of blocks that can block the isReady function for the material
  21507. */
  21508. blockingBlocks: NodeMaterialBlock[];
  21509. /**
  21510. * Gets the list of animated inputs
  21511. */
  21512. animatedInputs: InputBlock[];
  21513. /**
  21514. * Build Id used to avoid multiple recompilations
  21515. */
  21516. buildId: number;
  21517. /** List of emitted variables */
  21518. variableNames: {
  21519. [key: string]: number;
  21520. };
  21521. /** List of emitted defines */
  21522. defineNames: {
  21523. [key: string]: number;
  21524. };
  21525. /** Should emit comments? */
  21526. emitComments: boolean;
  21527. /** Emit build activity */
  21528. verbose: boolean;
  21529. /** Gets or sets the hosting scene */
  21530. scene: Scene;
  21531. /**
  21532. * Gets the compilation hints emitted at compilation time
  21533. */
  21534. hints: {
  21535. needWorldViewMatrix: boolean;
  21536. needWorldViewProjectionMatrix: boolean;
  21537. needAlphaBlending: boolean;
  21538. needAlphaTesting: boolean;
  21539. };
  21540. /**
  21541. * List of compilation checks
  21542. */
  21543. checks: {
  21544. emitVertex: boolean;
  21545. emitFragment: boolean;
  21546. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  21547. };
  21548. /**
  21549. * Is vertex program allowed to be empty?
  21550. */
  21551. allowEmptyVertexProgram: boolean;
  21552. /** Creates a new shared data */
  21553. constructor();
  21554. /**
  21555. * Emits console errors and exceptions if there is a failing check
  21556. */
  21557. emitErrors(): void;
  21558. }
  21559. }
  21560. declare module BABYLON {
  21561. /**
  21562. * Class used to store node based material build state
  21563. */
  21564. export class NodeMaterialBuildState {
  21565. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  21566. supportUniformBuffers: boolean;
  21567. /**
  21568. * Gets the list of emitted attributes
  21569. */
  21570. attributes: string[];
  21571. /**
  21572. * Gets the list of emitted uniforms
  21573. */
  21574. uniforms: string[];
  21575. /**
  21576. * Gets the list of emitted constants
  21577. */
  21578. constants: string[];
  21579. /**
  21580. * Gets the list of emitted samplers
  21581. */
  21582. samplers: string[];
  21583. /**
  21584. * Gets the list of emitted functions
  21585. */
  21586. functions: {
  21587. [key: string]: string;
  21588. };
  21589. /**
  21590. * Gets the list of emitted extensions
  21591. */
  21592. extensions: {
  21593. [key: string]: string;
  21594. };
  21595. /**
  21596. * Gets the target of the compilation state
  21597. */
  21598. target: NodeMaterialBlockTargets;
  21599. /**
  21600. * Gets the list of emitted counters
  21601. */
  21602. counters: {
  21603. [key: string]: number;
  21604. };
  21605. /**
  21606. * Shared data between multiple NodeMaterialBuildState instances
  21607. */
  21608. sharedData: NodeMaterialBuildStateSharedData;
  21609. /** @hidden */
  21610. _vertexState: NodeMaterialBuildState;
  21611. /** @hidden */
  21612. _attributeDeclaration: string;
  21613. /** @hidden */
  21614. _uniformDeclaration: string;
  21615. /** @hidden */
  21616. _constantDeclaration: string;
  21617. /** @hidden */
  21618. _samplerDeclaration: string;
  21619. /** @hidden */
  21620. _varyingTransfer: string;
  21621. /** @hidden */
  21622. _injectAtEnd: string;
  21623. private _repeatableContentAnchorIndex;
  21624. /** @hidden */
  21625. _builtCompilationString: string;
  21626. /**
  21627. * Gets the emitted compilation strings
  21628. */
  21629. compilationString: string;
  21630. /**
  21631. * Finalize the compilation strings
  21632. * @param state defines the current compilation state
  21633. */
  21634. finalize(state: NodeMaterialBuildState): void;
  21635. /** @hidden */
  21636. get _repeatableContentAnchor(): string;
  21637. /** @hidden */
  21638. _getFreeVariableName(prefix: string): string;
  21639. /** @hidden */
  21640. _getFreeDefineName(prefix: string): string;
  21641. /** @hidden */
  21642. _excludeVariableName(name: string): void;
  21643. /** @hidden */
  21644. _emit2DSampler(name: string): void;
  21645. /** @hidden */
  21646. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  21647. /** @hidden */
  21648. _emitExtension(name: string, extension: string, define?: string): void;
  21649. /** @hidden */
  21650. _emitFunction(name: string, code: string, comments: string): void;
  21651. /** @hidden */
  21652. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  21653. replaceStrings?: {
  21654. search: RegExp;
  21655. replace: string;
  21656. }[];
  21657. repeatKey?: string;
  21658. }): string;
  21659. /** @hidden */
  21660. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  21661. repeatKey?: string;
  21662. removeAttributes?: boolean;
  21663. removeUniforms?: boolean;
  21664. removeVaryings?: boolean;
  21665. removeIfDef?: boolean;
  21666. replaceStrings?: {
  21667. search: RegExp;
  21668. replace: string;
  21669. }[];
  21670. }, storeKey?: string): void;
  21671. /** @hidden */
  21672. _registerTempVariable(name: string): boolean;
  21673. /** @hidden */
  21674. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  21675. /** @hidden */
  21676. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  21677. /** @hidden */
  21678. _emitFloat(value: number): string;
  21679. }
  21680. }
  21681. declare module BABYLON {
  21682. /**
  21683. * Helper class used to generate session unique ID
  21684. */
  21685. export class UniqueIdGenerator {
  21686. private static _UniqueIdCounter;
  21687. /**
  21688. * Gets an unique (relatively to the current scene) Id
  21689. */
  21690. static get UniqueId(): number;
  21691. }
  21692. }
  21693. declare module BABYLON {
  21694. /**
  21695. * Defines a block that can be used inside a node based material
  21696. */
  21697. export class NodeMaterialBlock {
  21698. private _buildId;
  21699. private _buildTarget;
  21700. private _target;
  21701. private _isFinalMerger;
  21702. private _isInput;
  21703. private _name;
  21704. protected _isUnique: boolean;
  21705. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  21706. inputsAreExclusive: boolean;
  21707. /** @hidden */
  21708. _codeVariableName: string;
  21709. /** @hidden */
  21710. _inputs: NodeMaterialConnectionPoint[];
  21711. /** @hidden */
  21712. _outputs: NodeMaterialConnectionPoint[];
  21713. /** @hidden */
  21714. _preparationId: number;
  21715. /**
  21716. * Gets the name of the block
  21717. */
  21718. get name(): string;
  21719. /**
  21720. * Sets the name of the block. Will check if the name is valid.
  21721. */
  21722. set name(newName: string);
  21723. /**
  21724. * Gets or sets the unique id of the node
  21725. */
  21726. uniqueId: number;
  21727. /**
  21728. * Gets or sets the comments associated with this block
  21729. */
  21730. comments: string;
  21731. /**
  21732. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  21733. */
  21734. get isUnique(): boolean;
  21735. /**
  21736. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  21737. */
  21738. get isFinalMerger(): boolean;
  21739. /**
  21740. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  21741. */
  21742. get isInput(): boolean;
  21743. /**
  21744. * Gets or sets the build Id
  21745. */
  21746. get buildId(): number;
  21747. set buildId(value: number);
  21748. /**
  21749. * Gets or sets the target of the block
  21750. */
  21751. get target(): NodeMaterialBlockTargets;
  21752. set target(value: NodeMaterialBlockTargets);
  21753. /**
  21754. * Gets the list of input points
  21755. */
  21756. get inputs(): NodeMaterialConnectionPoint[];
  21757. /** Gets the list of output points */
  21758. get outputs(): NodeMaterialConnectionPoint[];
  21759. /**
  21760. * Find an input by its name
  21761. * @param name defines the name of the input to look for
  21762. * @returns the input or null if not found
  21763. */
  21764. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  21765. /**
  21766. * Find an output by its name
  21767. * @param name defines the name of the outputto look for
  21768. * @returns the output or null if not found
  21769. */
  21770. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  21771. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  21772. visibleInInspector: boolean;
  21773. /**
  21774. * Creates a new NodeMaterialBlock
  21775. * @param name defines the block name
  21776. * @param target defines the target of that block (Vertex by default)
  21777. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  21778. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  21779. */
  21780. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  21781. /**
  21782. * Initialize the block and prepare the context for build
  21783. * @param state defines the state that will be used for the build
  21784. */
  21785. initialize(state: NodeMaterialBuildState): void;
  21786. /**
  21787. * Bind data to effect. Will only be called for blocks with isBindable === true
  21788. * @param effect defines the effect to bind data to
  21789. * @param nodeMaterial defines the hosting NodeMaterial
  21790. * @param mesh defines the mesh that will be rendered
  21791. * @param subMesh defines the submesh that will be rendered
  21792. */
  21793. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21794. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  21795. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  21796. protected _writeFloat(value: number): string;
  21797. /**
  21798. * Gets the current class name e.g. "NodeMaterialBlock"
  21799. * @returns the class name
  21800. */
  21801. getClassName(): string;
  21802. /**
  21803. * Register a new input. Must be called inside a block constructor
  21804. * @param name defines the connection point name
  21805. * @param type defines the connection point type
  21806. * @param isOptional defines a boolean indicating that this input can be omitted
  21807. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  21808. * @param point an already created connection point. If not provided, create a new one
  21809. * @returns the current block
  21810. */
  21811. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  21812. /**
  21813. * Register a new output. Must be called inside a block constructor
  21814. * @param name defines the connection point name
  21815. * @param type defines the connection point type
  21816. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  21817. * @param point an already created connection point. If not provided, create a new one
  21818. * @returns the current block
  21819. */
  21820. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  21821. /**
  21822. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  21823. * @param forOutput defines an optional connection point to check compatibility with
  21824. * @returns the first available input or null
  21825. */
  21826. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  21827. /**
  21828. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  21829. * @param forBlock defines an optional block to check compatibility with
  21830. * @returns the first available input or null
  21831. */
  21832. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  21833. /**
  21834. * Gets the sibling of the given output
  21835. * @param current defines the current output
  21836. * @returns the next output in the list or null
  21837. */
  21838. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  21839. /**
  21840. * Connect current block with another block
  21841. * @param other defines the block to connect with
  21842. * @param options define the various options to help pick the right connections
  21843. * @returns the current block
  21844. */
  21845. connectTo(other: NodeMaterialBlock, options?: {
  21846. input?: string;
  21847. output?: string;
  21848. outputSwizzle?: string;
  21849. }): this | undefined;
  21850. protected _buildBlock(state: NodeMaterialBuildState): void;
  21851. /**
  21852. * Add uniforms, samplers and uniform buffers at compilation time
  21853. * @param state defines the state to update
  21854. * @param nodeMaterial defines the node material requesting the update
  21855. * @param defines defines the material defines to update
  21856. * @param uniformBuffers defines the list of uniform buffer names
  21857. */
  21858. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  21859. /**
  21860. * Add potential fallbacks if shader compilation fails
  21861. * @param mesh defines the mesh to be rendered
  21862. * @param fallbacks defines the current prioritized list of fallbacks
  21863. */
  21864. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  21865. /**
  21866. * Initialize defines for shader compilation
  21867. * @param mesh defines the mesh to be rendered
  21868. * @param nodeMaterial defines the node material requesting the update
  21869. * @param defines defines the material defines to update
  21870. * @param useInstances specifies that instances should be used
  21871. */
  21872. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21873. /**
  21874. * Update defines for shader compilation
  21875. * @param mesh defines the mesh to be rendered
  21876. * @param nodeMaterial defines the node material requesting the update
  21877. * @param defines defines the material defines to update
  21878. * @param useInstances specifies that instances should be used
  21879. * @param subMesh defines which submesh to render
  21880. */
  21881. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  21882. /**
  21883. * Lets the block try to connect some inputs automatically
  21884. * @param material defines the hosting NodeMaterial
  21885. */
  21886. autoConfigure(material: NodeMaterial): void;
  21887. /**
  21888. * Function called when a block is declared as repeatable content generator
  21889. * @param vertexShaderState defines the current compilation state for the vertex shader
  21890. * @param fragmentShaderState defines the current compilation state for the fragment shader
  21891. * @param mesh defines the mesh to be rendered
  21892. * @param defines defines the material defines to update
  21893. */
  21894. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  21895. /**
  21896. * Checks if the block is ready
  21897. * @param mesh defines the mesh to be rendered
  21898. * @param nodeMaterial defines the node material requesting the update
  21899. * @param defines defines the material defines to update
  21900. * @param useInstances specifies that instances should be used
  21901. * @returns true if the block is ready
  21902. */
  21903. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  21904. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  21905. private _processBuild;
  21906. /**
  21907. * Validates the new name for the block node.
  21908. * @param newName the new name to be given to the node.
  21909. * @returns false if the name is a reserve word, else true.
  21910. */
  21911. validateBlockName(newName: string): boolean;
  21912. /**
  21913. * Compile the current node and generate the shader code
  21914. * @param state defines the current compilation state (uniforms, samplers, current string)
  21915. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  21916. * @returns true if already built
  21917. */
  21918. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  21919. protected _inputRename(name: string): string;
  21920. protected _outputRename(name: string): string;
  21921. protected _dumpPropertiesCode(): string;
  21922. /** @hidden */
  21923. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  21924. /** @hidden */
  21925. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  21926. /**
  21927. * Clone the current block to a new identical block
  21928. * @param scene defines the hosting scene
  21929. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  21930. * @returns a copy of the current block
  21931. */
  21932. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  21933. /**
  21934. * Serializes this block in a JSON representation
  21935. * @returns the serialized block object
  21936. */
  21937. serialize(): any;
  21938. /** @hidden */
  21939. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21940. private _deserializePortDisplayNamesAndExposedOnFrame;
  21941. /**
  21942. * Release resources
  21943. */
  21944. dispose(): void;
  21945. }
  21946. }
  21947. declare module BABYLON {
  21948. /**
  21949. * Base class of materials working in push mode in babylon JS
  21950. * @hidden
  21951. */
  21952. export class PushMaterial extends Material {
  21953. protected _activeEffect: Effect;
  21954. protected _normalMatrix: Matrix;
  21955. constructor(name: string, scene: Scene);
  21956. getEffect(): Effect;
  21957. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21958. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  21959. /**
  21960. * Binds the given world matrix to the active effect
  21961. *
  21962. * @param world the matrix to bind
  21963. */
  21964. bindOnlyWorldMatrix(world: Matrix): void;
  21965. /**
  21966. * Binds the given normal matrix to the active effect
  21967. *
  21968. * @param normalMatrix the matrix to bind
  21969. */
  21970. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  21971. bind(world: Matrix, mesh?: Mesh): void;
  21972. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  21973. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  21974. }
  21975. }
  21976. declare module BABYLON {
  21977. /**
  21978. * Root class for all node material optimizers
  21979. */
  21980. export class NodeMaterialOptimizer {
  21981. /**
  21982. * Function used to optimize a NodeMaterial graph
  21983. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  21984. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  21985. */
  21986. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  21987. }
  21988. }
  21989. declare module BABYLON {
  21990. /**
  21991. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  21992. */
  21993. export class TransformBlock extends NodeMaterialBlock {
  21994. /**
  21995. * Defines the value to use to complement W value to transform it to a Vector4
  21996. */
  21997. complementW: number;
  21998. /**
  21999. * Defines the value to use to complement z value to transform it to a Vector4
  22000. */
  22001. complementZ: number;
  22002. /**
  22003. * Creates a new TransformBlock
  22004. * @param name defines the block name
  22005. */
  22006. constructor(name: string);
  22007. /**
  22008. * Gets the current class name
  22009. * @returns the class name
  22010. */
  22011. getClassName(): string;
  22012. /**
  22013. * Gets the vector input
  22014. */
  22015. get vector(): NodeMaterialConnectionPoint;
  22016. /**
  22017. * Gets the output component
  22018. */
  22019. get output(): NodeMaterialConnectionPoint;
  22020. /**
  22021. * Gets the xyz output component
  22022. */
  22023. get xyz(): NodeMaterialConnectionPoint;
  22024. /**
  22025. * Gets the matrix transform input
  22026. */
  22027. get transform(): NodeMaterialConnectionPoint;
  22028. protected _buildBlock(state: NodeMaterialBuildState): this;
  22029. /**
  22030. * Update defines for shader compilation
  22031. * @param mesh defines the mesh to be rendered
  22032. * @param nodeMaterial defines the node material requesting the update
  22033. * @param defines defines the material defines to update
  22034. * @param useInstances specifies that instances should be used
  22035. * @param subMesh defines which submesh to render
  22036. */
  22037. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22038. serialize(): any;
  22039. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22040. protected _dumpPropertiesCode(): string;
  22041. }
  22042. }
  22043. declare module BABYLON {
  22044. /**
  22045. * Block used to output the vertex position
  22046. */
  22047. export class VertexOutputBlock extends NodeMaterialBlock {
  22048. /**
  22049. * Creates a new VertexOutputBlock
  22050. * @param name defines the block name
  22051. */
  22052. constructor(name: string);
  22053. /**
  22054. * Gets the current class name
  22055. * @returns the class name
  22056. */
  22057. getClassName(): string;
  22058. /**
  22059. * Gets the vector input component
  22060. */
  22061. get vector(): NodeMaterialConnectionPoint;
  22062. protected _buildBlock(state: NodeMaterialBuildState): this;
  22063. }
  22064. }
  22065. declare module BABYLON {
  22066. /**
  22067. * Block used to output the final color
  22068. */
  22069. export class FragmentOutputBlock extends NodeMaterialBlock {
  22070. /**
  22071. * Create a new FragmentOutputBlock
  22072. * @param name defines the block name
  22073. */
  22074. constructor(name: string);
  22075. /**
  22076. * Gets the current class name
  22077. * @returns the class name
  22078. */
  22079. getClassName(): string;
  22080. /**
  22081. * Gets the rgba input component
  22082. */
  22083. get rgba(): NodeMaterialConnectionPoint;
  22084. /**
  22085. * Gets the rgb input component
  22086. */
  22087. get rgb(): NodeMaterialConnectionPoint;
  22088. /**
  22089. * Gets the a input component
  22090. */
  22091. get a(): NodeMaterialConnectionPoint;
  22092. protected _buildBlock(state: NodeMaterialBuildState): this;
  22093. }
  22094. }
  22095. declare module BABYLON {
  22096. /**
  22097. * Block used for the particle ramp gradient section
  22098. */
  22099. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  22100. /**
  22101. * Create a new ParticleRampGradientBlock
  22102. * @param name defines the block name
  22103. */
  22104. constructor(name: string);
  22105. /**
  22106. * Gets the current class name
  22107. * @returns the class name
  22108. */
  22109. getClassName(): string;
  22110. /**
  22111. * Gets the color input component
  22112. */
  22113. get color(): NodeMaterialConnectionPoint;
  22114. /**
  22115. * Gets the rampColor output component
  22116. */
  22117. get rampColor(): NodeMaterialConnectionPoint;
  22118. /**
  22119. * Initialize the block and prepare the context for build
  22120. * @param state defines the state that will be used for the build
  22121. */
  22122. initialize(state: NodeMaterialBuildState): void;
  22123. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22124. }
  22125. }
  22126. declare module BABYLON {
  22127. /**
  22128. * Block used for the particle blend multiply section
  22129. */
  22130. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  22131. /**
  22132. * Create a new ParticleBlendMultiplyBlock
  22133. * @param name defines the block name
  22134. */
  22135. constructor(name: string);
  22136. /**
  22137. * Gets the current class name
  22138. * @returns the class name
  22139. */
  22140. getClassName(): string;
  22141. /**
  22142. * Gets the color input component
  22143. */
  22144. get color(): NodeMaterialConnectionPoint;
  22145. /**
  22146. * Gets the alphaTexture input component
  22147. */
  22148. get alphaTexture(): NodeMaterialConnectionPoint;
  22149. /**
  22150. * Gets the alphaColor input component
  22151. */
  22152. get alphaColor(): NodeMaterialConnectionPoint;
  22153. /**
  22154. * Gets the blendColor output component
  22155. */
  22156. get blendColor(): NodeMaterialConnectionPoint;
  22157. /**
  22158. * Initialize the block and prepare the context for build
  22159. * @param state defines the state that will be used for the build
  22160. */
  22161. initialize(state: NodeMaterialBuildState): void;
  22162. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22163. }
  22164. }
  22165. declare module BABYLON {
  22166. /**
  22167. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  22168. */
  22169. export class VectorMergerBlock extends NodeMaterialBlock {
  22170. /**
  22171. * Create a new VectorMergerBlock
  22172. * @param name defines the block name
  22173. */
  22174. constructor(name: string);
  22175. /**
  22176. * Gets the current class name
  22177. * @returns the class name
  22178. */
  22179. getClassName(): string;
  22180. /**
  22181. * Gets the xyz component (input)
  22182. */
  22183. get xyzIn(): NodeMaterialConnectionPoint;
  22184. /**
  22185. * Gets the xy component (input)
  22186. */
  22187. get xyIn(): NodeMaterialConnectionPoint;
  22188. /**
  22189. * Gets the x component (input)
  22190. */
  22191. get x(): NodeMaterialConnectionPoint;
  22192. /**
  22193. * Gets the y component (input)
  22194. */
  22195. get y(): NodeMaterialConnectionPoint;
  22196. /**
  22197. * Gets the z component (input)
  22198. */
  22199. get z(): NodeMaterialConnectionPoint;
  22200. /**
  22201. * Gets the w component (input)
  22202. */
  22203. get w(): NodeMaterialConnectionPoint;
  22204. /**
  22205. * Gets the xyzw component (output)
  22206. */
  22207. get xyzw(): NodeMaterialConnectionPoint;
  22208. /**
  22209. * Gets the xyz component (output)
  22210. */
  22211. get xyzOut(): NodeMaterialConnectionPoint;
  22212. /**
  22213. * Gets the xy component (output)
  22214. */
  22215. get xyOut(): NodeMaterialConnectionPoint;
  22216. /**
  22217. * Gets the xy component (output)
  22218. * @deprecated Please use xyOut instead.
  22219. */
  22220. get xy(): NodeMaterialConnectionPoint;
  22221. /**
  22222. * Gets the xyz component (output)
  22223. * @deprecated Please use xyzOut instead.
  22224. */
  22225. get xyz(): NodeMaterialConnectionPoint;
  22226. protected _buildBlock(state: NodeMaterialBuildState): this;
  22227. }
  22228. }
  22229. declare module BABYLON {
  22230. /**
  22231. * Block used to remap a float from a range to a new one
  22232. */
  22233. export class RemapBlock extends NodeMaterialBlock {
  22234. /**
  22235. * Gets or sets the source range
  22236. */
  22237. sourceRange: Vector2;
  22238. /**
  22239. * Gets or sets the target range
  22240. */
  22241. targetRange: Vector2;
  22242. /**
  22243. * Creates a new RemapBlock
  22244. * @param name defines the block name
  22245. */
  22246. constructor(name: string);
  22247. /**
  22248. * Gets the current class name
  22249. * @returns the class name
  22250. */
  22251. getClassName(): string;
  22252. /**
  22253. * Gets the input component
  22254. */
  22255. get input(): NodeMaterialConnectionPoint;
  22256. /**
  22257. * Gets the source min input component
  22258. */
  22259. get sourceMin(): NodeMaterialConnectionPoint;
  22260. /**
  22261. * Gets the source max input component
  22262. */
  22263. get sourceMax(): NodeMaterialConnectionPoint;
  22264. /**
  22265. * Gets the target min input component
  22266. */
  22267. get targetMin(): NodeMaterialConnectionPoint;
  22268. /**
  22269. * Gets the target max input component
  22270. */
  22271. get targetMax(): NodeMaterialConnectionPoint;
  22272. /**
  22273. * Gets the output component
  22274. */
  22275. get output(): NodeMaterialConnectionPoint;
  22276. protected _buildBlock(state: NodeMaterialBuildState): this;
  22277. protected _dumpPropertiesCode(): string;
  22278. serialize(): any;
  22279. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22280. }
  22281. }
  22282. declare module BABYLON {
  22283. /**
  22284. * Block used to multiply 2 values
  22285. */
  22286. export class MultiplyBlock extends NodeMaterialBlock {
  22287. /**
  22288. * Creates a new MultiplyBlock
  22289. * @param name defines the block name
  22290. */
  22291. constructor(name: string);
  22292. /**
  22293. * Gets the current class name
  22294. * @returns the class name
  22295. */
  22296. getClassName(): string;
  22297. /**
  22298. * Gets the left operand input component
  22299. */
  22300. get left(): NodeMaterialConnectionPoint;
  22301. /**
  22302. * Gets the right operand input component
  22303. */
  22304. get right(): NodeMaterialConnectionPoint;
  22305. /**
  22306. * Gets the output component
  22307. */
  22308. get output(): NodeMaterialConnectionPoint;
  22309. protected _buildBlock(state: NodeMaterialBuildState): this;
  22310. }
  22311. }
  22312. declare module BABYLON {
  22313. /**
  22314. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  22315. */
  22316. export class ColorSplitterBlock extends NodeMaterialBlock {
  22317. /**
  22318. * Create a new ColorSplitterBlock
  22319. * @param name defines the block name
  22320. */
  22321. constructor(name: string);
  22322. /**
  22323. * Gets the current class name
  22324. * @returns the class name
  22325. */
  22326. getClassName(): string;
  22327. /**
  22328. * Gets the rgba component (input)
  22329. */
  22330. get rgba(): NodeMaterialConnectionPoint;
  22331. /**
  22332. * Gets the rgb component (input)
  22333. */
  22334. get rgbIn(): NodeMaterialConnectionPoint;
  22335. /**
  22336. * Gets the rgb component (output)
  22337. */
  22338. get rgbOut(): NodeMaterialConnectionPoint;
  22339. /**
  22340. * Gets the r component (output)
  22341. */
  22342. get r(): NodeMaterialConnectionPoint;
  22343. /**
  22344. * Gets the g component (output)
  22345. */
  22346. get g(): NodeMaterialConnectionPoint;
  22347. /**
  22348. * Gets the b component (output)
  22349. */
  22350. get b(): NodeMaterialConnectionPoint;
  22351. /**
  22352. * Gets the a component (output)
  22353. */
  22354. get a(): NodeMaterialConnectionPoint;
  22355. protected _inputRename(name: string): string;
  22356. protected _outputRename(name: string): string;
  22357. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22358. }
  22359. }
  22360. declare module BABYLON {
  22361. /**
  22362. * Operations supported by the Trigonometry block
  22363. */
  22364. export enum TrigonometryBlockOperations {
  22365. /** Cos */
  22366. Cos = 0,
  22367. /** Sin */
  22368. Sin = 1,
  22369. /** Abs */
  22370. Abs = 2,
  22371. /** Exp */
  22372. Exp = 3,
  22373. /** Exp2 */
  22374. Exp2 = 4,
  22375. /** Round */
  22376. Round = 5,
  22377. /** Floor */
  22378. Floor = 6,
  22379. /** Ceiling */
  22380. Ceiling = 7,
  22381. /** Square root */
  22382. Sqrt = 8,
  22383. /** Log */
  22384. Log = 9,
  22385. /** Tangent */
  22386. Tan = 10,
  22387. /** Arc tangent */
  22388. ArcTan = 11,
  22389. /** Arc cosinus */
  22390. ArcCos = 12,
  22391. /** Arc sinus */
  22392. ArcSin = 13,
  22393. /** Fraction */
  22394. Fract = 14,
  22395. /** Sign */
  22396. Sign = 15,
  22397. /** To radians (from degrees) */
  22398. Radians = 16,
  22399. /** To degrees (from radians) */
  22400. Degrees = 17
  22401. }
  22402. /**
  22403. * Block used to apply trigonometry operation to floats
  22404. */
  22405. export class TrigonometryBlock extends NodeMaterialBlock {
  22406. /**
  22407. * Gets or sets the operation applied by the block
  22408. */
  22409. operation: TrigonometryBlockOperations;
  22410. /**
  22411. * Creates a new TrigonometryBlock
  22412. * @param name defines the block name
  22413. */
  22414. constructor(name: string);
  22415. /**
  22416. * Gets the current class name
  22417. * @returns the class name
  22418. */
  22419. getClassName(): string;
  22420. /**
  22421. * Gets the input component
  22422. */
  22423. get input(): NodeMaterialConnectionPoint;
  22424. /**
  22425. * Gets the output component
  22426. */
  22427. get output(): NodeMaterialConnectionPoint;
  22428. protected _buildBlock(state: NodeMaterialBuildState): this;
  22429. serialize(): any;
  22430. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22431. protected _dumpPropertiesCode(): string;
  22432. }
  22433. }
  22434. declare module BABYLON {
  22435. /**
  22436. * Interface used to configure the node material editor
  22437. */
  22438. export interface INodeMaterialEditorOptions {
  22439. /** Define the URl to load node editor script */
  22440. editorURL?: string;
  22441. }
  22442. /** @hidden */
  22443. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  22444. NORMAL: boolean;
  22445. TANGENT: boolean;
  22446. UV1: boolean;
  22447. /** BONES */
  22448. NUM_BONE_INFLUENCERS: number;
  22449. BonesPerMesh: number;
  22450. BONETEXTURE: boolean;
  22451. /** MORPH TARGETS */
  22452. MORPHTARGETS: boolean;
  22453. MORPHTARGETS_NORMAL: boolean;
  22454. MORPHTARGETS_TANGENT: boolean;
  22455. MORPHTARGETS_UV: boolean;
  22456. NUM_MORPH_INFLUENCERS: number;
  22457. /** IMAGE PROCESSING */
  22458. IMAGEPROCESSING: boolean;
  22459. VIGNETTE: boolean;
  22460. VIGNETTEBLENDMODEMULTIPLY: boolean;
  22461. VIGNETTEBLENDMODEOPAQUE: boolean;
  22462. TONEMAPPING: boolean;
  22463. TONEMAPPING_ACES: boolean;
  22464. CONTRAST: boolean;
  22465. EXPOSURE: boolean;
  22466. COLORCURVES: boolean;
  22467. COLORGRADING: boolean;
  22468. COLORGRADING3D: boolean;
  22469. SAMPLER3DGREENDEPTH: boolean;
  22470. SAMPLER3DBGRMAP: boolean;
  22471. IMAGEPROCESSINGPOSTPROCESS: boolean;
  22472. /** MISC. */
  22473. BUMPDIRECTUV: number;
  22474. constructor();
  22475. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  22476. }
  22477. /**
  22478. * Class used to configure NodeMaterial
  22479. */
  22480. export interface INodeMaterialOptions {
  22481. /**
  22482. * Defines if blocks should emit comments
  22483. */
  22484. emitComments: boolean;
  22485. }
  22486. /**
  22487. * Class used to create a node based material built by assembling shader blocks
  22488. */
  22489. export class NodeMaterial extends PushMaterial {
  22490. private static _BuildIdGenerator;
  22491. private _options;
  22492. private _vertexCompilationState;
  22493. private _fragmentCompilationState;
  22494. private _sharedData;
  22495. private _buildId;
  22496. private _buildWasSuccessful;
  22497. private _cachedWorldViewMatrix;
  22498. private _cachedWorldViewProjectionMatrix;
  22499. private _optimizers;
  22500. private _animationFrame;
  22501. /** Define the Url to load node editor script */
  22502. static EditorURL: string;
  22503. /** Define the Url to load snippets */
  22504. static SnippetUrl: string;
  22505. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  22506. static IgnoreTexturesAtLoadTime: boolean;
  22507. private BJSNODEMATERIALEDITOR;
  22508. /** Get the inspector from bundle or global */
  22509. private _getGlobalNodeMaterialEditor;
  22510. /**
  22511. * Snippet ID if the material was created from the snippet server
  22512. */
  22513. snippetId: string;
  22514. /**
  22515. * Gets or sets data used by visual editor
  22516. * @see https://nme.babylonjs.com
  22517. */
  22518. editorData: any;
  22519. /**
  22520. * 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)
  22521. */
  22522. ignoreAlpha: boolean;
  22523. /**
  22524. * Defines the maximum number of lights that can be used in the material
  22525. */
  22526. maxSimultaneousLights: number;
  22527. /**
  22528. * Observable raised when the material is built
  22529. */
  22530. onBuildObservable: Observable<NodeMaterial>;
  22531. /**
  22532. * Gets or sets the root nodes of the material vertex shader
  22533. */
  22534. _vertexOutputNodes: NodeMaterialBlock[];
  22535. /**
  22536. * Gets or sets the root nodes of the material fragment (pixel) shader
  22537. */
  22538. _fragmentOutputNodes: NodeMaterialBlock[];
  22539. /** Gets or sets options to control the node material overall behavior */
  22540. get options(): INodeMaterialOptions;
  22541. set options(options: INodeMaterialOptions);
  22542. /**
  22543. * Default configuration related to image processing available in the standard Material.
  22544. */
  22545. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  22546. /**
  22547. * Gets the image processing configuration used either in this material.
  22548. */
  22549. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  22550. /**
  22551. * Sets the Default image processing configuration used either in the this material.
  22552. *
  22553. * If sets to null, the scene one is in use.
  22554. */
  22555. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  22556. /**
  22557. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  22558. */
  22559. attachedBlocks: NodeMaterialBlock[];
  22560. /**
  22561. * Specifies the mode of the node material
  22562. * @hidden
  22563. */
  22564. _mode: NodeMaterialModes;
  22565. /**
  22566. * Gets the mode property
  22567. */
  22568. get mode(): NodeMaterialModes;
  22569. /**
  22570. * Create a new node based material
  22571. * @param name defines the material name
  22572. * @param scene defines the hosting scene
  22573. * @param options defines creation option
  22574. */
  22575. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  22576. /**
  22577. * Gets the current class name of the material e.g. "NodeMaterial"
  22578. * @returns the class name
  22579. */
  22580. getClassName(): string;
  22581. /**
  22582. * Keep track of the image processing observer to allow dispose and replace.
  22583. */
  22584. private _imageProcessingObserver;
  22585. /**
  22586. * Attaches a new image processing configuration to the Standard Material.
  22587. * @param configuration
  22588. */
  22589. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  22590. /**
  22591. * Get a block by its name
  22592. * @param name defines the name of the block to retrieve
  22593. * @returns the required block or null if not found
  22594. */
  22595. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  22596. /**
  22597. * Get a block by its name
  22598. * @param predicate defines the predicate used to find the good candidate
  22599. * @returns the required block or null if not found
  22600. */
  22601. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  22602. /**
  22603. * Get an input block by its name
  22604. * @param predicate defines the predicate used to find the good candidate
  22605. * @returns the required input block or null if not found
  22606. */
  22607. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  22608. /**
  22609. * Gets the list of input blocks attached to this material
  22610. * @returns an array of InputBlocks
  22611. */
  22612. getInputBlocks(): InputBlock[];
  22613. /**
  22614. * Adds a new optimizer to the list of optimizers
  22615. * @param optimizer defines the optimizers to add
  22616. * @returns the current material
  22617. */
  22618. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22619. /**
  22620. * Remove an optimizer from the list of optimizers
  22621. * @param optimizer defines the optimizers to remove
  22622. * @returns the current material
  22623. */
  22624. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  22625. /**
  22626. * Add a new block to the list of output nodes
  22627. * @param node defines the node to add
  22628. * @returns the current material
  22629. */
  22630. addOutputNode(node: NodeMaterialBlock): this;
  22631. /**
  22632. * Remove a block from the list of root nodes
  22633. * @param node defines the node to remove
  22634. * @returns the current material
  22635. */
  22636. removeOutputNode(node: NodeMaterialBlock): this;
  22637. private _addVertexOutputNode;
  22638. private _removeVertexOutputNode;
  22639. private _addFragmentOutputNode;
  22640. private _removeFragmentOutputNode;
  22641. /**
  22642. * Specifies if the material will require alpha blending
  22643. * @returns a boolean specifying if alpha blending is needed
  22644. */
  22645. needAlphaBlending(): boolean;
  22646. /**
  22647. * Specifies if this material should be rendered in alpha test mode
  22648. * @returns a boolean specifying if an alpha test is needed.
  22649. */
  22650. needAlphaTesting(): boolean;
  22651. private _initializeBlock;
  22652. private _resetDualBlocks;
  22653. /**
  22654. * Remove a block from the current node material
  22655. * @param block defines the block to remove
  22656. */
  22657. removeBlock(block: NodeMaterialBlock): void;
  22658. /**
  22659. * Build the material and generates the inner effect
  22660. * @param verbose defines if the build should log activity
  22661. */
  22662. build(verbose?: boolean): void;
  22663. /**
  22664. * Runs an otpimization phase to try to improve the shader code
  22665. */
  22666. optimize(): void;
  22667. private _prepareDefinesForAttributes;
  22668. /**
  22669. * Create a post process from the material
  22670. * @param camera The camera to apply the render pass to.
  22671. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  22672. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  22673. * @param engine The engine which the post process will be applied. (default: current engine)
  22674. * @param reusable If the post process can be reused on the same frame. (default: false)
  22675. * @param textureType Type of textures used when performing the post process. (default: 0)
  22676. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  22677. * @returns the post process created
  22678. */
  22679. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  22680. /**
  22681. * Create the post process effect from the material
  22682. * @param postProcess The post process to create the effect for
  22683. */
  22684. createEffectForPostProcess(postProcess: PostProcess): void;
  22685. private _createEffectForPostProcess;
  22686. /**
  22687. * Create a new procedural texture based on this node material
  22688. * @param size defines the size of the texture
  22689. * @param scene defines the hosting scene
  22690. * @returns the new procedural texture attached to this node material
  22691. */
  22692. createProceduralTexture(size: number | {
  22693. width: number;
  22694. height: number;
  22695. layers?: number;
  22696. }, scene: Scene): Nullable<ProceduralTexture>;
  22697. private _createEffectForParticles;
  22698. private _checkInternals;
  22699. /**
  22700. * Create the effect to be used as the custom effect for a particle system
  22701. * @param particleSystem Particle system to create the effect for
  22702. * @param onCompiled defines a function to call when the effect creation is successful
  22703. * @param onError defines a function to call when the effect creation has failed
  22704. */
  22705. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  22706. private _processDefines;
  22707. /**
  22708. * Get if the submesh is ready to be used and all its information available.
  22709. * Child classes can use it to update shaders
  22710. * @param mesh defines the mesh to check
  22711. * @param subMesh defines which submesh to check
  22712. * @param useInstances specifies that instances should be used
  22713. * @returns a boolean indicating that the submesh is ready or not
  22714. */
  22715. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  22716. /**
  22717. * Get a string representing the shaders built by the current node graph
  22718. */
  22719. get compiledShaders(): string;
  22720. /**
  22721. * Binds the world matrix to the material
  22722. * @param world defines the world transformation matrix
  22723. */
  22724. bindOnlyWorldMatrix(world: Matrix): void;
  22725. /**
  22726. * Binds the submesh to this material by preparing the effect and shader to draw
  22727. * @param world defines the world transformation matrix
  22728. * @param mesh defines the mesh containing the submesh
  22729. * @param subMesh defines the submesh to bind the material to
  22730. */
  22731. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22732. /**
  22733. * Gets the active textures from the material
  22734. * @returns an array of textures
  22735. */
  22736. getActiveTextures(): BaseTexture[];
  22737. /**
  22738. * Gets the list of texture blocks
  22739. * @returns an array of texture blocks
  22740. */
  22741. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  22742. /**
  22743. * Specifies if the material uses a texture
  22744. * @param texture defines the texture to check against the material
  22745. * @returns a boolean specifying if the material uses the texture
  22746. */
  22747. hasTexture(texture: BaseTexture): boolean;
  22748. /**
  22749. * Disposes the material
  22750. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22751. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22752. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22753. */
  22754. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22755. /** Creates the node editor window. */
  22756. private _createNodeEditor;
  22757. /**
  22758. * Launch the node material editor
  22759. * @param config Define the configuration of the editor
  22760. * @return a promise fulfilled when the node editor is visible
  22761. */
  22762. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  22763. /**
  22764. * Clear the current material
  22765. */
  22766. clear(): void;
  22767. /**
  22768. * Clear the current material and set it to a default state
  22769. */
  22770. setToDefault(): void;
  22771. /**
  22772. * Clear the current material and set it to a default state for post process
  22773. */
  22774. setToDefaultPostProcess(): void;
  22775. /**
  22776. * Clear the current material and set it to a default state for procedural texture
  22777. */
  22778. setToDefaultProceduralTexture(): void;
  22779. /**
  22780. * Clear the current material and set it to a default state for particle
  22781. */
  22782. setToDefaultParticle(): void;
  22783. /**
  22784. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  22785. * @param url defines the url to load from
  22786. * @returns a promise that will fullfil when the material is fully loaded
  22787. */
  22788. loadAsync(url: string): Promise<void>;
  22789. private _gatherBlocks;
  22790. /**
  22791. * Generate a string containing the code declaration required to create an equivalent of this material
  22792. * @returns a string
  22793. */
  22794. generateCode(): string;
  22795. /**
  22796. * Serializes this material in a JSON representation
  22797. * @returns the serialized material object
  22798. */
  22799. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  22800. private _restoreConnections;
  22801. /**
  22802. * Clear the current graph and load a new one from a serialization object
  22803. * @param source defines the JSON representation of the material
  22804. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22805. * @param merge defines whether or not the source must be merged or replace the current content
  22806. */
  22807. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  22808. /**
  22809. * Makes a duplicate of the current material.
  22810. * @param name - name to use for the new material.
  22811. */
  22812. clone(name: string): NodeMaterial;
  22813. /**
  22814. * Creates a node material from parsed material data
  22815. * @param source defines the JSON representation of the material
  22816. * @param scene defines the hosting scene
  22817. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22818. * @returns a new node material
  22819. */
  22820. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  22821. /**
  22822. * Creates a node material from a snippet saved in a remote file
  22823. * @param name defines the name of the material to create
  22824. * @param url defines the url to load from
  22825. * @param scene defines the hosting scene
  22826. * @returns a promise that will resolve to the new node material
  22827. */
  22828. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  22829. /**
  22830. * Creates a node material from a snippet saved by the node material editor
  22831. * @param snippetId defines the snippet to load
  22832. * @param scene defines the hosting scene
  22833. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22834. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  22835. * @returns a promise that will resolve to the new node material
  22836. */
  22837. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  22838. /**
  22839. * Creates a new node material set to default basic configuration
  22840. * @param name defines the name of the material
  22841. * @param scene defines the hosting scene
  22842. * @returns a new NodeMaterial
  22843. */
  22844. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  22845. }
  22846. }
  22847. declare module BABYLON {
  22848. interface ThinEngine {
  22849. /**
  22850. * Unbind a list of render target textures from the webGL context
  22851. * This is used only when drawBuffer extension or webGL2 are active
  22852. * @param textures defines the render target textures to unbind
  22853. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  22854. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  22855. */
  22856. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  22857. /**
  22858. * Create a multi render target texture
  22859. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  22860. * @param size defines the size of the texture
  22861. * @param options defines the creation options
  22862. * @returns the cube texture as an InternalTexture
  22863. */
  22864. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  22865. /**
  22866. * Update the sample count for a given multiple render target texture
  22867. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  22868. * @param textures defines the textures to update
  22869. * @param samples defines the sample count to set
  22870. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  22871. */
  22872. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  22873. /**
  22874. * Select a subsets of attachments to draw to.
  22875. * @param attachments gl attachments
  22876. */
  22877. bindAttachments(attachments: number[]): void;
  22878. /**
  22879. * Creates a layout object to draw/clear on specific textures in a MRT
  22880. * @param textureStatus textureStatus[i] indicates if the i-th is active
  22881. * @returns A layout to be fed to the engine, calling `bindAttachments`.
  22882. */
  22883. buildTextureLayout(textureStatus: boolean[]): number[];
  22884. /**
  22885. * Restores the webgl state to only draw on the main color attachment
  22886. */
  22887. restoreSingleAttachment(): void;
  22888. }
  22889. }
  22890. declare module BABYLON {
  22891. /**
  22892. * Creation options of the multi render target texture.
  22893. */
  22894. export interface IMultiRenderTargetOptions {
  22895. /**
  22896. * Define if the texture needs to create mip maps after render.
  22897. */
  22898. generateMipMaps?: boolean;
  22899. /**
  22900. * Define the types of all the draw buffers we want to create
  22901. */
  22902. types?: number[];
  22903. /**
  22904. * Define the sampling modes of all the draw buffers we want to create
  22905. */
  22906. samplingModes?: number[];
  22907. /**
  22908. * Define if a depth buffer is required
  22909. */
  22910. generateDepthBuffer?: boolean;
  22911. /**
  22912. * Define if a stencil buffer is required
  22913. */
  22914. generateStencilBuffer?: boolean;
  22915. /**
  22916. * Define if a depth texture is required instead of a depth buffer
  22917. */
  22918. generateDepthTexture?: boolean;
  22919. /**
  22920. * Define the number of desired draw buffers
  22921. */
  22922. textureCount?: number;
  22923. /**
  22924. * Define if aspect ratio should be adapted to the texture or stay the scene one
  22925. */
  22926. doNotChangeAspectRatio?: boolean;
  22927. /**
  22928. * Define the default type of the buffers we are creating
  22929. */
  22930. defaultType?: number;
  22931. }
  22932. /**
  22933. * A multi render target, like a render target provides the ability to render to a texture.
  22934. * Unlike the render target, it can render to several draw buffers in one draw.
  22935. * This is specially interesting in deferred rendering or for any effects requiring more than
  22936. * just one color from a single pass.
  22937. */
  22938. export class MultiRenderTarget extends RenderTargetTexture {
  22939. private _internalTextures;
  22940. private _textures;
  22941. private _multiRenderTargetOptions;
  22942. private _count;
  22943. /**
  22944. * Get if draw buffers are currently supported by the used hardware and browser.
  22945. */
  22946. get isSupported(): boolean;
  22947. /**
  22948. * Get the list of textures generated by the multi render target.
  22949. */
  22950. get textures(): Texture[];
  22951. /**
  22952. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  22953. */
  22954. get count(): number;
  22955. /**
  22956. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  22957. */
  22958. get depthTexture(): Texture;
  22959. /**
  22960. * Set the wrapping mode on U of all the textures we are rendering to.
  22961. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  22962. */
  22963. set wrapU(wrap: number);
  22964. /**
  22965. * Set the wrapping mode on V of all the textures we are rendering to.
  22966. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  22967. */
  22968. set wrapV(wrap: number);
  22969. /**
  22970. * Instantiate a new multi render target texture.
  22971. * A multi render target, like a render target provides the ability to render to a texture.
  22972. * Unlike the render target, it can render to several draw buffers in one draw.
  22973. * This is specially interesting in deferred rendering or for any effects requiring more than
  22974. * just one color from a single pass.
  22975. * @param name Define the name of the texture
  22976. * @param size Define the size of the buffers to render to
  22977. * @param count Define the number of target we are rendering into
  22978. * @param scene Define the scene the texture belongs to
  22979. * @param options Define the options used to create the multi render target
  22980. */
  22981. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  22982. private _initTypes;
  22983. /** @hidden */
  22984. _rebuild(forceFullRebuild?: boolean): void;
  22985. private _createInternalTextures;
  22986. private _createTextures;
  22987. /**
  22988. * Replaces a texture within the MRT.
  22989. * @param texture The new texture to insert in the MRT
  22990. * @param index The index of the texture to replace
  22991. */
  22992. replaceTexture(texture: Texture, index: number): void;
  22993. /**
  22994. * Define the number of samples used if MSAA is enabled.
  22995. */
  22996. get samples(): number;
  22997. set samples(value: number);
  22998. /**
  22999. * Resize all the textures in the multi render target.
  23000. * Be careful as it will recreate all the data in the new texture.
  23001. * @param size Define the new size
  23002. */
  23003. resize(size: any): void;
  23004. /**
  23005. * Changes the number of render targets in this MRT
  23006. * Be careful as it will recreate all the data in the new texture.
  23007. * @param count new texture count
  23008. * @param options Specifies texture types and sampling modes for new textures
  23009. */
  23010. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  23011. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  23012. /**
  23013. * Dispose the render targets and their associated resources
  23014. */
  23015. dispose(): void;
  23016. /**
  23017. * Release all the underlying texture used as draw buffers.
  23018. */
  23019. releaseInternalTextures(): void;
  23020. }
  23021. }
  23022. declare module BABYLON {
  23023. /** @hidden */
  23024. export var imageProcessingPixelShader: {
  23025. name: string;
  23026. shader: string;
  23027. };
  23028. }
  23029. declare module BABYLON {
  23030. /**
  23031. * ImageProcessingPostProcess
  23032. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  23033. */
  23034. export class ImageProcessingPostProcess extends PostProcess {
  23035. /**
  23036. * Default configuration related to image processing available in the PBR Material.
  23037. */
  23038. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  23039. /**
  23040. * Gets the image processing configuration used either in this material.
  23041. */
  23042. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  23043. /**
  23044. * Sets the Default image processing configuration used either in the this material.
  23045. *
  23046. * If sets to null, the scene one is in use.
  23047. */
  23048. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  23049. /**
  23050. * Keep track of the image processing observer to allow dispose and replace.
  23051. */
  23052. private _imageProcessingObserver;
  23053. /**
  23054. * Attaches a new image processing configuration to the PBR Material.
  23055. * @param configuration
  23056. */
  23057. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  23058. /**
  23059. * If the post process is supported.
  23060. */
  23061. get isSupported(): boolean;
  23062. /**
  23063. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  23064. */
  23065. get colorCurves(): Nullable<ColorCurves>;
  23066. /**
  23067. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  23068. */
  23069. set colorCurves(value: Nullable<ColorCurves>);
  23070. /**
  23071. * Gets wether the color curves effect is enabled.
  23072. */
  23073. get colorCurvesEnabled(): boolean;
  23074. /**
  23075. * Sets wether the color curves effect is enabled.
  23076. */
  23077. set colorCurvesEnabled(value: boolean);
  23078. /**
  23079. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  23080. */
  23081. get colorGradingTexture(): Nullable<BaseTexture>;
  23082. /**
  23083. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  23084. */
  23085. set colorGradingTexture(value: Nullable<BaseTexture>);
  23086. /**
  23087. * Gets wether the color grading effect is enabled.
  23088. */
  23089. get colorGradingEnabled(): boolean;
  23090. /**
  23091. * Gets wether the color grading effect is enabled.
  23092. */
  23093. set colorGradingEnabled(value: boolean);
  23094. /**
  23095. * Gets exposure used in the effect.
  23096. */
  23097. get exposure(): number;
  23098. /**
  23099. * Sets exposure used in the effect.
  23100. */
  23101. set exposure(value: number);
  23102. /**
  23103. * Gets wether tonemapping is enabled or not.
  23104. */
  23105. get toneMappingEnabled(): boolean;
  23106. /**
  23107. * Sets wether tonemapping is enabled or not
  23108. */
  23109. set toneMappingEnabled(value: boolean);
  23110. /**
  23111. * Gets the type of tone mapping effect.
  23112. */
  23113. get toneMappingType(): number;
  23114. /**
  23115. * Sets the type of tone mapping effect.
  23116. */
  23117. set toneMappingType(value: number);
  23118. /**
  23119. * Gets contrast used in the effect.
  23120. */
  23121. get contrast(): number;
  23122. /**
  23123. * Sets contrast used in the effect.
  23124. */
  23125. set contrast(value: number);
  23126. /**
  23127. * Gets Vignette stretch size.
  23128. */
  23129. get vignetteStretch(): number;
  23130. /**
  23131. * Sets Vignette stretch size.
  23132. */
  23133. set vignetteStretch(value: number);
  23134. /**
  23135. * Gets Vignette centre X Offset.
  23136. */
  23137. get vignetteCentreX(): number;
  23138. /**
  23139. * Sets Vignette centre X Offset.
  23140. */
  23141. set vignetteCentreX(value: number);
  23142. /**
  23143. * Gets Vignette centre Y Offset.
  23144. */
  23145. get vignetteCentreY(): number;
  23146. /**
  23147. * Sets Vignette centre Y Offset.
  23148. */
  23149. set vignetteCentreY(value: number);
  23150. /**
  23151. * Gets Vignette weight or intensity of the vignette effect.
  23152. */
  23153. get vignetteWeight(): number;
  23154. /**
  23155. * Sets Vignette weight or intensity of the vignette effect.
  23156. */
  23157. set vignetteWeight(value: number);
  23158. /**
  23159. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  23160. * if vignetteEnabled is set to true.
  23161. */
  23162. get vignetteColor(): Color4;
  23163. /**
  23164. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  23165. * if vignetteEnabled is set to true.
  23166. */
  23167. set vignetteColor(value: Color4);
  23168. /**
  23169. * Gets Camera field of view used by the Vignette effect.
  23170. */
  23171. get vignetteCameraFov(): number;
  23172. /**
  23173. * Sets Camera field of view used by the Vignette effect.
  23174. */
  23175. set vignetteCameraFov(value: number);
  23176. /**
  23177. * Gets the vignette blend mode allowing different kind of effect.
  23178. */
  23179. get vignetteBlendMode(): number;
  23180. /**
  23181. * Sets the vignette blend mode allowing different kind of effect.
  23182. */
  23183. set vignetteBlendMode(value: number);
  23184. /**
  23185. * Gets wether the vignette effect is enabled.
  23186. */
  23187. get vignetteEnabled(): boolean;
  23188. /**
  23189. * Sets wether the vignette effect is enabled.
  23190. */
  23191. set vignetteEnabled(value: boolean);
  23192. private _fromLinearSpace;
  23193. /**
  23194. * Gets wether the input of the processing is in Gamma or Linear Space.
  23195. */
  23196. get fromLinearSpace(): boolean;
  23197. /**
  23198. * Sets wether the input of the processing is in Gamma or Linear Space.
  23199. */
  23200. set fromLinearSpace(value: boolean);
  23201. /**
  23202. * Defines cache preventing GC.
  23203. */
  23204. private _defines;
  23205. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  23206. /**
  23207. * "ImageProcessingPostProcess"
  23208. * @returns "ImageProcessingPostProcess"
  23209. */
  23210. getClassName(): string;
  23211. /**
  23212. * @hidden
  23213. */
  23214. _updateParameters(): void;
  23215. dispose(camera?: Camera): void;
  23216. }
  23217. }
  23218. declare module BABYLON {
  23219. /**
  23220. * Interface for defining prepass effects in the prepass post-process pipeline
  23221. */
  23222. export interface PrePassEffectConfiguration {
  23223. /**
  23224. * Name of the effect
  23225. */
  23226. name: string;
  23227. /**
  23228. * Post process to attach for this effect
  23229. */
  23230. postProcess?: PostProcess;
  23231. /**
  23232. * Textures required in the MRT
  23233. */
  23234. texturesRequired: number[];
  23235. /**
  23236. * Is the effect enabled
  23237. */
  23238. enabled: boolean;
  23239. /**
  23240. * Disposes the effect configuration
  23241. */
  23242. dispose?: () => void;
  23243. /**
  23244. * Creates the associated post process
  23245. */
  23246. createPostProcess?: () => PostProcess;
  23247. }
  23248. }
  23249. declare module BABYLON {
  23250. /**
  23251. * Options to be used when creating a FresnelParameters.
  23252. */
  23253. export type IFresnelParametersCreationOptions = {
  23254. /**
  23255. * Define the color used on edges (grazing angle)
  23256. */
  23257. leftColor?: Color3;
  23258. /**
  23259. * Define the color used on center
  23260. */
  23261. rightColor?: Color3;
  23262. /**
  23263. * Define bias applied to computed fresnel term
  23264. */
  23265. bias?: number;
  23266. /**
  23267. * Defined the power exponent applied to fresnel term
  23268. */
  23269. power?: number;
  23270. /**
  23271. * Define if the fresnel effect is enable or not.
  23272. */
  23273. isEnabled?: boolean;
  23274. };
  23275. /**
  23276. * Serialized format for FresnelParameters.
  23277. */
  23278. export type IFresnelParametersSerialized = {
  23279. /**
  23280. * Define the color used on edges (grazing angle) [as an array]
  23281. */
  23282. leftColor: number[];
  23283. /**
  23284. * Define the color used on center [as an array]
  23285. */
  23286. rightColor: number[];
  23287. /**
  23288. * Define bias applied to computed fresnel term
  23289. */
  23290. bias: number;
  23291. /**
  23292. * Defined the power exponent applied to fresnel term
  23293. */
  23294. power?: number;
  23295. /**
  23296. * Define if the fresnel effect is enable or not.
  23297. */
  23298. isEnabled: boolean;
  23299. };
  23300. /**
  23301. * This represents all the required information to add a fresnel effect on a material:
  23302. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  23303. */
  23304. export class FresnelParameters {
  23305. private _isEnabled;
  23306. /**
  23307. * Define if the fresnel effect is enable or not.
  23308. */
  23309. get isEnabled(): boolean;
  23310. set isEnabled(value: boolean);
  23311. /**
  23312. * Define the color used on edges (grazing angle)
  23313. */
  23314. leftColor: Color3;
  23315. /**
  23316. * Define the color used on center
  23317. */
  23318. rightColor: Color3;
  23319. /**
  23320. * Define bias applied to computed fresnel term
  23321. */
  23322. bias: number;
  23323. /**
  23324. * Defined the power exponent applied to fresnel term
  23325. */
  23326. power: number;
  23327. /**
  23328. * Creates a new FresnelParameters object.
  23329. *
  23330. * @param options provide your own settings to optionally to override defaults
  23331. */
  23332. constructor(options?: IFresnelParametersCreationOptions);
  23333. /**
  23334. * Clones the current fresnel and its valuues
  23335. * @returns a clone fresnel configuration
  23336. */
  23337. clone(): FresnelParameters;
  23338. /**
  23339. * Determines equality between FresnelParameters objects
  23340. * @param otherFresnelParameters defines the second operand
  23341. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  23342. */
  23343. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  23344. /**
  23345. * Serializes the current fresnel parameters to a JSON representation.
  23346. * @return the JSON serialization
  23347. */
  23348. serialize(): IFresnelParametersSerialized;
  23349. /**
  23350. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  23351. * @param parsedFresnelParameters Define the JSON representation
  23352. * @returns the parsed parameters
  23353. */
  23354. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  23355. }
  23356. }
  23357. declare module BABYLON {
  23358. /**
  23359. * This groups all the flags used to control the materials channel.
  23360. */
  23361. export class MaterialFlags {
  23362. private static _DiffuseTextureEnabled;
  23363. /**
  23364. * Are diffuse textures enabled in the application.
  23365. */
  23366. static get DiffuseTextureEnabled(): boolean;
  23367. static set DiffuseTextureEnabled(value: boolean);
  23368. private static _DetailTextureEnabled;
  23369. /**
  23370. * Are detail textures enabled in the application.
  23371. */
  23372. static get DetailTextureEnabled(): boolean;
  23373. static set DetailTextureEnabled(value: boolean);
  23374. private static _AmbientTextureEnabled;
  23375. /**
  23376. * Are ambient textures enabled in the application.
  23377. */
  23378. static get AmbientTextureEnabled(): boolean;
  23379. static set AmbientTextureEnabled(value: boolean);
  23380. private static _OpacityTextureEnabled;
  23381. /**
  23382. * Are opacity textures enabled in the application.
  23383. */
  23384. static get OpacityTextureEnabled(): boolean;
  23385. static set OpacityTextureEnabled(value: boolean);
  23386. private static _ReflectionTextureEnabled;
  23387. /**
  23388. * Are reflection textures enabled in the application.
  23389. */
  23390. static get ReflectionTextureEnabled(): boolean;
  23391. static set ReflectionTextureEnabled(value: boolean);
  23392. private static _EmissiveTextureEnabled;
  23393. /**
  23394. * Are emissive textures enabled in the application.
  23395. */
  23396. static get EmissiveTextureEnabled(): boolean;
  23397. static set EmissiveTextureEnabled(value: boolean);
  23398. private static _SpecularTextureEnabled;
  23399. /**
  23400. * Are specular textures enabled in the application.
  23401. */
  23402. static get SpecularTextureEnabled(): boolean;
  23403. static set SpecularTextureEnabled(value: boolean);
  23404. private static _BumpTextureEnabled;
  23405. /**
  23406. * Are bump textures enabled in the application.
  23407. */
  23408. static get BumpTextureEnabled(): boolean;
  23409. static set BumpTextureEnabled(value: boolean);
  23410. private static _LightmapTextureEnabled;
  23411. /**
  23412. * Are lightmap textures enabled in the application.
  23413. */
  23414. static get LightmapTextureEnabled(): boolean;
  23415. static set LightmapTextureEnabled(value: boolean);
  23416. private static _RefractionTextureEnabled;
  23417. /**
  23418. * Are refraction textures enabled in the application.
  23419. */
  23420. static get RefractionTextureEnabled(): boolean;
  23421. static set RefractionTextureEnabled(value: boolean);
  23422. private static _ColorGradingTextureEnabled;
  23423. /**
  23424. * Are color grading textures enabled in the application.
  23425. */
  23426. static get ColorGradingTextureEnabled(): boolean;
  23427. static set ColorGradingTextureEnabled(value: boolean);
  23428. private static _FresnelEnabled;
  23429. /**
  23430. * Are fresnels enabled in the application.
  23431. */
  23432. static get FresnelEnabled(): boolean;
  23433. static set FresnelEnabled(value: boolean);
  23434. private static _ClearCoatTextureEnabled;
  23435. /**
  23436. * Are clear coat textures enabled in the application.
  23437. */
  23438. static get ClearCoatTextureEnabled(): boolean;
  23439. static set ClearCoatTextureEnabled(value: boolean);
  23440. private static _ClearCoatBumpTextureEnabled;
  23441. /**
  23442. * Are clear coat bump textures enabled in the application.
  23443. */
  23444. static get ClearCoatBumpTextureEnabled(): boolean;
  23445. static set ClearCoatBumpTextureEnabled(value: boolean);
  23446. private static _ClearCoatTintTextureEnabled;
  23447. /**
  23448. * Are clear coat tint textures enabled in the application.
  23449. */
  23450. static get ClearCoatTintTextureEnabled(): boolean;
  23451. static set ClearCoatTintTextureEnabled(value: boolean);
  23452. private static _SheenTextureEnabled;
  23453. /**
  23454. * Are sheen textures enabled in the application.
  23455. */
  23456. static get SheenTextureEnabled(): boolean;
  23457. static set SheenTextureEnabled(value: boolean);
  23458. private static _AnisotropicTextureEnabled;
  23459. /**
  23460. * Are anisotropic textures enabled in the application.
  23461. */
  23462. static get AnisotropicTextureEnabled(): boolean;
  23463. static set AnisotropicTextureEnabled(value: boolean);
  23464. private static _ThicknessTextureEnabled;
  23465. /**
  23466. * Are thickness textures enabled in the application.
  23467. */
  23468. static get ThicknessTextureEnabled(): boolean;
  23469. static set ThicknessTextureEnabled(value: boolean);
  23470. }
  23471. }
  23472. declare module BABYLON {
  23473. /** @hidden */
  23474. export var defaultFragmentDeclaration: {
  23475. name: string;
  23476. shader: string;
  23477. };
  23478. }
  23479. declare module BABYLON {
  23480. /** @hidden */
  23481. export var defaultUboDeclaration: {
  23482. name: string;
  23483. shader: string;
  23484. };
  23485. }
  23486. declare module BABYLON {
  23487. /** @hidden */
  23488. export var prePassDeclaration: {
  23489. name: string;
  23490. shader: string;
  23491. };
  23492. }
  23493. declare module BABYLON {
  23494. /** @hidden */
  23495. export var lightFragmentDeclaration: {
  23496. name: string;
  23497. shader: string;
  23498. };
  23499. }
  23500. declare module BABYLON {
  23501. /** @hidden */
  23502. export var lightUboDeclaration: {
  23503. name: string;
  23504. shader: string;
  23505. };
  23506. }
  23507. declare module BABYLON {
  23508. /** @hidden */
  23509. export var lightsFragmentFunctions: {
  23510. name: string;
  23511. shader: string;
  23512. };
  23513. }
  23514. declare module BABYLON {
  23515. /** @hidden */
  23516. export var shadowsFragmentFunctions: {
  23517. name: string;
  23518. shader: string;
  23519. };
  23520. }
  23521. declare module BABYLON {
  23522. /** @hidden */
  23523. export var fresnelFunction: {
  23524. name: string;
  23525. shader: string;
  23526. };
  23527. }
  23528. declare module BABYLON {
  23529. /** @hidden */
  23530. export var bumpFragmentMainFunctions: {
  23531. name: string;
  23532. shader: string;
  23533. };
  23534. }
  23535. declare module BABYLON {
  23536. /** @hidden */
  23537. export var bumpFragmentFunctions: {
  23538. name: string;
  23539. shader: string;
  23540. };
  23541. }
  23542. declare module BABYLON {
  23543. /** @hidden */
  23544. export var logDepthDeclaration: {
  23545. name: string;
  23546. shader: string;
  23547. };
  23548. }
  23549. declare module BABYLON {
  23550. /** @hidden */
  23551. export var bumpFragment: {
  23552. name: string;
  23553. shader: string;
  23554. };
  23555. }
  23556. declare module BABYLON {
  23557. /** @hidden */
  23558. export var depthPrePass: {
  23559. name: string;
  23560. shader: string;
  23561. };
  23562. }
  23563. declare module BABYLON {
  23564. /** @hidden */
  23565. export var lightFragment: {
  23566. name: string;
  23567. shader: string;
  23568. };
  23569. }
  23570. declare module BABYLON {
  23571. /** @hidden */
  23572. export var logDepthFragment: {
  23573. name: string;
  23574. shader: string;
  23575. };
  23576. }
  23577. declare module BABYLON {
  23578. /** @hidden */
  23579. export var defaultPixelShader: {
  23580. name: string;
  23581. shader: string;
  23582. };
  23583. }
  23584. declare module BABYLON {
  23585. /** @hidden */
  23586. export var defaultVertexDeclaration: {
  23587. name: string;
  23588. shader: string;
  23589. };
  23590. }
  23591. declare module BABYLON {
  23592. /** @hidden */
  23593. export var prePassVertexDeclaration: {
  23594. name: string;
  23595. shader: string;
  23596. };
  23597. }
  23598. declare module BABYLON {
  23599. /** @hidden */
  23600. export var bumpVertexDeclaration: {
  23601. name: string;
  23602. shader: string;
  23603. };
  23604. }
  23605. declare module BABYLON {
  23606. /** @hidden */
  23607. export var prePassVertex: {
  23608. name: string;
  23609. shader: string;
  23610. };
  23611. }
  23612. declare module BABYLON {
  23613. /** @hidden */
  23614. export var bumpVertex: {
  23615. name: string;
  23616. shader: string;
  23617. };
  23618. }
  23619. declare module BABYLON {
  23620. /** @hidden */
  23621. export var fogVertex: {
  23622. name: string;
  23623. shader: string;
  23624. };
  23625. }
  23626. declare module BABYLON {
  23627. /** @hidden */
  23628. export var shadowsVertex: {
  23629. name: string;
  23630. shader: string;
  23631. };
  23632. }
  23633. declare module BABYLON {
  23634. /** @hidden */
  23635. export var pointCloudVertex: {
  23636. name: string;
  23637. shader: string;
  23638. };
  23639. }
  23640. declare module BABYLON {
  23641. /** @hidden */
  23642. export var logDepthVertex: {
  23643. name: string;
  23644. shader: string;
  23645. };
  23646. }
  23647. declare module BABYLON {
  23648. /** @hidden */
  23649. export var defaultVertexShader: {
  23650. name: string;
  23651. shader: string;
  23652. };
  23653. }
  23654. declare module BABYLON {
  23655. /**
  23656. * @hidden
  23657. */
  23658. export interface IMaterialDetailMapDefines {
  23659. DETAIL: boolean;
  23660. DETAILDIRECTUV: number;
  23661. DETAIL_NORMALBLENDMETHOD: number;
  23662. /** @hidden */
  23663. _areTexturesDirty: boolean;
  23664. }
  23665. /**
  23666. * Define the code related to the detail map parameters of a material
  23667. *
  23668. * Inspired from:
  23669. * 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
  23670. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  23671. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  23672. */
  23673. export class DetailMapConfiguration {
  23674. private _texture;
  23675. /**
  23676. * The detail texture of the material.
  23677. */
  23678. texture: Nullable<BaseTexture>;
  23679. /**
  23680. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  23681. * Bigger values mean stronger blending
  23682. */
  23683. diffuseBlendLevel: number;
  23684. /**
  23685. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  23686. * Bigger values mean stronger blending. Only used with PBR materials
  23687. */
  23688. roughnessBlendLevel: number;
  23689. /**
  23690. * Defines how strong the bump effect from the detail map is
  23691. * Bigger values mean stronger effect
  23692. */
  23693. bumpLevel: number;
  23694. private _normalBlendMethod;
  23695. /**
  23696. * The method used to blend the bump and detail normals together
  23697. */
  23698. normalBlendMethod: number;
  23699. private _isEnabled;
  23700. /**
  23701. * Enable or disable the detail map on this material
  23702. */
  23703. isEnabled: boolean;
  23704. /** @hidden */
  23705. private _internalMarkAllSubMeshesAsTexturesDirty;
  23706. /** @hidden */
  23707. _markAllSubMeshesAsTexturesDirty(): void;
  23708. /**
  23709. * Instantiate a new detail map
  23710. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  23711. */
  23712. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  23713. /**
  23714. * Gets whether the submesh is ready to be used or not.
  23715. * @param defines the list of "defines" to update.
  23716. * @param scene defines the scene the material belongs to.
  23717. * @returns - boolean indicating that the submesh is ready or not.
  23718. */
  23719. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  23720. /**
  23721. * Update the defines for detail map usage
  23722. * @param defines the list of "defines" to update.
  23723. * @param scene defines the scene the material belongs to.
  23724. */
  23725. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  23726. /**
  23727. * Binds the material data.
  23728. * @param uniformBuffer defines the Uniform buffer to fill in.
  23729. * @param scene defines the scene the material belongs to.
  23730. * @param isFrozen defines whether the material is frozen or not.
  23731. */
  23732. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  23733. /**
  23734. * Checks to see if a texture is used in the material.
  23735. * @param texture - Base texture to use.
  23736. * @returns - Boolean specifying if a texture is used in the material.
  23737. */
  23738. hasTexture(texture: BaseTexture): boolean;
  23739. /**
  23740. * Returns an array of the actively used textures.
  23741. * @param activeTextures Array of BaseTextures
  23742. */
  23743. getActiveTextures(activeTextures: BaseTexture[]): void;
  23744. /**
  23745. * Returns the animatable textures.
  23746. * @param animatables Array of animatable textures.
  23747. */
  23748. getAnimatables(animatables: IAnimatable[]): void;
  23749. /**
  23750. * Disposes the resources of the material.
  23751. * @param forceDisposeTextures - Forces the disposal of all textures.
  23752. */
  23753. dispose(forceDisposeTextures?: boolean): void;
  23754. /**
  23755. * Get the current class name useful for serialization or dynamic coding.
  23756. * @returns "DetailMap"
  23757. */
  23758. getClassName(): string;
  23759. /**
  23760. * Add the required uniforms to the current list.
  23761. * @param uniforms defines the current uniform list.
  23762. */
  23763. static AddUniforms(uniforms: string[]): void;
  23764. /**
  23765. * Add the required samplers to the current list.
  23766. * @param samplers defines the current sampler list.
  23767. */
  23768. static AddSamplers(samplers: string[]): void;
  23769. /**
  23770. * Add the required uniforms to the current buffer.
  23771. * @param uniformBuffer defines the current uniform buffer.
  23772. */
  23773. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  23774. /**
  23775. * Makes a duplicate of the current instance into another one.
  23776. * @param detailMap define the instance where to copy the info
  23777. */
  23778. copyTo(detailMap: DetailMapConfiguration): void;
  23779. /**
  23780. * Serializes this detail map instance
  23781. * @returns - An object with the serialized instance.
  23782. */
  23783. serialize(): any;
  23784. /**
  23785. * Parses a detail map setting from a serialized object.
  23786. * @param source - Serialized object.
  23787. * @param scene Defines the scene we are parsing for
  23788. * @param rootUrl Defines the rootUrl to load from
  23789. */
  23790. parse(source: any, scene: Scene, rootUrl: string): void;
  23791. }
  23792. }
  23793. declare module BABYLON {
  23794. /** @hidden */
  23795. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  23796. MAINUV1: boolean;
  23797. MAINUV2: boolean;
  23798. DIFFUSE: boolean;
  23799. DIFFUSEDIRECTUV: number;
  23800. DETAIL: boolean;
  23801. DETAILDIRECTUV: number;
  23802. DETAIL_NORMALBLENDMETHOD: number;
  23803. AMBIENT: boolean;
  23804. AMBIENTDIRECTUV: number;
  23805. OPACITY: boolean;
  23806. OPACITYDIRECTUV: number;
  23807. OPACITYRGB: boolean;
  23808. REFLECTION: boolean;
  23809. EMISSIVE: boolean;
  23810. EMISSIVEDIRECTUV: number;
  23811. SPECULAR: boolean;
  23812. SPECULARDIRECTUV: number;
  23813. BUMP: boolean;
  23814. BUMPDIRECTUV: number;
  23815. PARALLAX: boolean;
  23816. PARALLAXOCCLUSION: boolean;
  23817. SPECULAROVERALPHA: boolean;
  23818. CLIPPLANE: boolean;
  23819. CLIPPLANE2: boolean;
  23820. CLIPPLANE3: boolean;
  23821. CLIPPLANE4: boolean;
  23822. CLIPPLANE5: boolean;
  23823. CLIPPLANE6: boolean;
  23824. ALPHATEST: boolean;
  23825. DEPTHPREPASS: boolean;
  23826. ALPHAFROMDIFFUSE: boolean;
  23827. POINTSIZE: boolean;
  23828. FOG: boolean;
  23829. SPECULARTERM: boolean;
  23830. DIFFUSEFRESNEL: boolean;
  23831. OPACITYFRESNEL: boolean;
  23832. REFLECTIONFRESNEL: boolean;
  23833. REFRACTIONFRESNEL: boolean;
  23834. EMISSIVEFRESNEL: boolean;
  23835. FRESNEL: boolean;
  23836. NORMAL: boolean;
  23837. UV1: boolean;
  23838. UV2: boolean;
  23839. VERTEXCOLOR: boolean;
  23840. VERTEXALPHA: boolean;
  23841. NUM_BONE_INFLUENCERS: number;
  23842. BonesPerMesh: number;
  23843. BONETEXTURE: boolean;
  23844. BONES_VELOCITY_ENABLED: boolean;
  23845. INSTANCES: boolean;
  23846. THIN_INSTANCES: boolean;
  23847. GLOSSINESS: boolean;
  23848. ROUGHNESS: boolean;
  23849. EMISSIVEASILLUMINATION: boolean;
  23850. LINKEMISSIVEWITHDIFFUSE: boolean;
  23851. REFLECTIONFRESNELFROMSPECULAR: boolean;
  23852. LIGHTMAP: boolean;
  23853. LIGHTMAPDIRECTUV: number;
  23854. OBJECTSPACE_NORMALMAP: boolean;
  23855. USELIGHTMAPASSHADOWMAP: boolean;
  23856. REFLECTIONMAP_3D: boolean;
  23857. REFLECTIONMAP_SPHERICAL: boolean;
  23858. REFLECTIONMAP_PLANAR: boolean;
  23859. REFLECTIONMAP_CUBIC: boolean;
  23860. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  23861. REFLECTIONMAP_PROJECTION: boolean;
  23862. REFLECTIONMAP_SKYBOX: boolean;
  23863. REFLECTIONMAP_EXPLICIT: boolean;
  23864. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  23865. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  23866. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  23867. INVERTCUBICMAP: boolean;
  23868. LOGARITHMICDEPTH: boolean;
  23869. REFRACTION: boolean;
  23870. REFRACTIONMAP_3D: boolean;
  23871. REFLECTIONOVERALPHA: boolean;
  23872. TWOSIDEDLIGHTING: boolean;
  23873. SHADOWFLOAT: boolean;
  23874. MORPHTARGETS: boolean;
  23875. MORPHTARGETS_NORMAL: boolean;
  23876. MORPHTARGETS_TANGENT: boolean;
  23877. MORPHTARGETS_UV: boolean;
  23878. NUM_MORPH_INFLUENCERS: number;
  23879. NONUNIFORMSCALING: boolean;
  23880. PREMULTIPLYALPHA: boolean;
  23881. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  23882. ALPHABLEND: boolean;
  23883. PREPASS: boolean;
  23884. PREPASS_IRRADIANCE: boolean;
  23885. PREPASS_IRRADIANCE_INDEX: number;
  23886. PREPASS_ALBEDO: boolean;
  23887. PREPASS_ALBEDO_INDEX: number;
  23888. PREPASS_DEPTHNORMAL: boolean;
  23889. PREPASS_DEPTHNORMAL_INDEX: number;
  23890. PREPASS_POSITION: boolean;
  23891. PREPASS_POSITION_INDEX: number;
  23892. PREPASS_VELOCITY: boolean;
  23893. PREPASS_VELOCITY_INDEX: number;
  23894. PREPASS_REFLECTIVITY: boolean;
  23895. PREPASS_REFLECTIVITY_INDEX: number;
  23896. SCENE_MRT_COUNT: number;
  23897. RGBDLIGHTMAP: boolean;
  23898. RGBDREFLECTION: boolean;
  23899. RGBDREFRACTION: boolean;
  23900. IMAGEPROCESSING: boolean;
  23901. VIGNETTE: boolean;
  23902. VIGNETTEBLENDMODEMULTIPLY: boolean;
  23903. VIGNETTEBLENDMODEOPAQUE: boolean;
  23904. TONEMAPPING: boolean;
  23905. TONEMAPPING_ACES: boolean;
  23906. CONTRAST: boolean;
  23907. COLORCURVES: boolean;
  23908. COLORGRADING: boolean;
  23909. COLORGRADING3D: boolean;
  23910. SAMPLER3DGREENDEPTH: boolean;
  23911. SAMPLER3DBGRMAP: boolean;
  23912. IMAGEPROCESSINGPOSTPROCESS: boolean;
  23913. MULTIVIEW: boolean;
  23914. /**
  23915. * If the reflection texture on this material is in linear color space
  23916. * @hidden
  23917. */
  23918. IS_REFLECTION_LINEAR: boolean;
  23919. /**
  23920. * If the refraction texture on this material is in linear color space
  23921. * @hidden
  23922. */
  23923. IS_REFRACTION_LINEAR: boolean;
  23924. EXPOSURE: boolean;
  23925. constructor();
  23926. setReflectionMode(modeToEnable: string): void;
  23927. }
  23928. /**
  23929. * This is the default material used in Babylon. It is the best trade off between quality
  23930. * and performances.
  23931. * @see https://doc.babylonjs.com/babylon101/materials
  23932. */
  23933. export class StandardMaterial extends PushMaterial {
  23934. private _diffuseTexture;
  23935. /**
  23936. * The basic texture of the material as viewed under a light.
  23937. */
  23938. diffuseTexture: Nullable<BaseTexture>;
  23939. private _ambientTexture;
  23940. /**
  23941. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  23942. */
  23943. ambientTexture: Nullable<BaseTexture>;
  23944. private _opacityTexture;
  23945. /**
  23946. * Define the transparency of the material from a texture.
  23947. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  23948. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  23949. */
  23950. opacityTexture: Nullable<BaseTexture>;
  23951. private _reflectionTexture;
  23952. /**
  23953. * Define the texture used to display the reflection.
  23954. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  23955. */
  23956. reflectionTexture: Nullable<BaseTexture>;
  23957. private _emissiveTexture;
  23958. /**
  23959. * Define texture of the material as if self lit.
  23960. * This will be mixed in the final result even in the absence of light.
  23961. */
  23962. emissiveTexture: Nullable<BaseTexture>;
  23963. private _specularTexture;
  23964. /**
  23965. * Define how the color and intensity of the highlight given by the light in the material.
  23966. */
  23967. specularTexture: Nullable<BaseTexture>;
  23968. private _bumpTexture;
  23969. /**
  23970. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  23971. * 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.
  23972. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  23973. */
  23974. bumpTexture: Nullable<BaseTexture>;
  23975. private _lightmapTexture;
  23976. /**
  23977. * Complex lighting can be computationally expensive to compute at runtime.
  23978. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  23979. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  23980. */
  23981. lightmapTexture: Nullable<BaseTexture>;
  23982. private _refractionTexture;
  23983. /**
  23984. * Define the texture used to display the refraction.
  23985. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  23986. */
  23987. refractionTexture: Nullable<BaseTexture>;
  23988. /**
  23989. * The color of the material lit by the environmental background lighting.
  23990. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  23991. */
  23992. ambientColor: Color3;
  23993. /**
  23994. * The basic color of the material as viewed under a light.
  23995. */
  23996. diffuseColor: Color3;
  23997. /**
  23998. * Define how the color and intensity of the highlight given by the light in the material.
  23999. */
  24000. specularColor: Color3;
  24001. /**
  24002. * Define the color of the material as if self lit.
  24003. * This will be mixed in the final result even in the absence of light.
  24004. */
  24005. emissiveColor: Color3;
  24006. /**
  24007. * Defines how sharp are the highlights in the material.
  24008. * The bigger the value the sharper giving a more glossy feeling to the result.
  24009. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  24010. */
  24011. specularPower: number;
  24012. private _useAlphaFromDiffuseTexture;
  24013. /**
  24014. * Does the transparency come from the diffuse texture alpha channel.
  24015. */
  24016. useAlphaFromDiffuseTexture: boolean;
  24017. private _useEmissiveAsIllumination;
  24018. /**
  24019. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  24020. */
  24021. useEmissiveAsIllumination: boolean;
  24022. private _linkEmissiveWithDiffuse;
  24023. /**
  24024. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  24025. * the emissive level when the final color is close to one.
  24026. */
  24027. linkEmissiveWithDiffuse: boolean;
  24028. private _useSpecularOverAlpha;
  24029. /**
  24030. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  24031. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  24032. */
  24033. useSpecularOverAlpha: boolean;
  24034. private _useReflectionOverAlpha;
  24035. /**
  24036. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  24037. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  24038. */
  24039. useReflectionOverAlpha: boolean;
  24040. private _disableLighting;
  24041. /**
  24042. * Does lights from the scene impacts this material.
  24043. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  24044. */
  24045. disableLighting: boolean;
  24046. private _useObjectSpaceNormalMap;
  24047. /**
  24048. * Allows using an object space normal map (instead of tangent space).
  24049. */
  24050. useObjectSpaceNormalMap: boolean;
  24051. private _useParallax;
  24052. /**
  24053. * Is parallax enabled or not.
  24054. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  24055. */
  24056. useParallax: boolean;
  24057. private _useParallaxOcclusion;
  24058. /**
  24059. * Is parallax occlusion enabled or not.
  24060. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  24061. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  24062. */
  24063. useParallaxOcclusion: boolean;
  24064. /**
  24065. * 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.
  24066. */
  24067. parallaxScaleBias: number;
  24068. private _roughness;
  24069. /**
  24070. * Helps to define how blurry the reflections should appears in the material.
  24071. */
  24072. roughness: number;
  24073. /**
  24074. * In case of refraction, define the value of the index of refraction.
  24075. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  24076. */
  24077. indexOfRefraction: number;
  24078. /**
  24079. * Invert the refraction texture alongside the y axis.
  24080. * It can be useful with procedural textures or probe for instance.
  24081. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  24082. */
  24083. invertRefractionY: boolean;
  24084. /**
  24085. * Defines the alpha limits in alpha test mode.
  24086. */
  24087. alphaCutOff: number;
  24088. private _useLightmapAsShadowmap;
  24089. /**
  24090. * In case of light mapping, define whether the map contains light or shadow informations.
  24091. */
  24092. useLightmapAsShadowmap: boolean;
  24093. private _diffuseFresnelParameters;
  24094. /**
  24095. * Define the diffuse fresnel parameters of the material.
  24096. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  24097. */
  24098. diffuseFresnelParameters: FresnelParameters;
  24099. private _opacityFresnelParameters;
  24100. /**
  24101. * Define the opacity fresnel parameters of the material.
  24102. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  24103. */
  24104. opacityFresnelParameters: FresnelParameters;
  24105. private _reflectionFresnelParameters;
  24106. /**
  24107. * Define the reflection fresnel parameters of the material.
  24108. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  24109. */
  24110. reflectionFresnelParameters: FresnelParameters;
  24111. private _refractionFresnelParameters;
  24112. /**
  24113. * Define the refraction fresnel parameters of the material.
  24114. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  24115. */
  24116. refractionFresnelParameters: FresnelParameters;
  24117. private _emissiveFresnelParameters;
  24118. /**
  24119. * Define the emissive fresnel parameters of the material.
  24120. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  24121. */
  24122. emissiveFresnelParameters: FresnelParameters;
  24123. private _useReflectionFresnelFromSpecular;
  24124. /**
  24125. * If true automatically deducts the fresnels values from the material specularity.
  24126. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  24127. */
  24128. useReflectionFresnelFromSpecular: boolean;
  24129. private _useGlossinessFromSpecularMapAlpha;
  24130. /**
  24131. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  24132. */
  24133. useGlossinessFromSpecularMapAlpha: boolean;
  24134. private _maxSimultaneousLights;
  24135. /**
  24136. * Defines the maximum number of lights that can be used in the material
  24137. */
  24138. maxSimultaneousLights: number;
  24139. private _invertNormalMapX;
  24140. /**
  24141. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  24142. */
  24143. invertNormalMapX: boolean;
  24144. private _invertNormalMapY;
  24145. /**
  24146. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  24147. */
  24148. invertNormalMapY: boolean;
  24149. private _twoSidedLighting;
  24150. /**
  24151. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  24152. */
  24153. twoSidedLighting: boolean;
  24154. /**
  24155. * Default configuration related to image processing available in the standard Material.
  24156. */
  24157. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  24158. /**
  24159. * Gets the image processing configuration used either in this material.
  24160. */
  24161. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  24162. /**
  24163. * Sets the Default image processing configuration used either in the this material.
  24164. *
  24165. * If sets to null, the scene one is in use.
  24166. */
  24167. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  24168. /**
  24169. * Keep track of the image processing observer to allow dispose and replace.
  24170. */
  24171. private _imageProcessingObserver;
  24172. /**
  24173. * Attaches a new image processing configuration to the Standard Material.
  24174. * @param configuration
  24175. */
  24176. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  24177. /**
  24178. * Defines additionnal PrePass parameters for the material.
  24179. */
  24180. readonly prePassConfiguration: PrePassConfiguration;
  24181. /**
  24182. * Gets wether the color curves effect is enabled.
  24183. */
  24184. get cameraColorCurvesEnabled(): boolean;
  24185. /**
  24186. * Sets wether the color curves effect is enabled.
  24187. */
  24188. set cameraColorCurvesEnabled(value: boolean);
  24189. /**
  24190. * Gets wether the color grading effect is enabled.
  24191. */
  24192. get cameraColorGradingEnabled(): boolean;
  24193. /**
  24194. * Gets wether the color grading effect is enabled.
  24195. */
  24196. set cameraColorGradingEnabled(value: boolean);
  24197. /**
  24198. * Gets wether tonemapping is enabled or not.
  24199. */
  24200. get cameraToneMappingEnabled(): boolean;
  24201. /**
  24202. * Sets wether tonemapping is enabled or not
  24203. */
  24204. set cameraToneMappingEnabled(value: boolean);
  24205. /**
  24206. * The camera exposure used on this material.
  24207. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  24208. * This corresponds to a photographic exposure.
  24209. */
  24210. get cameraExposure(): number;
  24211. /**
  24212. * The camera exposure used on this material.
  24213. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  24214. * This corresponds to a photographic exposure.
  24215. */
  24216. set cameraExposure(value: number);
  24217. /**
  24218. * Gets The camera contrast used on this material.
  24219. */
  24220. get cameraContrast(): number;
  24221. /**
  24222. * Sets The camera contrast used on this material.
  24223. */
  24224. set cameraContrast(value: number);
  24225. /**
  24226. * Gets the Color Grading 2D Lookup Texture.
  24227. */
  24228. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  24229. /**
  24230. * Sets the Color Grading 2D Lookup Texture.
  24231. */
  24232. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  24233. /**
  24234. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  24235. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  24236. * 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;
  24237. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  24238. */
  24239. get cameraColorCurves(): Nullable<ColorCurves>;
  24240. /**
  24241. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  24242. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  24243. * 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;
  24244. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  24245. */
  24246. set cameraColorCurves(value: Nullable<ColorCurves>);
  24247. /**
  24248. * Can this material render to several textures at once
  24249. */
  24250. get canRenderToMRT(): boolean;
  24251. /**
  24252. * Defines the detail map parameters for the material.
  24253. */
  24254. readonly detailMap: DetailMapConfiguration;
  24255. protected _renderTargets: SmartArray<RenderTargetTexture>;
  24256. protected _worldViewProjectionMatrix: Matrix;
  24257. protected _globalAmbientColor: Color3;
  24258. protected _useLogarithmicDepth: boolean;
  24259. protected _rebuildInParallel: boolean;
  24260. /**
  24261. * Instantiates a new standard material.
  24262. * This is the default material used in Babylon. It is the best trade off between quality
  24263. * and performances.
  24264. * @see https://doc.babylonjs.com/babylon101/materials
  24265. * @param name Define the name of the material in the scene
  24266. * @param scene Define the scene the material belong to
  24267. */
  24268. constructor(name: string, scene: Scene);
  24269. /**
  24270. * Gets a boolean indicating that current material needs to register RTT
  24271. */
  24272. get hasRenderTargetTextures(): boolean;
  24273. /**
  24274. * Gets the current class name of the material e.g. "StandardMaterial"
  24275. * Mainly use in serialization.
  24276. * @returns the class name
  24277. */
  24278. getClassName(): string;
  24279. /**
  24280. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  24281. * You can try switching to logarithmic depth.
  24282. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  24283. */
  24284. get useLogarithmicDepth(): boolean;
  24285. set useLogarithmicDepth(value: boolean);
  24286. /**
  24287. * Specifies if the material will require alpha blending
  24288. * @returns a boolean specifying if alpha blending is needed
  24289. */
  24290. needAlphaBlending(): boolean;
  24291. /**
  24292. * Specifies if this material should be rendered in alpha test mode
  24293. * @returns a boolean specifying if an alpha test is needed.
  24294. */
  24295. needAlphaTesting(): boolean;
  24296. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  24297. /**
  24298. * Get the texture used for alpha test purpose.
  24299. * @returns the diffuse texture in case of the standard material.
  24300. */
  24301. getAlphaTestTexture(): Nullable<BaseTexture>;
  24302. /**
  24303. * Get if the submesh is ready to be used and all its information available.
  24304. * Child classes can use it to update shaders
  24305. * @param mesh defines the mesh to check
  24306. * @param subMesh defines which submesh to check
  24307. * @param useInstances specifies that instances should be used
  24308. * @returns a boolean indicating that the submesh is ready or not
  24309. */
  24310. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  24311. /**
  24312. * Builds the material UBO layouts.
  24313. * Used internally during the effect preparation.
  24314. */
  24315. buildUniformLayout(): void;
  24316. /**
  24317. * Unbinds the material from the mesh
  24318. */
  24319. unbind(): void;
  24320. /**
  24321. * Binds the submesh to this material by preparing the effect and shader to draw
  24322. * @param world defines the world transformation matrix
  24323. * @param mesh defines the mesh containing the submesh
  24324. * @param subMesh defines the submesh to bind the material to
  24325. */
  24326. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  24327. /**
  24328. * Get the list of animatables in the material.
  24329. * @returns the list of animatables object used in the material
  24330. */
  24331. getAnimatables(): IAnimatable[];
  24332. /**
  24333. * Gets the active textures from the material
  24334. * @returns an array of textures
  24335. */
  24336. getActiveTextures(): BaseTexture[];
  24337. /**
  24338. * Specifies if the material uses a texture
  24339. * @param texture defines the texture to check against the material
  24340. * @returns a boolean specifying if the material uses the texture
  24341. */
  24342. hasTexture(texture: BaseTexture): boolean;
  24343. /**
  24344. * Disposes the material
  24345. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  24346. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  24347. */
  24348. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  24349. /**
  24350. * Makes a duplicate of the material, and gives it a new name
  24351. * @param name defines the new name for the duplicated material
  24352. * @returns the cloned material
  24353. */
  24354. clone(name: string): StandardMaterial;
  24355. /**
  24356. * Serializes this material in a JSON representation
  24357. * @returns the serialized material object
  24358. */
  24359. serialize(): any;
  24360. /**
  24361. * Creates a standard material from parsed material data
  24362. * @param source defines the JSON representation of the material
  24363. * @param scene defines the hosting scene
  24364. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  24365. * @returns a new standard material
  24366. */
  24367. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  24368. /**
  24369. * Are diffuse textures enabled in the application.
  24370. */
  24371. static get DiffuseTextureEnabled(): boolean;
  24372. static set DiffuseTextureEnabled(value: boolean);
  24373. /**
  24374. * Are detail textures enabled in the application.
  24375. */
  24376. static get DetailTextureEnabled(): boolean;
  24377. static set DetailTextureEnabled(value: boolean);
  24378. /**
  24379. * Are ambient textures enabled in the application.
  24380. */
  24381. static get AmbientTextureEnabled(): boolean;
  24382. static set AmbientTextureEnabled(value: boolean);
  24383. /**
  24384. * Are opacity textures enabled in the application.
  24385. */
  24386. static get OpacityTextureEnabled(): boolean;
  24387. static set OpacityTextureEnabled(value: boolean);
  24388. /**
  24389. * Are reflection textures enabled in the application.
  24390. */
  24391. static get ReflectionTextureEnabled(): boolean;
  24392. static set ReflectionTextureEnabled(value: boolean);
  24393. /**
  24394. * Are emissive textures enabled in the application.
  24395. */
  24396. static get EmissiveTextureEnabled(): boolean;
  24397. static set EmissiveTextureEnabled(value: boolean);
  24398. /**
  24399. * Are specular textures enabled in the application.
  24400. */
  24401. static get SpecularTextureEnabled(): boolean;
  24402. static set SpecularTextureEnabled(value: boolean);
  24403. /**
  24404. * Are bump textures enabled in the application.
  24405. */
  24406. static get BumpTextureEnabled(): boolean;
  24407. static set BumpTextureEnabled(value: boolean);
  24408. /**
  24409. * Are lightmap textures enabled in the application.
  24410. */
  24411. static get LightmapTextureEnabled(): boolean;
  24412. static set LightmapTextureEnabled(value: boolean);
  24413. /**
  24414. * Are refraction textures enabled in the application.
  24415. */
  24416. static get RefractionTextureEnabled(): boolean;
  24417. static set RefractionTextureEnabled(value: boolean);
  24418. /**
  24419. * Are color grading textures enabled in the application.
  24420. */
  24421. static get ColorGradingTextureEnabled(): boolean;
  24422. static set ColorGradingTextureEnabled(value: boolean);
  24423. /**
  24424. * Are fresnels enabled in the application.
  24425. */
  24426. static get FresnelEnabled(): boolean;
  24427. static set FresnelEnabled(value: boolean);
  24428. }
  24429. }
  24430. declare module BABYLON {
  24431. /** @hidden */
  24432. export var rgbdDecodePixelShader: {
  24433. name: string;
  24434. shader: string;
  24435. };
  24436. }
  24437. declare module BABYLON {
  24438. /**
  24439. * Class used to host RGBD texture specific utilities
  24440. */
  24441. export class RGBDTextureTools {
  24442. /**
  24443. * Expand the RGBD Texture from RGBD to Half Float if possible.
  24444. * @param texture the texture to expand.
  24445. */
  24446. static ExpandRGBDTexture(texture: Texture): void;
  24447. }
  24448. }
  24449. declare module BABYLON {
  24450. /**
  24451. * Class used to host texture specific utilities
  24452. */
  24453. export class BRDFTextureTools {
  24454. /**
  24455. * Prevents texture cache collision
  24456. */
  24457. private static _instanceNumber;
  24458. /**
  24459. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  24460. * @param scene defines the hosting scene
  24461. * @returns the environment BRDF texture
  24462. */
  24463. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  24464. private static _environmentBRDFBase64Texture;
  24465. }
  24466. }
  24467. declare module BABYLON {
  24468. /**
  24469. * @hidden
  24470. */
  24471. export interface IMaterialClearCoatDefines {
  24472. CLEARCOAT: boolean;
  24473. CLEARCOAT_DEFAULTIOR: boolean;
  24474. CLEARCOAT_TEXTURE: boolean;
  24475. CLEARCOAT_TEXTUREDIRECTUV: number;
  24476. CLEARCOAT_BUMP: boolean;
  24477. CLEARCOAT_BUMPDIRECTUV: number;
  24478. CLEARCOAT_REMAP_F0: boolean;
  24479. CLEARCOAT_TINT: boolean;
  24480. CLEARCOAT_TINT_TEXTURE: boolean;
  24481. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  24482. /** @hidden */
  24483. _areTexturesDirty: boolean;
  24484. }
  24485. /**
  24486. * Define the code related to the clear coat parameters of the pbr material.
  24487. */
  24488. export class PBRClearCoatConfiguration {
  24489. /**
  24490. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  24491. * The default fits with a polyurethane material.
  24492. */
  24493. private static readonly _DefaultIndexOfRefraction;
  24494. private _isEnabled;
  24495. /**
  24496. * Defines if the clear coat is enabled in the material.
  24497. */
  24498. isEnabled: boolean;
  24499. /**
  24500. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  24501. */
  24502. intensity: number;
  24503. /**
  24504. * Defines the clear coat layer roughness.
  24505. */
  24506. roughness: number;
  24507. private _indexOfRefraction;
  24508. /**
  24509. * Defines the index of refraction of the clear coat.
  24510. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  24511. * The default fits with a polyurethane material.
  24512. * Changing the default value is more performance intensive.
  24513. */
  24514. indexOfRefraction: number;
  24515. private _texture;
  24516. /**
  24517. * Stores the clear coat values in a texture.
  24518. */
  24519. texture: Nullable<BaseTexture>;
  24520. private _remapF0OnInterfaceChange;
  24521. /**
  24522. * Defines if the F0 value should be remapped to account for the interface change in the material.
  24523. */
  24524. remapF0OnInterfaceChange: boolean;
  24525. private _bumpTexture;
  24526. /**
  24527. * Define the clear coat specific bump texture.
  24528. */
  24529. bumpTexture: Nullable<BaseTexture>;
  24530. private _isTintEnabled;
  24531. /**
  24532. * Defines if the clear coat tint is enabled in the material.
  24533. */
  24534. isTintEnabled: boolean;
  24535. /**
  24536. * Defines the clear coat tint of the material.
  24537. * This is only use if tint is enabled
  24538. */
  24539. tintColor: Color3;
  24540. /**
  24541. * Defines the distance at which the tint color should be found in the
  24542. * clear coat media.
  24543. * This is only use if tint is enabled
  24544. */
  24545. tintColorAtDistance: number;
  24546. /**
  24547. * Defines the clear coat layer thickness.
  24548. * This is only use if tint is enabled
  24549. */
  24550. tintThickness: number;
  24551. private _tintTexture;
  24552. /**
  24553. * Stores the clear tint values in a texture.
  24554. * rgb is tint
  24555. * a is a thickness factor
  24556. */
  24557. tintTexture: Nullable<BaseTexture>;
  24558. /** @hidden */
  24559. private _internalMarkAllSubMeshesAsTexturesDirty;
  24560. /** @hidden */
  24561. _markAllSubMeshesAsTexturesDirty(): void;
  24562. /**
  24563. * Instantiate a new istance of clear coat configuration.
  24564. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  24565. */
  24566. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  24567. /**
  24568. * Gets wehter the submesh is ready to be used or not.
  24569. * @param defines the list of "defines" to update.
  24570. * @param scene defines the scene the material belongs to.
  24571. * @param engine defines the engine the material belongs to.
  24572. * @param disableBumpMap defines wether the material disables bump or not.
  24573. * @returns - boolean indicating that the submesh is ready or not.
  24574. */
  24575. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  24576. /**
  24577. * Checks to see if a texture is used in the material.
  24578. * @param defines the list of "defines" to update.
  24579. * @param scene defines the scene to the material belongs to.
  24580. */
  24581. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  24582. /**
  24583. * Binds the material data.
  24584. * @param uniformBuffer defines the Uniform buffer to fill in.
  24585. * @param scene defines the scene the material belongs to.
  24586. * @param engine defines the engine the material belongs to.
  24587. * @param disableBumpMap defines wether the material disables bump or not.
  24588. * @param isFrozen defines wether the material is frozen or not.
  24589. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  24590. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  24591. */
  24592. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  24593. /**
  24594. * Checks to see if a texture is used in the material.
  24595. * @param texture - Base texture to use.
  24596. * @returns - Boolean specifying if a texture is used in the material.
  24597. */
  24598. hasTexture(texture: BaseTexture): boolean;
  24599. /**
  24600. * Returns an array of the actively used textures.
  24601. * @param activeTextures Array of BaseTextures
  24602. */
  24603. getActiveTextures(activeTextures: BaseTexture[]): void;
  24604. /**
  24605. * Returns the animatable textures.
  24606. * @param animatables Array of animatable textures.
  24607. */
  24608. getAnimatables(animatables: IAnimatable[]): void;
  24609. /**
  24610. * Disposes the resources of the material.
  24611. * @param forceDisposeTextures - Forces the disposal of all textures.
  24612. */
  24613. dispose(forceDisposeTextures?: boolean): void;
  24614. /**
  24615. * Get the current class name of the texture useful for serialization or dynamic coding.
  24616. * @returns "PBRClearCoatConfiguration"
  24617. */
  24618. getClassName(): string;
  24619. /**
  24620. * Add fallbacks to the effect fallbacks list.
  24621. * @param defines defines the Base texture to use.
  24622. * @param fallbacks defines the current fallback list.
  24623. * @param currentRank defines the current fallback rank.
  24624. * @returns the new fallback rank.
  24625. */
  24626. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  24627. /**
  24628. * Add the required uniforms to the current list.
  24629. * @param uniforms defines the current uniform list.
  24630. */
  24631. static AddUniforms(uniforms: string[]): void;
  24632. /**
  24633. * Add the required samplers to the current list.
  24634. * @param samplers defines the current sampler list.
  24635. */
  24636. static AddSamplers(samplers: string[]): void;
  24637. /**
  24638. * Add the required uniforms to the current buffer.
  24639. * @param uniformBuffer defines the current uniform buffer.
  24640. */
  24641. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  24642. /**
  24643. * Makes a duplicate of the current configuration into another one.
  24644. * @param clearCoatConfiguration define the config where to copy the info
  24645. */
  24646. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  24647. /**
  24648. * Serializes this clear coat configuration.
  24649. * @returns - An object with the serialized config.
  24650. */
  24651. serialize(): any;
  24652. /**
  24653. * Parses a anisotropy Configuration from a serialized object.
  24654. * @param source - Serialized object.
  24655. * @param scene Defines the scene we are parsing for
  24656. * @param rootUrl Defines the rootUrl to load from
  24657. */
  24658. parse(source: any, scene: Scene, rootUrl: string): void;
  24659. }
  24660. }
  24661. declare module BABYLON {
  24662. /**
  24663. * @hidden
  24664. */
  24665. export interface IMaterialAnisotropicDefines {
  24666. ANISOTROPIC: boolean;
  24667. ANISOTROPIC_TEXTURE: boolean;
  24668. ANISOTROPIC_TEXTUREDIRECTUV: number;
  24669. MAINUV1: boolean;
  24670. _areTexturesDirty: boolean;
  24671. _needUVs: boolean;
  24672. }
  24673. /**
  24674. * Define the code related to the anisotropic parameters of the pbr material.
  24675. */
  24676. export class PBRAnisotropicConfiguration {
  24677. private _isEnabled;
  24678. /**
  24679. * Defines if the anisotropy is enabled in the material.
  24680. */
  24681. isEnabled: boolean;
  24682. /**
  24683. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  24684. */
  24685. intensity: number;
  24686. /**
  24687. * Defines if the effect is along the tangents, bitangents or in between.
  24688. * By default, the effect is "strectching" the highlights along the tangents.
  24689. */
  24690. direction: Vector2;
  24691. private _texture;
  24692. /**
  24693. * Stores the anisotropy values in a texture.
  24694. * rg is direction (like normal from -1 to 1)
  24695. * b is a intensity
  24696. */
  24697. texture: Nullable<BaseTexture>;
  24698. /** @hidden */
  24699. private _internalMarkAllSubMeshesAsTexturesDirty;
  24700. /** @hidden */
  24701. _markAllSubMeshesAsTexturesDirty(): void;
  24702. /**
  24703. * Instantiate a new istance of anisotropy configuration.
  24704. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  24705. */
  24706. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  24707. /**
  24708. * Specifies that the submesh is ready to be used.
  24709. * @param defines the list of "defines" to update.
  24710. * @param scene defines the scene the material belongs to.
  24711. * @returns - boolean indicating that the submesh is ready or not.
  24712. */
  24713. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  24714. /**
  24715. * Checks to see if a texture is used in the material.
  24716. * @param defines the list of "defines" to update.
  24717. * @param mesh the mesh we are preparing the defines for.
  24718. * @param scene defines the scene the material belongs to.
  24719. */
  24720. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  24721. /**
  24722. * Binds the material data.
  24723. * @param uniformBuffer defines the Uniform buffer to fill in.
  24724. * @param scene defines the scene the material belongs to.
  24725. * @param isFrozen defines wether the material is frozen or not.
  24726. */
  24727. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  24728. /**
  24729. * Checks to see if a texture is used in the material.
  24730. * @param texture - Base texture to use.
  24731. * @returns - Boolean specifying if a texture is used in the material.
  24732. */
  24733. hasTexture(texture: BaseTexture): boolean;
  24734. /**
  24735. * Returns an array of the actively used textures.
  24736. * @param activeTextures Array of BaseTextures
  24737. */
  24738. getActiveTextures(activeTextures: BaseTexture[]): void;
  24739. /**
  24740. * Returns the animatable textures.
  24741. * @param animatables Array of animatable textures.
  24742. */
  24743. getAnimatables(animatables: IAnimatable[]): void;
  24744. /**
  24745. * Disposes the resources of the material.
  24746. * @param forceDisposeTextures - Forces the disposal of all textures.
  24747. */
  24748. dispose(forceDisposeTextures?: boolean): void;
  24749. /**
  24750. * Get the current class name of the texture useful for serialization or dynamic coding.
  24751. * @returns "PBRAnisotropicConfiguration"
  24752. */
  24753. getClassName(): string;
  24754. /**
  24755. * Add fallbacks to the effect fallbacks list.
  24756. * @param defines defines the Base texture to use.
  24757. * @param fallbacks defines the current fallback list.
  24758. * @param currentRank defines the current fallback rank.
  24759. * @returns the new fallback rank.
  24760. */
  24761. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  24762. /**
  24763. * Add the required uniforms to the current list.
  24764. * @param uniforms defines the current uniform list.
  24765. */
  24766. static AddUniforms(uniforms: string[]): void;
  24767. /**
  24768. * Add the required uniforms to the current buffer.
  24769. * @param uniformBuffer defines the current uniform buffer.
  24770. */
  24771. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  24772. /**
  24773. * Add the required samplers to the current list.
  24774. * @param samplers defines the current sampler list.
  24775. */
  24776. static AddSamplers(samplers: string[]): void;
  24777. /**
  24778. * Makes a duplicate of the current configuration into another one.
  24779. * @param anisotropicConfiguration define the config where to copy the info
  24780. */
  24781. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  24782. /**
  24783. * Serializes this anisotropy configuration.
  24784. * @returns - An object with the serialized config.
  24785. */
  24786. serialize(): any;
  24787. /**
  24788. * Parses a anisotropy Configuration from a serialized object.
  24789. * @param source - Serialized object.
  24790. * @param scene Defines the scene we are parsing for
  24791. * @param rootUrl Defines the rootUrl to load from
  24792. */
  24793. parse(source: any, scene: Scene, rootUrl: string): void;
  24794. }
  24795. }
  24796. declare module BABYLON {
  24797. /**
  24798. * @hidden
  24799. */
  24800. export interface IMaterialBRDFDefines {
  24801. BRDF_V_HEIGHT_CORRELATED: boolean;
  24802. MS_BRDF_ENERGY_CONSERVATION: boolean;
  24803. SPHERICAL_HARMONICS: boolean;
  24804. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  24805. /** @hidden */
  24806. _areMiscDirty: boolean;
  24807. }
  24808. /**
  24809. * Define the code related to the BRDF parameters of the pbr material.
  24810. */
  24811. export class PBRBRDFConfiguration {
  24812. /**
  24813. * Default value used for the energy conservation.
  24814. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  24815. */
  24816. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  24817. /**
  24818. * Default value used for the Smith Visibility Height Correlated mode.
  24819. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  24820. */
  24821. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  24822. /**
  24823. * Default value used for the IBL diffuse part.
  24824. * This can help switching back to the polynomials mode globally which is a tiny bit
  24825. * less GPU intensive at the drawback of a lower quality.
  24826. */
  24827. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  24828. /**
  24829. * Default value used for activating energy conservation for the specular workflow.
  24830. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  24831. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  24832. */
  24833. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  24834. private _useEnergyConservation;
  24835. /**
  24836. * Defines if the material uses energy conservation.
  24837. */
  24838. useEnergyConservation: boolean;
  24839. private _useSmithVisibilityHeightCorrelated;
  24840. /**
  24841. * LEGACY Mode set to false
  24842. * Defines if the material uses height smith correlated visibility term.
  24843. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  24844. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  24845. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  24846. * Not relying on height correlated will also disable energy conservation.
  24847. */
  24848. useSmithVisibilityHeightCorrelated: boolean;
  24849. private _useSphericalHarmonics;
  24850. /**
  24851. * LEGACY Mode set to false
  24852. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  24853. * diffuse part of the IBL.
  24854. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  24855. * to the ground truth.
  24856. */
  24857. useSphericalHarmonics: boolean;
  24858. private _useSpecularGlossinessInputEnergyConservation;
  24859. /**
  24860. * Defines if the material uses energy conservation, when the specular workflow is active.
  24861. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  24862. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  24863. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  24864. */
  24865. useSpecularGlossinessInputEnergyConservation: boolean;
  24866. /** @hidden */
  24867. private _internalMarkAllSubMeshesAsMiscDirty;
  24868. /** @hidden */
  24869. _markAllSubMeshesAsMiscDirty(): void;
  24870. /**
  24871. * Instantiate a new istance of clear coat configuration.
  24872. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  24873. */
  24874. constructor(markAllSubMeshesAsMiscDirty: () => void);
  24875. /**
  24876. * Checks to see if a texture is used in the material.
  24877. * @param defines the list of "defines" to update.
  24878. */
  24879. prepareDefines(defines: IMaterialBRDFDefines): void;
  24880. /**
  24881. * Get the current class name of the texture useful for serialization or dynamic coding.
  24882. * @returns "PBRClearCoatConfiguration"
  24883. */
  24884. getClassName(): string;
  24885. /**
  24886. * Makes a duplicate of the current configuration into another one.
  24887. * @param brdfConfiguration define the config where to copy the info
  24888. */
  24889. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  24890. /**
  24891. * Serializes this BRDF configuration.
  24892. * @returns - An object with the serialized config.
  24893. */
  24894. serialize(): any;
  24895. /**
  24896. * Parses a anisotropy Configuration from a serialized object.
  24897. * @param source - Serialized object.
  24898. * @param scene Defines the scene we are parsing for
  24899. * @param rootUrl Defines the rootUrl to load from
  24900. */
  24901. parse(source: any, scene: Scene, rootUrl: string): void;
  24902. }
  24903. }
  24904. declare module BABYLON {
  24905. /**
  24906. * @hidden
  24907. */
  24908. export interface IMaterialSheenDefines {
  24909. SHEEN: boolean;
  24910. SHEEN_TEXTURE: boolean;
  24911. SHEEN_TEXTUREDIRECTUV: number;
  24912. SHEEN_LINKWITHALBEDO: boolean;
  24913. SHEEN_ROUGHNESS: boolean;
  24914. SHEEN_ALBEDOSCALING: boolean;
  24915. /** @hidden */
  24916. _areTexturesDirty: boolean;
  24917. }
  24918. /**
  24919. * Define the code related to the Sheen parameters of the pbr material.
  24920. */
  24921. export class PBRSheenConfiguration {
  24922. private _isEnabled;
  24923. /**
  24924. * Defines if the material uses sheen.
  24925. */
  24926. isEnabled: boolean;
  24927. private _linkSheenWithAlbedo;
  24928. /**
  24929. * Defines if the sheen is linked to the sheen color.
  24930. */
  24931. linkSheenWithAlbedo: boolean;
  24932. /**
  24933. * Defines the sheen intensity.
  24934. */
  24935. intensity: number;
  24936. /**
  24937. * Defines the sheen color.
  24938. */
  24939. color: Color3;
  24940. private _texture;
  24941. /**
  24942. * Stores the sheen tint values in a texture.
  24943. * rgb is tint
  24944. * a is a intensity or roughness if roughness has been defined
  24945. */
  24946. texture: Nullable<BaseTexture>;
  24947. private _roughness;
  24948. /**
  24949. * Defines the sheen roughness.
  24950. * It is not taken into account if linkSheenWithAlbedo is true.
  24951. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  24952. */
  24953. roughness: Nullable<number>;
  24954. private _albedoScaling;
  24955. /**
  24956. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  24957. * It allows the strength of the sheen effect to not depend on the base color of the material,
  24958. * making it easier to setup and tweak the effect
  24959. */
  24960. albedoScaling: boolean;
  24961. /** @hidden */
  24962. private _internalMarkAllSubMeshesAsTexturesDirty;
  24963. /** @hidden */
  24964. _markAllSubMeshesAsTexturesDirty(): void;
  24965. /**
  24966. * Instantiate a new istance of clear coat configuration.
  24967. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  24968. */
  24969. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  24970. /**
  24971. * Specifies that the submesh is ready to be used.
  24972. * @param defines the list of "defines" to update.
  24973. * @param scene defines the scene the material belongs to.
  24974. * @returns - boolean indicating that the submesh is ready or not.
  24975. */
  24976. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  24977. /**
  24978. * Checks to see if a texture is used in the material.
  24979. * @param defines the list of "defines" to update.
  24980. * @param scene defines the scene the material belongs to.
  24981. */
  24982. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  24983. /**
  24984. * Binds the material data.
  24985. * @param uniformBuffer defines the Uniform buffer to fill in.
  24986. * @param scene defines the scene the material belongs to.
  24987. * @param isFrozen defines wether the material is frozen or not.
  24988. */
  24989. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  24990. /**
  24991. * Checks to see if a texture is used in the material.
  24992. * @param texture - Base texture to use.
  24993. * @returns - Boolean specifying if a texture is used in the material.
  24994. */
  24995. hasTexture(texture: BaseTexture): boolean;
  24996. /**
  24997. * Returns an array of the actively used textures.
  24998. * @param activeTextures Array of BaseTextures
  24999. */
  25000. getActiveTextures(activeTextures: BaseTexture[]): void;
  25001. /**
  25002. * Returns the animatable textures.
  25003. * @param animatables Array of animatable textures.
  25004. */
  25005. getAnimatables(animatables: IAnimatable[]): void;
  25006. /**
  25007. * Disposes the resources of the material.
  25008. * @param forceDisposeTextures - Forces the disposal of all textures.
  25009. */
  25010. dispose(forceDisposeTextures?: boolean): void;
  25011. /**
  25012. * Get the current class name of the texture useful for serialization or dynamic coding.
  25013. * @returns "PBRSheenConfiguration"
  25014. */
  25015. getClassName(): string;
  25016. /**
  25017. * Add fallbacks to the effect fallbacks list.
  25018. * @param defines defines the Base texture to use.
  25019. * @param fallbacks defines the current fallback list.
  25020. * @param currentRank defines the current fallback rank.
  25021. * @returns the new fallback rank.
  25022. */
  25023. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  25024. /**
  25025. * Add the required uniforms to the current list.
  25026. * @param uniforms defines the current uniform list.
  25027. */
  25028. static AddUniforms(uniforms: string[]): void;
  25029. /**
  25030. * Add the required uniforms to the current buffer.
  25031. * @param uniformBuffer defines the current uniform buffer.
  25032. */
  25033. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  25034. /**
  25035. * Add the required samplers to the current list.
  25036. * @param samplers defines the current sampler list.
  25037. */
  25038. static AddSamplers(samplers: string[]): void;
  25039. /**
  25040. * Makes a duplicate of the current configuration into another one.
  25041. * @param sheenConfiguration define the config where to copy the info
  25042. */
  25043. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  25044. /**
  25045. * Serializes this BRDF configuration.
  25046. * @returns - An object with the serialized config.
  25047. */
  25048. serialize(): any;
  25049. /**
  25050. * Parses a anisotropy Configuration from a serialized object.
  25051. * @param source - Serialized object.
  25052. * @param scene Defines the scene we are parsing for
  25053. * @param rootUrl Defines the rootUrl to load from
  25054. */
  25055. parse(source: any, scene: Scene, rootUrl: string): void;
  25056. }
  25057. }
  25058. declare module BABYLON {
  25059. /**
  25060. * @hidden
  25061. */
  25062. export interface IMaterialSubSurfaceDefines {
  25063. SUBSURFACE: boolean;
  25064. SS_REFRACTION: boolean;
  25065. SS_TRANSLUCENCY: boolean;
  25066. SS_SCATTERING: boolean;
  25067. SS_THICKNESSANDMASK_TEXTURE: boolean;
  25068. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  25069. SS_REFRACTIONMAP_3D: boolean;
  25070. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  25071. SS_LODINREFRACTIONALPHA: boolean;
  25072. SS_GAMMAREFRACTION: boolean;
  25073. SS_RGBDREFRACTION: boolean;
  25074. SS_LINEARSPECULARREFRACTION: boolean;
  25075. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  25076. SS_ALBEDOFORREFRACTIONTINT: boolean;
  25077. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  25078. /** @hidden */
  25079. _areTexturesDirty: boolean;
  25080. }
  25081. /**
  25082. * Define the code related to the sub surface parameters of the pbr material.
  25083. */
  25084. export class PBRSubSurfaceConfiguration {
  25085. private _isRefractionEnabled;
  25086. /**
  25087. * Defines if the refraction is enabled in the material.
  25088. */
  25089. isRefractionEnabled: boolean;
  25090. private _isTranslucencyEnabled;
  25091. /**
  25092. * Defines if the translucency is enabled in the material.
  25093. */
  25094. isTranslucencyEnabled: boolean;
  25095. private _isScatteringEnabled;
  25096. /**
  25097. * Defines if the sub surface scattering is enabled in the material.
  25098. */
  25099. isScatteringEnabled: boolean;
  25100. private _scatteringDiffusionProfileIndex;
  25101. /**
  25102. * Diffusion profile for subsurface scattering.
  25103. * Useful for better scattering in the skins or foliages.
  25104. */
  25105. get scatteringDiffusionProfile(): Nullable<Color3>;
  25106. set scatteringDiffusionProfile(c: Nullable<Color3>);
  25107. /**
  25108. * Defines the refraction intensity of the material.
  25109. * The refraction when enabled replaces the Diffuse part of the material.
  25110. * The intensity helps transitionning between diffuse and refraction.
  25111. */
  25112. refractionIntensity: number;
  25113. /**
  25114. * Defines the translucency intensity of the material.
  25115. * When translucency has been enabled, this defines how much of the "translucency"
  25116. * is addded to the diffuse part of the material.
  25117. */
  25118. translucencyIntensity: number;
  25119. /**
  25120. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  25121. */
  25122. useAlbedoToTintRefraction: boolean;
  25123. private _thicknessTexture;
  25124. /**
  25125. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  25126. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  25127. * 0 would mean minimumThickness
  25128. * 1 would mean maximumThickness
  25129. * The other channels might be use as a mask to vary the different effects intensity.
  25130. */
  25131. thicknessTexture: Nullable<BaseTexture>;
  25132. private _refractionTexture;
  25133. /**
  25134. * Defines the texture to use for refraction.
  25135. */
  25136. refractionTexture: Nullable<BaseTexture>;
  25137. private _indexOfRefraction;
  25138. /**
  25139. * Index of refraction of the material base layer.
  25140. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  25141. *
  25142. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  25143. *
  25144. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  25145. */
  25146. indexOfRefraction: number;
  25147. private _volumeIndexOfRefraction;
  25148. /**
  25149. * Index of refraction of the material's volume.
  25150. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  25151. *
  25152. * This ONLY impacts refraction. If not provided or given a non-valid value,
  25153. * the volume will use the same IOR as the surface.
  25154. */
  25155. get volumeIndexOfRefraction(): number;
  25156. set volumeIndexOfRefraction(value: number);
  25157. private _invertRefractionY;
  25158. /**
  25159. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  25160. */
  25161. invertRefractionY: boolean;
  25162. private _linkRefractionWithTransparency;
  25163. /**
  25164. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  25165. * Materials half opaque for instance using refraction could benefit from this control.
  25166. */
  25167. linkRefractionWithTransparency: boolean;
  25168. /**
  25169. * Defines the minimum thickness stored in the thickness map.
  25170. * If no thickness map is defined, this value will be used to simulate thickness.
  25171. */
  25172. minimumThickness: number;
  25173. /**
  25174. * Defines the maximum thickness stored in the thickness map.
  25175. */
  25176. maximumThickness: number;
  25177. /**
  25178. * Defines the volume tint of the material.
  25179. * This is used for both translucency and scattering.
  25180. */
  25181. tintColor: Color3;
  25182. /**
  25183. * Defines the distance at which the tint color should be found in the media.
  25184. * This is used for refraction only.
  25185. */
  25186. tintColorAtDistance: number;
  25187. /**
  25188. * Defines how far each channel transmit through the media.
  25189. * It is defined as a color to simplify it selection.
  25190. */
  25191. diffusionDistance: Color3;
  25192. private _useMaskFromThicknessTexture;
  25193. /**
  25194. * Stores the intensity of the different subsurface effects in the thickness texture.
  25195. * * the green channel is the translucency intensity.
  25196. * * the blue channel is the scattering intensity.
  25197. * * the alpha channel is the refraction intensity.
  25198. */
  25199. useMaskFromThicknessTexture: boolean;
  25200. private _scene;
  25201. /** @hidden */
  25202. private _internalMarkAllSubMeshesAsTexturesDirty;
  25203. private _internalMarkScenePrePassDirty;
  25204. /** @hidden */
  25205. _markAllSubMeshesAsTexturesDirty(): void;
  25206. /** @hidden */
  25207. _markScenePrePassDirty(): void;
  25208. /**
  25209. * Instantiate a new istance of sub surface configuration.
  25210. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  25211. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  25212. * @param scene The scene
  25213. */
  25214. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  25215. /**
  25216. * Gets wehter the submesh is ready to be used or not.
  25217. * @param defines the list of "defines" to update.
  25218. * @param scene defines the scene the material belongs to.
  25219. * @returns - boolean indicating that the submesh is ready or not.
  25220. */
  25221. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  25222. /**
  25223. * Checks to see if a texture is used in the material.
  25224. * @param defines the list of "defines" to update.
  25225. * @param scene defines the scene to the material belongs to.
  25226. */
  25227. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  25228. /**
  25229. * Binds the material data.
  25230. * @param uniformBuffer defines the Uniform buffer to fill in.
  25231. * @param scene defines the scene the material belongs to.
  25232. * @param engine defines the engine the material belongs to.
  25233. * @param isFrozen defines whether the material is frozen or not.
  25234. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  25235. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  25236. */
  25237. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  25238. /**
  25239. * Unbinds the material from the mesh.
  25240. * @param activeEffect defines the effect that should be unbound from.
  25241. * @returns true if unbound, otherwise false
  25242. */
  25243. unbind(activeEffect: Effect): boolean;
  25244. /**
  25245. * Returns the texture used for refraction or null if none is used.
  25246. * @param scene defines the scene the material belongs to.
  25247. * @returns - Refraction texture if present. If no refraction texture and refraction
  25248. * is linked with transparency, returns environment texture. Otherwise, returns null.
  25249. */
  25250. private _getRefractionTexture;
  25251. /**
  25252. * Returns true if alpha blending should be disabled.
  25253. */
  25254. get disableAlphaBlending(): boolean;
  25255. /**
  25256. * Fills the list of render target textures.
  25257. * @param renderTargets the list of render targets to update
  25258. */
  25259. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  25260. /**
  25261. * Checks to see if a texture is used in the material.
  25262. * @param texture - Base texture to use.
  25263. * @returns - Boolean specifying if a texture is used in the material.
  25264. */
  25265. hasTexture(texture: BaseTexture): boolean;
  25266. /**
  25267. * Gets a boolean indicating that current material needs to register RTT
  25268. * @returns true if this uses a render target otherwise false.
  25269. */
  25270. hasRenderTargetTextures(): boolean;
  25271. /**
  25272. * Returns an array of the actively used textures.
  25273. * @param activeTextures Array of BaseTextures
  25274. */
  25275. getActiveTextures(activeTextures: BaseTexture[]): void;
  25276. /**
  25277. * Returns the animatable textures.
  25278. * @param animatables Array of animatable textures.
  25279. */
  25280. getAnimatables(animatables: IAnimatable[]): void;
  25281. /**
  25282. * Disposes the resources of the material.
  25283. * @param forceDisposeTextures - Forces the disposal of all textures.
  25284. */
  25285. dispose(forceDisposeTextures?: boolean): void;
  25286. /**
  25287. * Get the current class name of the texture useful for serialization or dynamic coding.
  25288. * @returns "PBRSubSurfaceConfiguration"
  25289. */
  25290. getClassName(): string;
  25291. /**
  25292. * Add fallbacks to the effect fallbacks list.
  25293. * @param defines defines the Base texture to use.
  25294. * @param fallbacks defines the current fallback list.
  25295. * @param currentRank defines the current fallback rank.
  25296. * @returns the new fallback rank.
  25297. */
  25298. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  25299. /**
  25300. * Add the required uniforms to the current list.
  25301. * @param uniforms defines the current uniform list.
  25302. */
  25303. static AddUniforms(uniforms: string[]): void;
  25304. /**
  25305. * Add the required samplers to the current list.
  25306. * @param samplers defines the current sampler list.
  25307. */
  25308. static AddSamplers(samplers: string[]): void;
  25309. /**
  25310. * Add the required uniforms to the current buffer.
  25311. * @param uniformBuffer defines the current uniform buffer.
  25312. */
  25313. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  25314. /**
  25315. * Makes a duplicate of the current configuration into another one.
  25316. * @param configuration define the config where to copy the info
  25317. */
  25318. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  25319. /**
  25320. * Serializes this Sub Surface configuration.
  25321. * @returns - An object with the serialized config.
  25322. */
  25323. serialize(): any;
  25324. /**
  25325. * Parses a anisotropy Configuration from a serialized object.
  25326. * @param source - Serialized object.
  25327. * @param scene Defines the scene we are parsing for
  25328. * @param rootUrl Defines the rootUrl to load from
  25329. */
  25330. parse(source: any, scene: Scene, rootUrl: string): void;
  25331. }
  25332. }
  25333. declare module BABYLON {
  25334. /**
  25335. * Class representing spherical harmonics coefficients to the 3rd degree
  25336. */
  25337. export class SphericalHarmonics {
  25338. /**
  25339. * Defines whether or not the harmonics have been prescaled for rendering.
  25340. */
  25341. preScaled: boolean;
  25342. /**
  25343. * The l0,0 coefficients of the spherical harmonics
  25344. */
  25345. l00: Vector3;
  25346. /**
  25347. * The l1,-1 coefficients of the spherical harmonics
  25348. */
  25349. l1_1: Vector3;
  25350. /**
  25351. * The l1,0 coefficients of the spherical harmonics
  25352. */
  25353. l10: Vector3;
  25354. /**
  25355. * The l1,1 coefficients of the spherical harmonics
  25356. */
  25357. l11: Vector3;
  25358. /**
  25359. * The l2,-2 coefficients of the spherical harmonics
  25360. */
  25361. l2_2: Vector3;
  25362. /**
  25363. * The l2,-1 coefficients of the spherical harmonics
  25364. */
  25365. l2_1: Vector3;
  25366. /**
  25367. * The l2,0 coefficients of the spherical harmonics
  25368. */
  25369. l20: Vector3;
  25370. /**
  25371. * The l2,1 coefficients of the spherical harmonics
  25372. */
  25373. l21: Vector3;
  25374. /**
  25375. * The l2,2 coefficients of the spherical harmonics
  25376. */
  25377. l22: Vector3;
  25378. /**
  25379. * Adds a light to the spherical harmonics
  25380. * @param direction the direction of the light
  25381. * @param color the color of the light
  25382. * @param deltaSolidAngle the delta solid angle of the light
  25383. */
  25384. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  25385. /**
  25386. * Scales the spherical harmonics by the given amount
  25387. * @param scale the amount to scale
  25388. */
  25389. scaleInPlace(scale: number): void;
  25390. /**
  25391. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  25392. *
  25393. * ```
  25394. * E_lm = A_l * L_lm
  25395. * ```
  25396. *
  25397. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  25398. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  25399. * the scaling factors are given in equation 9.
  25400. */
  25401. convertIncidentRadianceToIrradiance(): void;
  25402. /**
  25403. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  25404. *
  25405. * ```
  25406. * L = (1/pi) * E * rho
  25407. * ```
  25408. *
  25409. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  25410. */
  25411. convertIrradianceToLambertianRadiance(): void;
  25412. /**
  25413. * Integrates the reconstruction coefficients directly in to the SH preventing further
  25414. * required operations at run time.
  25415. *
  25416. * This is simply done by scaling back the SH with Ylm constants parameter.
  25417. * The trigonometric part being applied by the shader at run time.
  25418. */
  25419. preScaleForRendering(): void;
  25420. /**
  25421. * Constructs a spherical harmonics from an array.
  25422. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  25423. * @returns the spherical harmonics
  25424. */
  25425. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  25426. /**
  25427. * Gets the spherical harmonics from polynomial
  25428. * @param polynomial the spherical polynomial
  25429. * @returns the spherical harmonics
  25430. */
  25431. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  25432. }
  25433. /**
  25434. * Class representing spherical polynomial coefficients to the 3rd degree
  25435. */
  25436. export class SphericalPolynomial {
  25437. private _harmonics;
  25438. /**
  25439. * The spherical harmonics used to create the polynomials.
  25440. */
  25441. get preScaledHarmonics(): SphericalHarmonics;
  25442. /**
  25443. * The x coefficients of the spherical polynomial
  25444. */
  25445. x: Vector3;
  25446. /**
  25447. * The y coefficients of the spherical polynomial
  25448. */
  25449. y: Vector3;
  25450. /**
  25451. * The z coefficients of the spherical polynomial
  25452. */
  25453. z: Vector3;
  25454. /**
  25455. * The xx coefficients of the spherical polynomial
  25456. */
  25457. xx: Vector3;
  25458. /**
  25459. * The yy coefficients of the spherical polynomial
  25460. */
  25461. yy: Vector3;
  25462. /**
  25463. * The zz coefficients of the spherical polynomial
  25464. */
  25465. zz: Vector3;
  25466. /**
  25467. * The xy coefficients of the spherical polynomial
  25468. */
  25469. xy: Vector3;
  25470. /**
  25471. * The yz coefficients of the spherical polynomial
  25472. */
  25473. yz: Vector3;
  25474. /**
  25475. * The zx coefficients of the spherical polynomial
  25476. */
  25477. zx: Vector3;
  25478. /**
  25479. * Adds an ambient color to the spherical polynomial
  25480. * @param color the color to add
  25481. */
  25482. addAmbient(color: Color3): void;
  25483. /**
  25484. * Scales the spherical polynomial by the given amount
  25485. * @param scale the amount to scale
  25486. */
  25487. scaleInPlace(scale: number): void;
  25488. /**
  25489. * Gets the spherical polynomial from harmonics
  25490. * @param harmonics the spherical harmonics
  25491. * @returns the spherical polynomial
  25492. */
  25493. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  25494. /**
  25495. * Constructs a spherical polynomial from an array.
  25496. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  25497. * @returns the spherical polynomial
  25498. */
  25499. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  25500. }
  25501. }
  25502. declare module BABYLON {
  25503. /**
  25504. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  25505. */
  25506. export interface CubeMapInfo {
  25507. /**
  25508. * The pixel array for the front face.
  25509. * This is stored in format, left to right, up to down format.
  25510. */
  25511. front: Nullable<ArrayBufferView>;
  25512. /**
  25513. * The pixel array for the back face.
  25514. * This is stored in format, left to right, up to down format.
  25515. */
  25516. back: Nullable<ArrayBufferView>;
  25517. /**
  25518. * The pixel array for the left face.
  25519. * This is stored in format, left to right, up to down format.
  25520. */
  25521. left: Nullable<ArrayBufferView>;
  25522. /**
  25523. * The pixel array for the right face.
  25524. * This is stored in format, left to right, up to down format.
  25525. */
  25526. right: Nullable<ArrayBufferView>;
  25527. /**
  25528. * The pixel array for the up face.
  25529. * This is stored in format, left to right, up to down format.
  25530. */
  25531. up: Nullable<ArrayBufferView>;
  25532. /**
  25533. * The pixel array for the down face.
  25534. * This is stored in format, left to right, up to down format.
  25535. */
  25536. down: Nullable<ArrayBufferView>;
  25537. /**
  25538. * The size of the cubemap stored.
  25539. *
  25540. * Each faces will be size * size pixels.
  25541. */
  25542. size: number;
  25543. /**
  25544. * The format of the texture.
  25545. *
  25546. * RGBA, RGB.
  25547. */
  25548. format: number;
  25549. /**
  25550. * The type of the texture data.
  25551. *
  25552. * UNSIGNED_INT, FLOAT.
  25553. */
  25554. type: number;
  25555. /**
  25556. * Specifies whether the texture is in gamma space.
  25557. */
  25558. gammaSpace: boolean;
  25559. }
  25560. /**
  25561. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  25562. */
  25563. export class PanoramaToCubeMapTools {
  25564. private static FACE_LEFT;
  25565. private static FACE_RIGHT;
  25566. private static FACE_FRONT;
  25567. private static FACE_BACK;
  25568. private static FACE_DOWN;
  25569. private static FACE_UP;
  25570. /**
  25571. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  25572. *
  25573. * @param float32Array The source data.
  25574. * @param inputWidth The width of the input panorama.
  25575. * @param inputHeight The height of the input panorama.
  25576. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  25577. * @return The cubemap data
  25578. */
  25579. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  25580. private static CreateCubemapTexture;
  25581. private static CalcProjectionSpherical;
  25582. }
  25583. }
  25584. declare module BABYLON {
  25585. /**
  25586. * Helper class dealing with the extraction of spherical polynomial dataArray
  25587. * from a cube map.
  25588. */
  25589. export class CubeMapToSphericalPolynomialTools {
  25590. private static FileFaces;
  25591. /**
  25592. * Converts a texture to the according Spherical Polynomial data.
  25593. * This extracts the first 3 orders only as they are the only one used in the lighting.
  25594. *
  25595. * @param texture The texture to extract the information from.
  25596. * @return The Spherical Polynomial data.
  25597. */
  25598. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  25599. /**
  25600. * Converts a cubemap to the according Spherical Polynomial data.
  25601. * This extracts the first 3 orders only as they are the only one used in the lighting.
  25602. *
  25603. * @param cubeInfo The Cube map to extract the information from.
  25604. * @return The Spherical Polynomial data.
  25605. */
  25606. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  25607. }
  25608. }
  25609. declare module BABYLON {
  25610. interface BaseTexture {
  25611. /**
  25612. * Get the polynomial representation of the texture data.
  25613. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  25614. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  25615. */
  25616. sphericalPolynomial: Nullable<SphericalPolynomial>;
  25617. }
  25618. }
  25619. declare module BABYLON {
  25620. /** @hidden */
  25621. export var pbrFragmentDeclaration: {
  25622. name: string;
  25623. shader: string;
  25624. };
  25625. }
  25626. declare module BABYLON {
  25627. /** @hidden */
  25628. export var pbrUboDeclaration: {
  25629. name: string;
  25630. shader: string;
  25631. };
  25632. }
  25633. declare module BABYLON {
  25634. /** @hidden */
  25635. export var pbrFragmentExtraDeclaration: {
  25636. name: string;
  25637. shader: string;
  25638. };
  25639. }
  25640. declare module BABYLON {
  25641. /** @hidden */
  25642. export var pbrFragmentSamplersDeclaration: {
  25643. name: string;
  25644. shader: string;
  25645. };
  25646. }
  25647. declare module BABYLON {
  25648. /** @hidden */
  25649. export var subSurfaceScatteringFunctions: {
  25650. name: string;
  25651. shader: string;
  25652. };
  25653. }
  25654. declare module BABYLON {
  25655. /** @hidden */
  25656. export var importanceSampling: {
  25657. name: string;
  25658. shader: string;
  25659. };
  25660. }
  25661. declare module BABYLON {
  25662. /** @hidden */
  25663. export var pbrHelperFunctions: {
  25664. name: string;
  25665. shader: string;
  25666. };
  25667. }
  25668. declare module BABYLON {
  25669. /** @hidden */
  25670. export var harmonicsFunctions: {
  25671. name: string;
  25672. shader: string;
  25673. };
  25674. }
  25675. declare module BABYLON {
  25676. /** @hidden */
  25677. export var pbrDirectLightingSetupFunctions: {
  25678. name: string;
  25679. shader: string;
  25680. };
  25681. }
  25682. declare module BABYLON {
  25683. /** @hidden */
  25684. export var pbrDirectLightingFalloffFunctions: {
  25685. name: string;
  25686. shader: string;
  25687. };
  25688. }
  25689. declare module BABYLON {
  25690. /** @hidden */
  25691. export var pbrBRDFFunctions: {
  25692. name: string;
  25693. shader: string;
  25694. };
  25695. }
  25696. declare module BABYLON {
  25697. /** @hidden */
  25698. export var hdrFilteringFunctions: {
  25699. name: string;
  25700. shader: string;
  25701. };
  25702. }
  25703. declare module BABYLON {
  25704. /** @hidden */
  25705. export var pbrDirectLightingFunctions: {
  25706. name: string;
  25707. shader: string;
  25708. };
  25709. }
  25710. declare module BABYLON {
  25711. /** @hidden */
  25712. export var pbrIBLFunctions: {
  25713. name: string;
  25714. shader: string;
  25715. };
  25716. }
  25717. declare module BABYLON {
  25718. /** @hidden */
  25719. export var pbrBlockAlbedoOpacity: {
  25720. name: string;
  25721. shader: string;
  25722. };
  25723. }
  25724. declare module BABYLON {
  25725. /** @hidden */
  25726. export var pbrBlockReflectivity: {
  25727. name: string;
  25728. shader: string;
  25729. };
  25730. }
  25731. declare module BABYLON {
  25732. /** @hidden */
  25733. export var pbrBlockAmbientOcclusion: {
  25734. name: string;
  25735. shader: string;
  25736. };
  25737. }
  25738. declare module BABYLON {
  25739. /** @hidden */
  25740. export var pbrBlockAlphaFresnel: {
  25741. name: string;
  25742. shader: string;
  25743. };
  25744. }
  25745. declare module BABYLON {
  25746. /** @hidden */
  25747. export var pbrBlockAnisotropic: {
  25748. name: string;
  25749. shader: string;
  25750. };
  25751. }
  25752. declare module BABYLON {
  25753. /** @hidden */
  25754. export var pbrBlockReflection: {
  25755. name: string;
  25756. shader: string;
  25757. };
  25758. }
  25759. declare module BABYLON {
  25760. /** @hidden */
  25761. export var pbrBlockSheen: {
  25762. name: string;
  25763. shader: string;
  25764. };
  25765. }
  25766. declare module BABYLON {
  25767. /** @hidden */
  25768. export var pbrBlockClearcoat: {
  25769. name: string;
  25770. shader: string;
  25771. };
  25772. }
  25773. declare module BABYLON {
  25774. /** @hidden */
  25775. export var pbrBlockSubSurface: {
  25776. name: string;
  25777. shader: string;
  25778. };
  25779. }
  25780. declare module BABYLON {
  25781. /** @hidden */
  25782. export var pbrBlockNormalGeometric: {
  25783. name: string;
  25784. shader: string;
  25785. };
  25786. }
  25787. declare module BABYLON {
  25788. /** @hidden */
  25789. export var pbrBlockNormalFinal: {
  25790. name: string;
  25791. shader: string;
  25792. };
  25793. }
  25794. declare module BABYLON {
  25795. /** @hidden */
  25796. export var pbrBlockLightmapInit: {
  25797. name: string;
  25798. shader: string;
  25799. };
  25800. }
  25801. declare module BABYLON {
  25802. /** @hidden */
  25803. export var pbrBlockGeometryInfo: {
  25804. name: string;
  25805. shader: string;
  25806. };
  25807. }
  25808. declare module BABYLON {
  25809. /** @hidden */
  25810. export var pbrBlockReflectance0: {
  25811. name: string;
  25812. shader: string;
  25813. };
  25814. }
  25815. declare module BABYLON {
  25816. /** @hidden */
  25817. export var pbrBlockReflectance: {
  25818. name: string;
  25819. shader: string;
  25820. };
  25821. }
  25822. declare module BABYLON {
  25823. /** @hidden */
  25824. export var pbrBlockDirectLighting: {
  25825. name: string;
  25826. shader: string;
  25827. };
  25828. }
  25829. declare module BABYLON {
  25830. /** @hidden */
  25831. export var pbrBlockFinalLitComponents: {
  25832. name: string;
  25833. shader: string;
  25834. };
  25835. }
  25836. declare module BABYLON {
  25837. /** @hidden */
  25838. export var pbrBlockFinalUnlitComponents: {
  25839. name: string;
  25840. shader: string;
  25841. };
  25842. }
  25843. declare module BABYLON {
  25844. /** @hidden */
  25845. export var pbrBlockFinalColorComposition: {
  25846. name: string;
  25847. shader: string;
  25848. };
  25849. }
  25850. declare module BABYLON {
  25851. /** @hidden */
  25852. export var pbrBlockImageProcessing: {
  25853. name: string;
  25854. shader: string;
  25855. };
  25856. }
  25857. declare module BABYLON {
  25858. /** @hidden */
  25859. export var pbrDebug: {
  25860. name: string;
  25861. shader: string;
  25862. };
  25863. }
  25864. declare module BABYLON {
  25865. /** @hidden */
  25866. export var pbrPixelShader: {
  25867. name: string;
  25868. shader: string;
  25869. };
  25870. }
  25871. declare module BABYLON {
  25872. /** @hidden */
  25873. export var pbrVertexDeclaration: {
  25874. name: string;
  25875. shader: string;
  25876. };
  25877. }
  25878. declare module BABYLON {
  25879. /** @hidden */
  25880. export var pbrVertexShader: {
  25881. name: string;
  25882. shader: string;
  25883. };
  25884. }
  25885. declare module BABYLON {
  25886. /**
  25887. * Manages the defines for the PBR Material.
  25888. * @hidden
  25889. */
  25890. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  25891. PBR: boolean;
  25892. NUM_SAMPLES: string;
  25893. REALTIME_FILTERING: boolean;
  25894. MAINUV1: boolean;
  25895. MAINUV2: boolean;
  25896. UV1: boolean;
  25897. UV2: boolean;
  25898. ALBEDO: boolean;
  25899. GAMMAALBEDO: boolean;
  25900. ALBEDODIRECTUV: number;
  25901. VERTEXCOLOR: boolean;
  25902. DETAIL: boolean;
  25903. DETAILDIRECTUV: number;
  25904. DETAIL_NORMALBLENDMETHOD: number;
  25905. AMBIENT: boolean;
  25906. AMBIENTDIRECTUV: number;
  25907. AMBIENTINGRAYSCALE: boolean;
  25908. OPACITY: boolean;
  25909. VERTEXALPHA: boolean;
  25910. OPACITYDIRECTUV: number;
  25911. OPACITYRGB: boolean;
  25912. ALPHATEST: boolean;
  25913. DEPTHPREPASS: boolean;
  25914. ALPHABLEND: boolean;
  25915. ALPHAFROMALBEDO: boolean;
  25916. ALPHATESTVALUE: string;
  25917. SPECULAROVERALPHA: boolean;
  25918. RADIANCEOVERALPHA: boolean;
  25919. ALPHAFRESNEL: boolean;
  25920. LINEARALPHAFRESNEL: boolean;
  25921. PREMULTIPLYALPHA: boolean;
  25922. EMISSIVE: boolean;
  25923. EMISSIVEDIRECTUV: number;
  25924. REFLECTIVITY: boolean;
  25925. REFLECTIVITYDIRECTUV: number;
  25926. SPECULARTERM: boolean;
  25927. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  25928. MICROSURFACEAUTOMATIC: boolean;
  25929. LODBASEDMICROSFURACE: boolean;
  25930. MICROSURFACEMAP: boolean;
  25931. MICROSURFACEMAPDIRECTUV: number;
  25932. METALLICWORKFLOW: boolean;
  25933. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  25934. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  25935. METALLNESSSTOREINMETALMAPBLUE: boolean;
  25936. AOSTOREINMETALMAPRED: boolean;
  25937. METALLIC_REFLECTANCE: boolean;
  25938. METALLIC_REFLECTANCEDIRECTUV: number;
  25939. ENVIRONMENTBRDF: boolean;
  25940. ENVIRONMENTBRDF_RGBD: boolean;
  25941. NORMAL: boolean;
  25942. TANGENT: boolean;
  25943. BUMP: boolean;
  25944. BUMPDIRECTUV: number;
  25945. OBJECTSPACE_NORMALMAP: boolean;
  25946. PARALLAX: boolean;
  25947. PARALLAXOCCLUSION: boolean;
  25948. NORMALXYSCALE: boolean;
  25949. LIGHTMAP: boolean;
  25950. LIGHTMAPDIRECTUV: number;
  25951. USELIGHTMAPASSHADOWMAP: boolean;
  25952. GAMMALIGHTMAP: boolean;
  25953. RGBDLIGHTMAP: boolean;
  25954. REFLECTION: boolean;
  25955. REFLECTIONMAP_3D: boolean;
  25956. REFLECTIONMAP_SPHERICAL: boolean;
  25957. REFLECTIONMAP_PLANAR: boolean;
  25958. REFLECTIONMAP_CUBIC: boolean;
  25959. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  25960. REFLECTIONMAP_PROJECTION: boolean;
  25961. REFLECTIONMAP_SKYBOX: boolean;
  25962. REFLECTIONMAP_EXPLICIT: boolean;
  25963. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  25964. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  25965. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  25966. INVERTCUBICMAP: boolean;
  25967. USESPHERICALFROMREFLECTIONMAP: boolean;
  25968. USEIRRADIANCEMAP: boolean;
  25969. SPHERICAL_HARMONICS: boolean;
  25970. USESPHERICALINVERTEX: boolean;
  25971. REFLECTIONMAP_OPPOSITEZ: boolean;
  25972. LODINREFLECTIONALPHA: boolean;
  25973. GAMMAREFLECTION: boolean;
  25974. RGBDREFLECTION: boolean;
  25975. LINEARSPECULARREFLECTION: boolean;
  25976. RADIANCEOCCLUSION: boolean;
  25977. HORIZONOCCLUSION: boolean;
  25978. INSTANCES: boolean;
  25979. THIN_INSTANCES: boolean;
  25980. PREPASS: boolean;
  25981. PREPASS_IRRADIANCE: boolean;
  25982. PREPASS_IRRADIANCE_INDEX: number;
  25983. PREPASS_ALBEDO: boolean;
  25984. PREPASS_ALBEDO_INDEX: number;
  25985. PREPASS_DEPTHNORMAL: boolean;
  25986. PREPASS_DEPTHNORMAL_INDEX: number;
  25987. PREPASS_POSITION: boolean;
  25988. PREPASS_POSITION_INDEX: number;
  25989. PREPASS_VELOCITY: boolean;
  25990. PREPASS_VELOCITY_INDEX: number;
  25991. PREPASS_REFLECTIVITY: boolean;
  25992. PREPASS_REFLECTIVITY_INDEX: number;
  25993. SCENE_MRT_COUNT: number;
  25994. NUM_BONE_INFLUENCERS: number;
  25995. BonesPerMesh: number;
  25996. BONETEXTURE: boolean;
  25997. BONES_VELOCITY_ENABLED: boolean;
  25998. NONUNIFORMSCALING: boolean;
  25999. MORPHTARGETS: boolean;
  26000. MORPHTARGETS_NORMAL: boolean;
  26001. MORPHTARGETS_TANGENT: boolean;
  26002. MORPHTARGETS_UV: boolean;
  26003. NUM_MORPH_INFLUENCERS: number;
  26004. IMAGEPROCESSING: boolean;
  26005. VIGNETTE: boolean;
  26006. VIGNETTEBLENDMODEMULTIPLY: boolean;
  26007. VIGNETTEBLENDMODEOPAQUE: boolean;
  26008. TONEMAPPING: boolean;
  26009. TONEMAPPING_ACES: boolean;
  26010. CONTRAST: boolean;
  26011. COLORCURVES: boolean;
  26012. COLORGRADING: boolean;
  26013. COLORGRADING3D: boolean;
  26014. SAMPLER3DGREENDEPTH: boolean;
  26015. SAMPLER3DBGRMAP: boolean;
  26016. IMAGEPROCESSINGPOSTPROCESS: boolean;
  26017. EXPOSURE: boolean;
  26018. MULTIVIEW: boolean;
  26019. USEPHYSICALLIGHTFALLOFF: boolean;
  26020. USEGLTFLIGHTFALLOFF: boolean;
  26021. TWOSIDEDLIGHTING: boolean;
  26022. SHADOWFLOAT: boolean;
  26023. CLIPPLANE: boolean;
  26024. CLIPPLANE2: boolean;
  26025. CLIPPLANE3: boolean;
  26026. CLIPPLANE4: boolean;
  26027. CLIPPLANE5: boolean;
  26028. CLIPPLANE6: boolean;
  26029. POINTSIZE: boolean;
  26030. FOG: boolean;
  26031. LOGARITHMICDEPTH: boolean;
  26032. FORCENORMALFORWARD: boolean;
  26033. SPECULARAA: boolean;
  26034. CLEARCOAT: boolean;
  26035. CLEARCOAT_DEFAULTIOR: boolean;
  26036. CLEARCOAT_TEXTURE: boolean;
  26037. CLEARCOAT_TEXTUREDIRECTUV: number;
  26038. CLEARCOAT_BUMP: boolean;
  26039. CLEARCOAT_BUMPDIRECTUV: number;
  26040. CLEARCOAT_REMAP_F0: boolean;
  26041. CLEARCOAT_TINT: boolean;
  26042. CLEARCOAT_TINT_TEXTURE: boolean;
  26043. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  26044. ANISOTROPIC: boolean;
  26045. ANISOTROPIC_TEXTURE: boolean;
  26046. ANISOTROPIC_TEXTUREDIRECTUV: number;
  26047. BRDF_V_HEIGHT_CORRELATED: boolean;
  26048. MS_BRDF_ENERGY_CONSERVATION: boolean;
  26049. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  26050. SHEEN: boolean;
  26051. SHEEN_TEXTURE: boolean;
  26052. SHEEN_TEXTUREDIRECTUV: number;
  26053. SHEEN_LINKWITHALBEDO: boolean;
  26054. SHEEN_ROUGHNESS: boolean;
  26055. SHEEN_ALBEDOSCALING: boolean;
  26056. SUBSURFACE: boolean;
  26057. SS_REFRACTION: boolean;
  26058. SS_TRANSLUCENCY: boolean;
  26059. SS_SCATTERING: boolean;
  26060. SS_THICKNESSANDMASK_TEXTURE: boolean;
  26061. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  26062. SS_REFRACTIONMAP_3D: boolean;
  26063. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  26064. SS_LODINREFRACTIONALPHA: boolean;
  26065. SS_GAMMAREFRACTION: boolean;
  26066. SS_RGBDREFRACTION: boolean;
  26067. SS_LINEARSPECULARREFRACTION: boolean;
  26068. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  26069. SS_ALBEDOFORREFRACTIONTINT: boolean;
  26070. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  26071. UNLIT: boolean;
  26072. DEBUGMODE: number;
  26073. /**
  26074. * Initializes the PBR Material defines.
  26075. */
  26076. constructor();
  26077. /**
  26078. * Resets the PBR Material defines.
  26079. */
  26080. reset(): void;
  26081. }
  26082. /**
  26083. * The Physically based material base class of BJS.
  26084. *
  26085. * This offers the main features of a standard PBR material.
  26086. * For more information, please refer to the documentation :
  26087. * https://doc.babylonjs.com/how_to/physically_based_rendering
  26088. */
  26089. export abstract class PBRBaseMaterial extends PushMaterial {
  26090. /**
  26091. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  26092. */
  26093. static readonly PBRMATERIAL_OPAQUE: number;
  26094. /**
  26095. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  26096. */
  26097. static readonly PBRMATERIAL_ALPHATEST: number;
  26098. /**
  26099. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  26100. */
  26101. static readonly PBRMATERIAL_ALPHABLEND: number;
  26102. /**
  26103. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  26104. * They are also discarded below the alpha cutoff threshold to improve performances.
  26105. */
  26106. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  26107. /**
  26108. * Defines the default value of how much AO map is occluding the analytical lights
  26109. * (point spot...).
  26110. */
  26111. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  26112. /**
  26113. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  26114. */
  26115. static readonly LIGHTFALLOFF_PHYSICAL: number;
  26116. /**
  26117. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  26118. * to enhance interoperability with other engines.
  26119. */
  26120. static readonly LIGHTFALLOFF_GLTF: number;
  26121. /**
  26122. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  26123. * to enhance interoperability with other materials.
  26124. */
  26125. static readonly LIGHTFALLOFF_STANDARD: number;
  26126. /**
  26127. * Intensity of the direct lights e.g. the four lights available in your scene.
  26128. * This impacts both the direct diffuse and specular highlights.
  26129. */
  26130. protected _directIntensity: number;
  26131. /**
  26132. * Intensity of the emissive part of the material.
  26133. * This helps controlling the emissive effect without modifying the emissive color.
  26134. */
  26135. protected _emissiveIntensity: number;
  26136. /**
  26137. * Intensity of the environment e.g. how much the environment will light the object
  26138. * either through harmonics for rough material or through the refelction for shiny ones.
  26139. */
  26140. protected _environmentIntensity: number;
  26141. /**
  26142. * This is a special control allowing the reduction of the specular highlights coming from the
  26143. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  26144. */
  26145. protected _specularIntensity: number;
  26146. /**
  26147. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  26148. */
  26149. private _lightingInfos;
  26150. /**
  26151. * Debug Control allowing disabling the bump map on this material.
  26152. */
  26153. protected _disableBumpMap: boolean;
  26154. /**
  26155. * AKA Diffuse Texture in standard nomenclature.
  26156. */
  26157. protected _albedoTexture: Nullable<BaseTexture>;
  26158. /**
  26159. * AKA Occlusion Texture in other nomenclature.
  26160. */
  26161. protected _ambientTexture: Nullable<BaseTexture>;
  26162. /**
  26163. * AKA Occlusion Texture Intensity in other nomenclature.
  26164. */
  26165. protected _ambientTextureStrength: number;
  26166. /**
  26167. * Defines how much the AO map is occluding the analytical lights (point spot...).
  26168. * 1 means it completely occludes it
  26169. * 0 mean it has no impact
  26170. */
  26171. protected _ambientTextureImpactOnAnalyticalLights: number;
  26172. /**
  26173. * Stores the alpha values in a texture.
  26174. */
  26175. protected _opacityTexture: Nullable<BaseTexture>;
  26176. /**
  26177. * Stores the reflection values in a texture.
  26178. */
  26179. protected _reflectionTexture: Nullable<BaseTexture>;
  26180. /**
  26181. * Stores the emissive values in a texture.
  26182. */
  26183. protected _emissiveTexture: Nullable<BaseTexture>;
  26184. /**
  26185. * AKA Specular texture in other nomenclature.
  26186. */
  26187. protected _reflectivityTexture: Nullable<BaseTexture>;
  26188. /**
  26189. * Used to switch from specular/glossiness to metallic/roughness workflow.
  26190. */
  26191. protected _metallicTexture: Nullable<BaseTexture>;
  26192. /**
  26193. * Specifies the metallic scalar of the metallic/roughness workflow.
  26194. * Can also be used to scale the metalness values of the metallic texture.
  26195. */
  26196. protected _metallic: Nullable<number>;
  26197. /**
  26198. * Specifies the roughness scalar of the metallic/roughness workflow.
  26199. * Can also be used to scale the roughness values of the metallic texture.
  26200. */
  26201. protected _roughness: Nullable<number>;
  26202. /**
  26203. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  26204. * By default the indexOfrefraction is used to compute F0;
  26205. *
  26206. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  26207. *
  26208. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  26209. * F90 = metallicReflectanceColor;
  26210. */
  26211. protected _metallicF0Factor: number;
  26212. /**
  26213. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  26214. * By default the F90 is always 1;
  26215. *
  26216. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  26217. *
  26218. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  26219. * F90 = metallicReflectanceColor;
  26220. */
  26221. protected _metallicReflectanceColor: Color3;
  26222. /**
  26223. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  26224. * This is multiply against the scalar values defined in the material.
  26225. */
  26226. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  26227. /**
  26228. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  26229. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  26230. */
  26231. protected _microSurfaceTexture: Nullable<BaseTexture>;
  26232. /**
  26233. * Stores surface normal data used to displace a mesh in a texture.
  26234. */
  26235. protected _bumpTexture: Nullable<BaseTexture>;
  26236. /**
  26237. * Stores the pre-calculated light information of a mesh in a texture.
  26238. */
  26239. protected _lightmapTexture: Nullable<BaseTexture>;
  26240. /**
  26241. * The color of a material in ambient lighting.
  26242. */
  26243. protected _ambientColor: Color3;
  26244. /**
  26245. * AKA Diffuse Color in other nomenclature.
  26246. */
  26247. protected _albedoColor: Color3;
  26248. /**
  26249. * AKA Specular Color in other nomenclature.
  26250. */
  26251. protected _reflectivityColor: Color3;
  26252. /**
  26253. * The color applied when light is reflected from a material.
  26254. */
  26255. protected _reflectionColor: Color3;
  26256. /**
  26257. * The color applied when light is emitted from a material.
  26258. */
  26259. protected _emissiveColor: Color3;
  26260. /**
  26261. * AKA Glossiness in other nomenclature.
  26262. */
  26263. protected _microSurface: number;
  26264. /**
  26265. * Specifies that the material will use the light map as a show map.
  26266. */
  26267. protected _useLightmapAsShadowmap: boolean;
  26268. /**
  26269. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  26270. * makes the reflect vector face the model (under horizon).
  26271. */
  26272. protected _useHorizonOcclusion: boolean;
  26273. /**
  26274. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  26275. * too much the area relying on ambient texture to define their ambient occlusion.
  26276. */
  26277. protected _useRadianceOcclusion: boolean;
  26278. /**
  26279. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  26280. */
  26281. protected _useAlphaFromAlbedoTexture: boolean;
  26282. /**
  26283. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  26284. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  26285. */
  26286. protected _useSpecularOverAlpha: boolean;
  26287. /**
  26288. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  26289. */
  26290. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  26291. /**
  26292. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  26293. */
  26294. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  26295. /**
  26296. * Specifies if the metallic texture contains the roughness information in its green channel.
  26297. */
  26298. protected _useRoughnessFromMetallicTextureGreen: boolean;
  26299. /**
  26300. * Specifies if the metallic texture contains the metallness information in its blue channel.
  26301. */
  26302. protected _useMetallnessFromMetallicTextureBlue: boolean;
  26303. /**
  26304. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  26305. */
  26306. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  26307. /**
  26308. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  26309. */
  26310. protected _useAmbientInGrayScale: boolean;
  26311. /**
  26312. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  26313. * The material will try to infer what glossiness each pixel should be.
  26314. */
  26315. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  26316. /**
  26317. * Defines the falloff type used in this material.
  26318. * It by default is Physical.
  26319. */
  26320. protected _lightFalloff: number;
  26321. /**
  26322. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  26323. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  26324. */
  26325. protected _useRadianceOverAlpha: boolean;
  26326. /**
  26327. * Allows using an object space normal map (instead of tangent space).
  26328. */
  26329. protected _useObjectSpaceNormalMap: boolean;
  26330. /**
  26331. * Allows using the bump map in parallax mode.
  26332. */
  26333. protected _useParallax: boolean;
  26334. /**
  26335. * Allows using the bump map in parallax occlusion mode.
  26336. */
  26337. protected _useParallaxOcclusion: boolean;
  26338. /**
  26339. * Controls the scale bias of the parallax mode.
  26340. */
  26341. protected _parallaxScaleBias: number;
  26342. /**
  26343. * If sets to true, disables all the lights affecting the material.
  26344. */
  26345. protected _disableLighting: boolean;
  26346. /**
  26347. * Number of Simultaneous lights allowed on the material.
  26348. */
  26349. protected _maxSimultaneousLights: number;
  26350. /**
  26351. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  26352. */
  26353. protected _invertNormalMapX: boolean;
  26354. /**
  26355. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  26356. */
  26357. protected _invertNormalMapY: boolean;
  26358. /**
  26359. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  26360. */
  26361. protected _twoSidedLighting: boolean;
  26362. /**
  26363. * Defines the alpha limits in alpha test mode.
  26364. */
  26365. protected _alphaCutOff: number;
  26366. /**
  26367. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  26368. */
  26369. protected _forceAlphaTest: boolean;
  26370. /**
  26371. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  26372. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  26373. */
  26374. protected _useAlphaFresnel: boolean;
  26375. /**
  26376. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  26377. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  26378. */
  26379. protected _useLinearAlphaFresnel: boolean;
  26380. /**
  26381. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  26382. * from cos thetav and roughness:
  26383. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  26384. */
  26385. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  26386. /**
  26387. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  26388. */
  26389. protected _forceIrradianceInFragment: boolean;
  26390. private _realTimeFiltering;
  26391. /**
  26392. * Enables realtime filtering on the texture.
  26393. */
  26394. get realTimeFiltering(): boolean;
  26395. set realTimeFiltering(b: boolean);
  26396. private _realTimeFilteringQuality;
  26397. /**
  26398. * Quality switch for realtime filtering
  26399. */
  26400. get realTimeFilteringQuality(): number;
  26401. set realTimeFilteringQuality(n: number);
  26402. /**
  26403. * Can this material render to several textures at once
  26404. */
  26405. get canRenderToMRT(): boolean;
  26406. /**
  26407. * Force normal to face away from face.
  26408. */
  26409. protected _forceNormalForward: boolean;
  26410. /**
  26411. * Enables specular anti aliasing in the PBR shader.
  26412. * It will both interacts on the Geometry for analytical and IBL lighting.
  26413. * It also prefilter the roughness map based on the bump values.
  26414. */
  26415. protected _enableSpecularAntiAliasing: boolean;
  26416. /**
  26417. * Default configuration related to image processing available in the PBR Material.
  26418. */
  26419. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  26420. /**
  26421. * Keep track of the image processing observer to allow dispose and replace.
  26422. */
  26423. private _imageProcessingObserver;
  26424. /**
  26425. * Attaches a new image processing configuration to the PBR Material.
  26426. * @param configuration
  26427. */
  26428. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  26429. /**
  26430. * Stores the available render targets.
  26431. */
  26432. private _renderTargets;
  26433. /**
  26434. * Sets the global ambient color for the material used in lighting calculations.
  26435. */
  26436. private _globalAmbientColor;
  26437. /**
  26438. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  26439. */
  26440. private _useLogarithmicDepth;
  26441. /**
  26442. * If set to true, no lighting calculations will be applied.
  26443. */
  26444. private _unlit;
  26445. private _debugMode;
  26446. /**
  26447. * @hidden
  26448. * This is reserved for the inspector.
  26449. * Defines the material debug mode.
  26450. * It helps seeing only some components of the material while troubleshooting.
  26451. */
  26452. debugMode: number;
  26453. /**
  26454. * @hidden
  26455. * This is reserved for the inspector.
  26456. * Specify from where on screen the debug mode should start.
  26457. * The value goes from -1 (full screen) to 1 (not visible)
  26458. * It helps with side by side comparison against the final render
  26459. * This defaults to -1
  26460. */
  26461. private debugLimit;
  26462. /**
  26463. * @hidden
  26464. * This is reserved for the inspector.
  26465. * As the default viewing range might not be enough (if the ambient is really small for instance)
  26466. * You can use the factor to better multiply the final value.
  26467. */
  26468. private debugFactor;
  26469. /**
  26470. * Defines the clear coat layer parameters for the material.
  26471. */
  26472. readonly clearCoat: PBRClearCoatConfiguration;
  26473. /**
  26474. * Defines the anisotropic parameters for the material.
  26475. */
  26476. readonly anisotropy: PBRAnisotropicConfiguration;
  26477. /**
  26478. * Defines the BRDF parameters for the material.
  26479. */
  26480. readonly brdf: PBRBRDFConfiguration;
  26481. /**
  26482. * Defines the Sheen parameters for the material.
  26483. */
  26484. readonly sheen: PBRSheenConfiguration;
  26485. /**
  26486. * Defines the SubSurface parameters for the material.
  26487. */
  26488. readonly subSurface: PBRSubSurfaceConfiguration;
  26489. /**
  26490. * Defines additionnal PrePass parameters for the material.
  26491. */
  26492. readonly prePassConfiguration: PrePassConfiguration;
  26493. /**
  26494. * Defines the detail map parameters for the material.
  26495. */
  26496. readonly detailMap: DetailMapConfiguration;
  26497. protected _rebuildInParallel: boolean;
  26498. /**
  26499. * Instantiates a new PBRMaterial instance.
  26500. *
  26501. * @param name The material name
  26502. * @param scene The scene the material will be use in.
  26503. */
  26504. constructor(name: string, scene: Scene);
  26505. /**
  26506. * Gets a boolean indicating that current material needs to register RTT
  26507. */
  26508. get hasRenderTargetTextures(): boolean;
  26509. /**
  26510. * Gets the name of the material class.
  26511. */
  26512. getClassName(): string;
  26513. /**
  26514. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  26515. */
  26516. get useLogarithmicDepth(): boolean;
  26517. /**
  26518. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  26519. */
  26520. set useLogarithmicDepth(value: boolean);
  26521. /**
  26522. * Returns true if alpha blending should be disabled.
  26523. */
  26524. protected get _disableAlphaBlending(): boolean;
  26525. /**
  26526. * Specifies whether or not this material should be rendered in alpha blend mode.
  26527. */
  26528. needAlphaBlending(): boolean;
  26529. /**
  26530. * Specifies whether or not this material should be rendered in alpha test mode.
  26531. */
  26532. needAlphaTesting(): boolean;
  26533. /**
  26534. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  26535. */
  26536. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  26537. /**
  26538. * Gets the texture used for the alpha test.
  26539. */
  26540. getAlphaTestTexture(): Nullable<BaseTexture>;
  26541. /**
  26542. * Specifies that the submesh is ready to be used.
  26543. * @param mesh - BJS mesh.
  26544. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  26545. * @param useInstances - Specifies that instances should be used.
  26546. * @returns - boolean indicating that the submesh is ready or not.
  26547. */
  26548. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  26549. /**
  26550. * Specifies if the material uses metallic roughness workflow.
  26551. * @returns boolean specifiying if the material uses metallic roughness workflow.
  26552. */
  26553. isMetallicWorkflow(): boolean;
  26554. private _prepareEffect;
  26555. private _prepareDefines;
  26556. /**
  26557. * Force shader compilation
  26558. */
  26559. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  26560. /**
  26561. * Initializes the uniform buffer layout for the shader.
  26562. */
  26563. buildUniformLayout(): void;
  26564. /**
  26565. * Unbinds the material from the mesh
  26566. */
  26567. unbind(): void;
  26568. /**
  26569. * Binds the submesh data.
  26570. * @param world - The world matrix.
  26571. * @param mesh - The BJS mesh.
  26572. * @param subMesh - A submesh of the BJS mesh.
  26573. */
  26574. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  26575. /**
  26576. * Returns the animatable textures.
  26577. * @returns - Array of animatable textures.
  26578. */
  26579. getAnimatables(): IAnimatable[];
  26580. /**
  26581. * Returns the texture used for reflections.
  26582. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  26583. */
  26584. private _getReflectionTexture;
  26585. /**
  26586. * Returns an array of the actively used textures.
  26587. * @returns - Array of BaseTextures
  26588. */
  26589. getActiveTextures(): BaseTexture[];
  26590. /**
  26591. * Checks to see if a texture is used in the material.
  26592. * @param texture - Base texture to use.
  26593. * @returns - Boolean specifying if a texture is used in the material.
  26594. */
  26595. hasTexture(texture: BaseTexture): boolean;
  26596. /**
  26597. * Sets the required values to the prepass renderer.
  26598. * @param prePassRenderer defines the prepass renderer to setup
  26599. */
  26600. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  26601. /**
  26602. * Disposes the resources of the material.
  26603. * @param forceDisposeEffect - Forces the disposal of effects.
  26604. * @param forceDisposeTextures - Forces the disposal of all textures.
  26605. */
  26606. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  26607. }
  26608. }
  26609. declare module BABYLON {
  26610. /**
  26611. * The Physically based material of BJS.
  26612. *
  26613. * This offers the main features of a standard PBR material.
  26614. * For more information, please refer to the documentation :
  26615. * https://doc.babylonjs.com/how_to/physically_based_rendering
  26616. */
  26617. export class PBRMaterial extends PBRBaseMaterial {
  26618. /**
  26619. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  26620. */
  26621. static readonly PBRMATERIAL_OPAQUE: number;
  26622. /**
  26623. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  26624. */
  26625. static readonly PBRMATERIAL_ALPHATEST: number;
  26626. /**
  26627. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  26628. */
  26629. static readonly PBRMATERIAL_ALPHABLEND: number;
  26630. /**
  26631. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  26632. * They are also discarded below the alpha cutoff threshold to improve performances.
  26633. */
  26634. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  26635. /**
  26636. * Defines the default value of how much AO map is occluding the analytical lights
  26637. * (point spot...).
  26638. */
  26639. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  26640. /**
  26641. * Intensity of the direct lights e.g. the four lights available in your scene.
  26642. * This impacts both the direct diffuse and specular highlights.
  26643. */
  26644. directIntensity: number;
  26645. /**
  26646. * Intensity of the emissive part of the material.
  26647. * This helps controlling the emissive effect without modifying the emissive color.
  26648. */
  26649. emissiveIntensity: number;
  26650. /**
  26651. * Intensity of the environment e.g. how much the environment will light the object
  26652. * either through harmonics for rough material or through the refelction for shiny ones.
  26653. */
  26654. environmentIntensity: number;
  26655. /**
  26656. * This is a special control allowing the reduction of the specular highlights coming from the
  26657. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  26658. */
  26659. specularIntensity: number;
  26660. /**
  26661. * Debug Control allowing disabling the bump map on this material.
  26662. */
  26663. disableBumpMap: boolean;
  26664. /**
  26665. * AKA Diffuse Texture in standard nomenclature.
  26666. */
  26667. albedoTexture: BaseTexture;
  26668. /**
  26669. * AKA Occlusion Texture in other nomenclature.
  26670. */
  26671. ambientTexture: BaseTexture;
  26672. /**
  26673. * AKA Occlusion Texture Intensity in other nomenclature.
  26674. */
  26675. ambientTextureStrength: number;
  26676. /**
  26677. * Defines how much the AO map is occluding the analytical lights (point spot...).
  26678. * 1 means it completely occludes it
  26679. * 0 mean it has no impact
  26680. */
  26681. ambientTextureImpactOnAnalyticalLights: number;
  26682. /**
  26683. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  26684. */
  26685. opacityTexture: BaseTexture;
  26686. /**
  26687. * Stores the reflection values in a texture.
  26688. */
  26689. reflectionTexture: Nullable<BaseTexture>;
  26690. /**
  26691. * Stores the emissive values in a texture.
  26692. */
  26693. emissiveTexture: BaseTexture;
  26694. /**
  26695. * AKA Specular texture in other nomenclature.
  26696. */
  26697. reflectivityTexture: BaseTexture;
  26698. /**
  26699. * Used to switch from specular/glossiness to metallic/roughness workflow.
  26700. */
  26701. metallicTexture: BaseTexture;
  26702. /**
  26703. * Specifies the metallic scalar of the metallic/roughness workflow.
  26704. * Can also be used to scale the metalness values of the metallic texture.
  26705. */
  26706. metallic: Nullable<number>;
  26707. /**
  26708. * Specifies the roughness scalar of the metallic/roughness workflow.
  26709. * Can also be used to scale the roughness values of the metallic texture.
  26710. */
  26711. roughness: Nullable<number>;
  26712. /**
  26713. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  26714. * By default the indexOfrefraction is used to compute F0;
  26715. *
  26716. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  26717. *
  26718. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  26719. * F90 = metallicReflectanceColor;
  26720. */
  26721. metallicF0Factor: number;
  26722. /**
  26723. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  26724. * By default the F90 is always 1;
  26725. *
  26726. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  26727. *
  26728. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  26729. * F90 = metallicReflectanceColor;
  26730. */
  26731. metallicReflectanceColor: Color3;
  26732. /**
  26733. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  26734. * This is multiply against the scalar values defined in the material.
  26735. */
  26736. metallicReflectanceTexture: Nullable<BaseTexture>;
  26737. /**
  26738. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  26739. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  26740. */
  26741. microSurfaceTexture: BaseTexture;
  26742. /**
  26743. * Stores surface normal data used to displace a mesh in a texture.
  26744. */
  26745. bumpTexture: BaseTexture;
  26746. /**
  26747. * Stores the pre-calculated light information of a mesh in a texture.
  26748. */
  26749. lightmapTexture: BaseTexture;
  26750. /**
  26751. * Stores the refracted light information in a texture.
  26752. */
  26753. get refractionTexture(): Nullable<BaseTexture>;
  26754. set refractionTexture(value: Nullable<BaseTexture>);
  26755. /**
  26756. * The color of a material in ambient lighting.
  26757. */
  26758. ambientColor: Color3;
  26759. /**
  26760. * AKA Diffuse Color in other nomenclature.
  26761. */
  26762. albedoColor: Color3;
  26763. /**
  26764. * AKA Specular Color in other nomenclature.
  26765. */
  26766. reflectivityColor: Color3;
  26767. /**
  26768. * The color reflected from the material.
  26769. */
  26770. reflectionColor: Color3;
  26771. /**
  26772. * The color emitted from the material.
  26773. */
  26774. emissiveColor: Color3;
  26775. /**
  26776. * AKA Glossiness in other nomenclature.
  26777. */
  26778. microSurface: number;
  26779. /**
  26780. * Index of refraction of the material base layer.
  26781. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  26782. *
  26783. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  26784. *
  26785. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  26786. */
  26787. get indexOfRefraction(): number;
  26788. set indexOfRefraction(value: number);
  26789. /**
  26790. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  26791. */
  26792. get invertRefractionY(): boolean;
  26793. set invertRefractionY(value: boolean);
  26794. /**
  26795. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  26796. * Materials half opaque for instance using refraction could benefit from this control.
  26797. */
  26798. get linkRefractionWithTransparency(): boolean;
  26799. set linkRefractionWithTransparency(value: boolean);
  26800. /**
  26801. * If true, the light map contains occlusion information instead of lighting info.
  26802. */
  26803. useLightmapAsShadowmap: boolean;
  26804. /**
  26805. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  26806. */
  26807. useAlphaFromAlbedoTexture: boolean;
  26808. /**
  26809. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  26810. */
  26811. forceAlphaTest: boolean;
  26812. /**
  26813. * Defines the alpha limits in alpha test mode.
  26814. */
  26815. alphaCutOff: number;
  26816. /**
  26817. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  26818. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  26819. */
  26820. useSpecularOverAlpha: boolean;
  26821. /**
  26822. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  26823. */
  26824. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  26825. /**
  26826. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  26827. */
  26828. useRoughnessFromMetallicTextureAlpha: boolean;
  26829. /**
  26830. * Specifies if the metallic texture contains the roughness information in its green channel.
  26831. */
  26832. useRoughnessFromMetallicTextureGreen: boolean;
  26833. /**
  26834. * Specifies if the metallic texture contains the metallness information in its blue channel.
  26835. */
  26836. useMetallnessFromMetallicTextureBlue: boolean;
  26837. /**
  26838. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  26839. */
  26840. useAmbientOcclusionFromMetallicTextureRed: boolean;
  26841. /**
  26842. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  26843. */
  26844. useAmbientInGrayScale: boolean;
  26845. /**
  26846. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  26847. * The material will try to infer what glossiness each pixel should be.
  26848. */
  26849. useAutoMicroSurfaceFromReflectivityMap: boolean;
  26850. /**
  26851. * BJS is using an harcoded light falloff based on a manually sets up range.
  26852. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  26853. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  26854. */
  26855. get usePhysicalLightFalloff(): boolean;
  26856. /**
  26857. * BJS is using an harcoded light falloff based on a manually sets up range.
  26858. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  26859. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  26860. */
  26861. set usePhysicalLightFalloff(value: boolean);
  26862. /**
  26863. * In order to support the falloff compatibility with gltf, a special mode has been added
  26864. * to reproduce the gltf light falloff.
  26865. */
  26866. get useGLTFLightFalloff(): boolean;
  26867. /**
  26868. * In order to support the falloff compatibility with gltf, a special mode has been added
  26869. * to reproduce the gltf light falloff.
  26870. */
  26871. set useGLTFLightFalloff(value: boolean);
  26872. /**
  26873. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  26874. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  26875. */
  26876. useRadianceOverAlpha: boolean;
  26877. /**
  26878. * Allows using an object space normal map (instead of tangent space).
  26879. */
  26880. useObjectSpaceNormalMap: boolean;
  26881. /**
  26882. * Allows using the bump map in parallax mode.
  26883. */
  26884. useParallax: boolean;
  26885. /**
  26886. * Allows using the bump map in parallax occlusion mode.
  26887. */
  26888. useParallaxOcclusion: boolean;
  26889. /**
  26890. * Controls the scale bias of the parallax mode.
  26891. */
  26892. parallaxScaleBias: number;
  26893. /**
  26894. * If sets to true, disables all the lights affecting the material.
  26895. */
  26896. disableLighting: boolean;
  26897. /**
  26898. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  26899. */
  26900. forceIrradianceInFragment: boolean;
  26901. /**
  26902. * Number of Simultaneous lights allowed on the material.
  26903. */
  26904. maxSimultaneousLights: number;
  26905. /**
  26906. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  26907. */
  26908. invertNormalMapX: boolean;
  26909. /**
  26910. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  26911. */
  26912. invertNormalMapY: boolean;
  26913. /**
  26914. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  26915. */
  26916. twoSidedLighting: boolean;
  26917. /**
  26918. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  26919. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  26920. */
  26921. useAlphaFresnel: boolean;
  26922. /**
  26923. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  26924. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  26925. */
  26926. useLinearAlphaFresnel: boolean;
  26927. /**
  26928. * Let user defines the brdf lookup texture used for IBL.
  26929. * A default 8bit version is embedded but you could point at :
  26930. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  26931. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  26932. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  26933. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  26934. */
  26935. environmentBRDFTexture: Nullable<BaseTexture>;
  26936. /**
  26937. * Force normal to face away from face.
  26938. */
  26939. forceNormalForward: boolean;
  26940. /**
  26941. * Enables specular anti aliasing in the PBR shader.
  26942. * It will both interacts on the Geometry for analytical and IBL lighting.
  26943. * It also prefilter the roughness map based on the bump values.
  26944. */
  26945. enableSpecularAntiAliasing: boolean;
  26946. /**
  26947. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  26948. * makes the reflect vector face the model (under horizon).
  26949. */
  26950. useHorizonOcclusion: boolean;
  26951. /**
  26952. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  26953. * too much the area relying on ambient texture to define their ambient occlusion.
  26954. */
  26955. useRadianceOcclusion: boolean;
  26956. /**
  26957. * If set to true, no lighting calculations will be applied.
  26958. */
  26959. unlit: boolean;
  26960. /**
  26961. * Gets the image processing configuration used either in this material.
  26962. */
  26963. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  26964. /**
  26965. * Sets the Default image processing configuration used either in the this material.
  26966. *
  26967. * If sets to null, the scene one is in use.
  26968. */
  26969. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  26970. /**
  26971. * Gets wether the color curves effect is enabled.
  26972. */
  26973. get cameraColorCurvesEnabled(): boolean;
  26974. /**
  26975. * Sets wether the color curves effect is enabled.
  26976. */
  26977. set cameraColorCurvesEnabled(value: boolean);
  26978. /**
  26979. * Gets wether the color grading effect is enabled.
  26980. */
  26981. get cameraColorGradingEnabled(): boolean;
  26982. /**
  26983. * Gets wether the color grading effect is enabled.
  26984. */
  26985. set cameraColorGradingEnabled(value: boolean);
  26986. /**
  26987. * Gets wether tonemapping is enabled or not.
  26988. */
  26989. get cameraToneMappingEnabled(): boolean;
  26990. /**
  26991. * Sets wether tonemapping is enabled or not
  26992. */
  26993. set cameraToneMappingEnabled(value: boolean);
  26994. /**
  26995. * The camera exposure used on this material.
  26996. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  26997. * This corresponds to a photographic exposure.
  26998. */
  26999. get cameraExposure(): number;
  27000. /**
  27001. * The camera exposure used on this material.
  27002. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27003. * This corresponds to a photographic exposure.
  27004. */
  27005. set cameraExposure(value: number);
  27006. /**
  27007. * Gets The camera contrast used on this material.
  27008. */
  27009. get cameraContrast(): number;
  27010. /**
  27011. * Sets The camera contrast used on this material.
  27012. */
  27013. set cameraContrast(value: number);
  27014. /**
  27015. * Gets the Color Grading 2D Lookup Texture.
  27016. */
  27017. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  27018. /**
  27019. * Sets the Color Grading 2D Lookup Texture.
  27020. */
  27021. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  27022. /**
  27023. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27024. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27025. * 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;
  27026. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27027. */
  27028. get cameraColorCurves(): Nullable<ColorCurves>;
  27029. /**
  27030. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27031. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27032. * 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;
  27033. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27034. */
  27035. set cameraColorCurves(value: Nullable<ColorCurves>);
  27036. /**
  27037. * Instantiates a new PBRMaterial instance.
  27038. *
  27039. * @param name The material name
  27040. * @param scene The scene the material will be use in.
  27041. */
  27042. constructor(name: string, scene: Scene);
  27043. /**
  27044. * Returns the name of this material class.
  27045. */
  27046. getClassName(): string;
  27047. /**
  27048. * Makes a duplicate of the current material.
  27049. * @param name - name to use for the new material.
  27050. */
  27051. clone(name: string): PBRMaterial;
  27052. /**
  27053. * Serializes this PBR Material.
  27054. * @returns - An object with the serialized material.
  27055. */
  27056. serialize(): any;
  27057. /**
  27058. * Parses a PBR Material from a serialized object.
  27059. * @param source - Serialized object.
  27060. * @param scene - BJS scene instance.
  27061. * @param rootUrl - url for the scene object
  27062. * @returns - PBRMaterial
  27063. */
  27064. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  27065. }
  27066. }
  27067. declare module BABYLON {
  27068. /** @hidden */
  27069. export var mrtFragmentDeclaration: {
  27070. name: string;
  27071. shader: string;
  27072. };
  27073. }
  27074. declare module BABYLON {
  27075. /** @hidden */
  27076. export var geometryPixelShader: {
  27077. name: string;
  27078. shader: string;
  27079. };
  27080. }
  27081. declare module BABYLON {
  27082. /** @hidden */
  27083. export var geometryVertexShader: {
  27084. name: string;
  27085. shader: string;
  27086. };
  27087. }
  27088. declare module BABYLON {
  27089. /** @hidden */
  27090. interface ISavedTransformationMatrix {
  27091. world: Matrix;
  27092. viewProjection: Matrix;
  27093. }
  27094. /**
  27095. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  27096. */
  27097. export class GeometryBufferRenderer {
  27098. /**
  27099. * Constant used to retrieve the depth + normal texture index in the G-Buffer textures array
  27100. * using getIndex(GeometryBufferRenderer.DEPTHNORMAL_TEXTURE_INDEX)
  27101. */
  27102. static readonly DEPTHNORMAL_TEXTURE_TYPE: number;
  27103. /**
  27104. * Constant used to retrieve the position texture index in the G-Buffer textures array
  27105. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  27106. */
  27107. static readonly POSITION_TEXTURE_TYPE: number;
  27108. /**
  27109. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  27110. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  27111. */
  27112. static readonly VELOCITY_TEXTURE_TYPE: number;
  27113. /**
  27114. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  27115. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  27116. */
  27117. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  27118. /**
  27119. * Dictionary used to store the previous transformation matrices of each rendered mesh
  27120. * in order to compute objects velocities when enableVelocity is set to "true"
  27121. * @hidden
  27122. */
  27123. _previousTransformationMatrices: {
  27124. [index: number]: ISavedTransformationMatrix;
  27125. };
  27126. /**
  27127. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  27128. * in order to compute objects velocities when enableVelocity is set to "true"
  27129. * @hidden
  27130. */
  27131. _previousBonesTransformationMatrices: {
  27132. [index: number]: Float32Array;
  27133. };
  27134. /**
  27135. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  27136. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  27137. */
  27138. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  27139. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  27140. renderTransparentMeshes: boolean;
  27141. private _scene;
  27142. private _resizeObserver;
  27143. private _multiRenderTarget;
  27144. private _ratio;
  27145. private _enablePosition;
  27146. private _enableVelocity;
  27147. private _enableReflectivity;
  27148. private _positionIndex;
  27149. private _velocityIndex;
  27150. private _reflectivityIndex;
  27151. private _depthNormalIndex;
  27152. private _linkedWithPrePass;
  27153. private _prePassRenderer;
  27154. private _attachments;
  27155. protected _effect: Effect;
  27156. protected _cachedDefines: string;
  27157. /**
  27158. * @hidden
  27159. * Sets up internal structures to share outputs with PrePassRenderer
  27160. * This method should only be called by the PrePassRenderer itself
  27161. */
  27162. _linkPrePassRenderer(prePassRenderer: PrePassRenderer): void;
  27163. /**
  27164. * @hidden
  27165. * Separates internal structures from PrePassRenderer so the geometry buffer can now operate by itself.
  27166. * This method should only be called by the PrePassRenderer itself
  27167. */
  27168. _unlinkPrePassRenderer(): void;
  27169. /**
  27170. * @hidden
  27171. * Resets the geometry buffer layout
  27172. */
  27173. _resetLayout(): void;
  27174. /**
  27175. * @hidden
  27176. * Replaces a texture in the geometry buffer renderer
  27177. * Useful when linking textures of the prepass renderer
  27178. */
  27179. _forceTextureType(geometryBufferType: number, index: number): void;
  27180. /**
  27181. * @hidden
  27182. * Sets texture attachments
  27183. * Useful when linking textures of the prepass renderer
  27184. */
  27185. _setAttachments(attachments: number[]): void;
  27186. /**
  27187. * @hidden
  27188. * Replaces the first texture which is hard coded as a depth texture in the geometry buffer
  27189. * Useful when linking textures of the prepass renderer
  27190. */
  27191. _linkInternalTexture(internalTexture: InternalTexture): void;
  27192. /**
  27193. * Gets the render list (meshes to be rendered) used in the G buffer.
  27194. */
  27195. get renderList(): Nullable<AbstractMesh[]>;
  27196. /**
  27197. * Set the render list (meshes to be rendered) used in the G buffer.
  27198. */
  27199. set renderList(meshes: Nullable<AbstractMesh[]>);
  27200. /**
  27201. * Gets wether or not G buffer are supported by the running hardware.
  27202. * This requires draw buffer supports
  27203. */
  27204. get isSupported(): boolean;
  27205. /**
  27206. * Returns the index of the given texture type in the G-Buffer textures array
  27207. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  27208. * @returns the index of the given texture type in the G-Buffer textures array
  27209. */
  27210. getTextureIndex(textureType: number): number;
  27211. /**
  27212. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  27213. */
  27214. get enablePosition(): boolean;
  27215. /**
  27216. * Sets whether or not objects positions are enabled for the G buffer.
  27217. */
  27218. set enablePosition(enable: boolean);
  27219. /**
  27220. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  27221. */
  27222. get enableVelocity(): boolean;
  27223. /**
  27224. * Sets wether or not objects velocities are enabled for the G buffer.
  27225. */
  27226. set enableVelocity(enable: boolean);
  27227. /**
  27228. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  27229. */
  27230. get enableReflectivity(): boolean;
  27231. /**
  27232. * Sets wether or not objects roughness are enabled for the G buffer.
  27233. */
  27234. set enableReflectivity(enable: boolean);
  27235. /**
  27236. * Gets the scene associated with the buffer.
  27237. */
  27238. get scene(): Scene;
  27239. /**
  27240. * Gets the ratio used by the buffer during its creation.
  27241. * How big is the buffer related to the main canvas.
  27242. */
  27243. get ratio(): number;
  27244. /** @hidden */
  27245. static _SceneComponentInitialization: (scene: Scene) => void;
  27246. /**
  27247. * Creates a new G Buffer for the scene
  27248. * @param scene The scene the buffer belongs to
  27249. * @param ratio How big is the buffer related to the main canvas.
  27250. */
  27251. constructor(scene: Scene, ratio?: number);
  27252. /**
  27253. * Checks wether everything is ready to render a submesh to the G buffer.
  27254. * @param subMesh the submesh to check readiness for
  27255. * @param useInstances is the mesh drawn using instance or not
  27256. * @returns true if ready otherwise false
  27257. */
  27258. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  27259. /**
  27260. * Gets the current underlying G Buffer.
  27261. * @returns the buffer
  27262. */
  27263. getGBuffer(): MultiRenderTarget;
  27264. /**
  27265. * Gets the number of samples used to render the buffer (anti aliasing).
  27266. */
  27267. get samples(): number;
  27268. /**
  27269. * Sets the number of samples used to render the buffer (anti aliasing).
  27270. */
  27271. set samples(value: number);
  27272. /**
  27273. * Disposes the renderer and frees up associated resources.
  27274. */
  27275. dispose(): void;
  27276. private _assignRenderTargetIndices;
  27277. protected _createRenderTargets(): void;
  27278. private _copyBonesTransformationMatrices;
  27279. }
  27280. }
  27281. declare module BABYLON {
  27282. /**
  27283. * Renders a pre pass of the scene
  27284. * This means every mesh in the scene will be rendered to a render target texture
  27285. * And then this texture will be composited to the rendering canvas with post processes
  27286. * It is necessary for effects like subsurface scattering or deferred shading
  27287. */
  27288. export class PrePassRenderer {
  27289. /** @hidden */
  27290. static _SceneComponentInitialization: (scene: Scene) => void;
  27291. private _textureFormats;
  27292. /**
  27293. * To save performance, we can excluded skinned meshes from the prepass
  27294. */
  27295. excludedSkinnedMesh: AbstractMesh[];
  27296. /**
  27297. * Force material to be excluded from the prepass
  27298. * Can be useful when `useGeometryBufferFallback` is set to `true`
  27299. * and you don't want a material to show in the effect.
  27300. */
  27301. excludedMaterials: Material[];
  27302. private _textureIndices;
  27303. private _scene;
  27304. private _engine;
  27305. private _isDirty;
  27306. /**
  27307. * Number of textures in the multi render target texture where the scene is directly rendered
  27308. */
  27309. mrtCount: number;
  27310. /**
  27311. * The render target where the scene is directly rendered
  27312. */
  27313. prePassRT: MultiRenderTarget;
  27314. private _multiRenderAttachments;
  27315. private _defaultAttachments;
  27316. private _clearAttachments;
  27317. private _postProcesses;
  27318. private readonly _clearColor;
  27319. /**
  27320. * Image processing post process for composition
  27321. */
  27322. imageProcessingPostProcess: ImageProcessingPostProcess;
  27323. /**
  27324. * Configuration for prepass effects
  27325. */
  27326. private _effectConfigurations;
  27327. private _mrtFormats;
  27328. private _mrtLayout;
  27329. private _enabled;
  27330. /**
  27331. * Indicates if the prepass is enabled
  27332. */
  27333. get enabled(): boolean;
  27334. /**
  27335. * How many samples are used for MSAA of the scene render target
  27336. */
  27337. get samples(): number;
  27338. set samples(n: number);
  27339. private _geometryBuffer;
  27340. private _useGeometryBufferFallback;
  27341. /**
  27342. * Uses the geometry buffer renderer as a fallback for non prepass capable effects
  27343. */
  27344. get useGeometryBufferFallback(): boolean;
  27345. set useGeometryBufferFallback(value: boolean);
  27346. /**
  27347. * Instanciates a prepass renderer
  27348. * @param scene The scene
  27349. */
  27350. constructor(scene: Scene);
  27351. private _initializeAttachments;
  27352. private _createCompositionEffect;
  27353. /**
  27354. * Indicates if rendering a prepass is supported
  27355. */
  27356. get isSupported(): boolean;
  27357. /**
  27358. * Sets the proper output textures to draw in the engine.
  27359. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  27360. * @param subMesh Submesh on which the effect is applied
  27361. */
  27362. bindAttachmentsForEffect(effect: Effect, subMesh: SubMesh): void;
  27363. /**
  27364. * @hidden
  27365. */
  27366. _beforeCameraDraw(): void;
  27367. /**
  27368. * @hidden
  27369. */
  27370. _afterCameraDraw(): void;
  27371. private _checkRTSize;
  27372. private _bindFrameBuffer;
  27373. /**
  27374. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  27375. */
  27376. clear(): void;
  27377. private _setState;
  27378. private _updateGeometryBufferLayout;
  27379. /**
  27380. * Adds an effect configuration to the prepass.
  27381. * If an effect has already been added, it won't add it twice and will return the configuration
  27382. * already present.
  27383. * @param cfg the effect configuration
  27384. * @return the effect configuration now used by the prepass
  27385. */
  27386. addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration;
  27387. /**
  27388. * Returns the index of a texture in the multi render target texture array.
  27389. * @param type Texture type
  27390. * @return The index
  27391. */
  27392. getIndex(type: number): number;
  27393. private _enable;
  27394. private _disable;
  27395. private _resetLayout;
  27396. private _resetPostProcessChain;
  27397. private _bindPostProcessChain;
  27398. /**
  27399. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  27400. */
  27401. markAsDirty(): void;
  27402. /**
  27403. * Enables a texture on the MultiRenderTarget for prepass
  27404. */
  27405. private _enableTextures;
  27406. private _update;
  27407. private _markAllMaterialsAsPrePassDirty;
  27408. /**
  27409. * Disposes the prepass renderer.
  27410. */
  27411. dispose(): void;
  27412. }
  27413. }
  27414. declare module BABYLON {
  27415. /**
  27416. * Size options for a post process
  27417. */
  27418. export type PostProcessOptions = {
  27419. width: number;
  27420. height: number;
  27421. };
  27422. /**
  27423. * PostProcess can be used to apply a shader to a texture after it has been rendered
  27424. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  27425. */
  27426. export class PostProcess {
  27427. /**
  27428. * Gets or sets the unique id of the post process
  27429. */
  27430. uniqueId: number;
  27431. /** Name of the PostProcess. */
  27432. name: string;
  27433. /**
  27434. * Width of the texture to apply the post process on
  27435. */
  27436. width: number;
  27437. /**
  27438. * Height of the texture to apply the post process on
  27439. */
  27440. height: number;
  27441. /**
  27442. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  27443. */
  27444. nodeMaterialSource: Nullable<NodeMaterial>;
  27445. /**
  27446. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  27447. * @hidden
  27448. */
  27449. _outputTexture: Nullable<InternalTexture>;
  27450. /**
  27451. * Sampling mode used by the shader
  27452. * See https://doc.babylonjs.com/classes/3.1/texture
  27453. */
  27454. renderTargetSamplingMode: number;
  27455. /**
  27456. * Clear color to use when screen clearing
  27457. */
  27458. clearColor: Color4;
  27459. /**
  27460. * If the buffer needs to be cleared before applying the post process. (default: true)
  27461. * Should be set to false if shader will overwrite all previous pixels.
  27462. */
  27463. autoClear: boolean;
  27464. /**
  27465. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  27466. */
  27467. alphaMode: number;
  27468. /**
  27469. * Sets the setAlphaBlendConstants of the babylon engine
  27470. */
  27471. alphaConstants: Color4;
  27472. /**
  27473. * Animations to be used for the post processing
  27474. */
  27475. animations: Animation[];
  27476. /**
  27477. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  27478. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  27479. */
  27480. enablePixelPerfectMode: boolean;
  27481. /**
  27482. * Force the postprocess to be applied without taking in account viewport
  27483. */
  27484. forceFullscreenViewport: boolean;
  27485. /**
  27486. * List of inspectable custom properties (used by the Inspector)
  27487. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  27488. */
  27489. inspectableCustomProperties: IInspectable[];
  27490. /**
  27491. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  27492. *
  27493. * | Value | Type | Description |
  27494. * | ----- | ----------------------------------- | ----------- |
  27495. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  27496. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  27497. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  27498. *
  27499. */
  27500. scaleMode: number;
  27501. /**
  27502. * Force textures to be a power of two (default: false)
  27503. */
  27504. alwaysForcePOT: boolean;
  27505. private _samples;
  27506. /**
  27507. * Number of sample textures (default: 1)
  27508. */
  27509. get samples(): number;
  27510. set samples(n: number);
  27511. /**
  27512. * Modify the scale of the post process to be the same as the viewport (default: false)
  27513. */
  27514. adaptScaleToCurrentViewport: boolean;
  27515. private _camera;
  27516. protected _scene: Scene;
  27517. private _engine;
  27518. private _options;
  27519. private _reusable;
  27520. private _textureType;
  27521. private _textureFormat;
  27522. /**
  27523. * Smart array of input and output textures for the post process.
  27524. * @hidden
  27525. */
  27526. _textures: SmartArray<InternalTexture>;
  27527. /**
  27528. * The index in _textures that corresponds to the output texture.
  27529. * @hidden
  27530. */
  27531. _currentRenderTextureInd: number;
  27532. private _effect;
  27533. private _samplers;
  27534. private _fragmentUrl;
  27535. private _vertexUrl;
  27536. private _parameters;
  27537. private _scaleRatio;
  27538. protected _indexParameters: any;
  27539. private _shareOutputWithPostProcess;
  27540. private _texelSize;
  27541. private _forcedOutputTexture;
  27542. /**
  27543. * Prepass configuration in case this post process needs a texture from prepass
  27544. * @hidden
  27545. */
  27546. _prePassEffectConfiguration: PrePassEffectConfiguration;
  27547. /**
  27548. * Returns the fragment url or shader name used in the post process.
  27549. * @returns the fragment url or name in the shader store.
  27550. */
  27551. getEffectName(): string;
  27552. /**
  27553. * An event triggered when the postprocess is activated.
  27554. */
  27555. onActivateObservable: Observable<Camera>;
  27556. private _onActivateObserver;
  27557. /**
  27558. * A function that is added to the onActivateObservable
  27559. */
  27560. set onActivate(callback: Nullable<(camera: Camera) => void>);
  27561. /**
  27562. * An event triggered when the postprocess changes its size.
  27563. */
  27564. onSizeChangedObservable: Observable<PostProcess>;
  27565. private _onSizeChangedObserver;
  27566. /**
  27567. * A function that is added to the onSizeChangedObservable
  27568. */
  27569. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  27570. /**
  27571. * An event triggered when the postprocess applies its effect.
  27572. */
  27573. onApplyObservable: Observable<Effect>;
  27574. private _onApplyObserver;
  27575. /**
  27576. * A function that is added to the onApplyObservable
  27577. */
  27578. set onApply(callback: (effect: Effect) => void);
  27579. /**
  27580. * An event triggered before rendering the postprocess
  27581. */
  27582. onBeforeRenderObservable: Observable<Effect>;
  27583. private _onBeforeRenderObserver;
  27584. /**
  27585. * A function that is added to the onBeforeRenderObservable
  27586. */
  27587. set onBeforeRender(callback: (effect: Effect) => void);
  27588. /**
  27589. * An event triggered after rendering the postprocess
  27590. */
  27591. onAfterRenderObservable: Observable<Effect>;
  27592. private _onAfterRenderObserver;
  27593. /**
  27594. * A function that is added to the onAfterRenderObservable
  27595. */
  27596. set onAfterRender(callback: (efect: Effect) => void);
  27597. /**
  27598. * 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
  27599. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  27600. */
  27601. get inputTexture(): InternalTexture;
  27602. set inputTexture(value: InternalTexture);
  27603. /**
  27604. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  27605. * the only way to unset it is to use this function to restore its internal state
  27606. */
  27607. restoreDefaultInputTexture(): void;
  27608. /**
  27609. * Gets the camera which post process is applied to.
  27610. * @returns The camera the post process is applied to.
  27611. */
  27612. getCamera(): Camera;
  27613. /**
  27614. * Gets the texel size of the postprocess.
  27615. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  27616. */
  27617. get texelSize(): Vector2;
  27618. /**
  27619. * Creates a new instance PostProcess
  27620. * @param name The name of the PostProcess.
  27621. * @param fragmentUrl The url of the fragment shader to be used.
  27622. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  27623. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  27624. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  27625. * @param camera The camera to apply the render pass to.
  27626. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27627. * @param engine The engine which the post process will be applied. (default: current engine)
  27628. * @param reusable If the post process can be reused on the same frame. (default: false)
  27629. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  27630. * @param textureType Type of textures used when performing the post process. (default: 0)
  27631. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  27632. * @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
  27633. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  27634. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  27635. */
  27636. 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);
  27637. /**
  27638. * Gets a string identifying the name of the class
  27639. * @returns "PostProcess" string
  27640. */
  27641. getClassName(): string;
  27642. /**
  27643. * Gets the engine which this post process belongs to.
  27644. * @returns The engine the post process was enabled with.
  27645. */
  27646. getEngine(): Engine;
  27647. /**
  27648. * The effect that is created when initializing the post process.
  27649. * @returns The created effect corresponding the the postprocess.
  27650. */
  27651. getEffect(): Effect;
  27652. /**
  27653. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  27654. * @param postProcess The post process to share the output with.
  27655. * @returns This post process.
  27656. */
  27657. shareOutputWith(postProcess: PostProcess): PostProcess;
  27658. /**
  27659. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  27660. * This should be called if the post process that shares output with this post process is disabled/disposed.
  27661. */
  27662. useOwnOutput(): void;
  27663. /**
  27664. * Updates the effect with the current post process compile time values and recompiles the shader.
  27665. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  27666. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  27667. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  27668. * @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
  27669. * @param onCompiled Called when the shader has been compiled.
  27670. * @param onError Called if there is an error when compiling a shader.
  27671. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  27672. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  27673. */
  27674. 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;
  27675. /**
  27676. * The post process is reusable if it can be used multiple times within one frame.
  27677. * @returns If the post process is reusable
  27678. */
  27679. isReusable(): boolean;
  27680. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  27681. markTextureDirty(): void;
  27682. /**
  27683. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  27684. * 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.
  27685. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  27686. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  27687. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  27688. * @returns The target texture that was bound to be written to.
  27689. */
  27690. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  27691. /**
  27692. * If the post process is supported.
  27693. */
  27694. get isSupported(): boolean;
  27695. /**
  27696. * The aspect ratio of the output texture.
  27697. */
  27698. get aspectRatio(): number;
  27699. /**
  27700. * Get a value indicating if the post-process is ready to be used
  27701. * @returns true if the post-process is ready (shader is compiled)
  27702. */
  27703. isReady(): boolean;
  27704. /**
  27705. * Binds all textures and uniforms to the shader, this will be run on every pass.
  27706. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  27707. */
  27708. apply(): Nullable<Effect>;
  27709. private _disposeTextures;
  27710. /**
  27711. * Sets the required values to the prepass renderer.
  27712. * @param prePassRenderer defines the prepass renderer to setup.
  27713. * @returns true if the pre pass is needed.
  27714. */
  27715. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  27716. /**
  27717. * Disposes the post process.
  27718. * @param camera The camera to dispose the post process on.
  27719. */
  27720. dispose(camera?: Camera): void;
  27721. /**
  27722. * Serializes the particle system to a JSON object
  27723. * @returns the JSON object
  27724. */
  27725. serialize(): any;
  27726. /**
  27727. * Creates a material from parsed material data
  27728. * @param parsedPostProcess defines parsed post process data
  27729. * @param scene defines the hosting scene
  27730. * @param rootUrl defines the root URL to use to load textures
  27731. * @returns a new post process
  27732. */
  27733. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  27734. }
  27735. }
  27736. declare module BABYLON {
  27737. /** @hidden */
  27738. export var kernelBlurVaryingDeclaration: {
  27739. name: string;
  27740. shader: string;
  27741. };
  27742. }
  27743. declare module BABYLON {
  27744. /** @hidden */
  27745. export var kernelBlurFragment: {
  27746. name: string;
  27747. shader: string;
  27748. };
  27749. }
  27750. declare module BABYLON {
  27751. /** @hidden */
  27752. export var kernelBlurFragment2: {
  27753. name: string;
  27754. shader: string;
  27755. };
  27756. }
  27757. declare module BABYLON {
  27758. /** @hidden */
  27759. export var kernelBlurPixelShader: {
  27760. name: string;
  27761. shader: string;
  27762. };
  27763. }
  27764. declare module BABYLON {
  27765. /** @hidden */
  27766. export var kernelBlurVertex: {
  27767. name: string;
  27768. shader: string;
  27769. };
  27770. }
  27771. declare module BABYLON {
  27772. /** @hidden */
  27773. export var kernelBlurVertexShader: {
  27774. name: string;
  27775. shader: string;
  27776. };
  27777. }
  27778. declare module BABYLON {
  27779. /**
  27780. * The Blur Post Process which blurs an image based on a kernel and direction.
  27781. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  27782. */
  27783. export class BlurPostProcess extends PostProcess {
  27784. private blockCompilation;
  27785. protected _kernel: number;
  27786. protected _idealKernel: number;
  27787. protected _packedFloat: boolean;
  27788. private _staticDefines;
  27789. /** The direction in which to blur the image. */
  27790. direction: Vector2;
  27791. /**
  27792. * Sets the length in pixels of the blur sample region
  27793. */
  27794. set kernel(v: number);
  27795. /**
  27796. * Gets the length in pixels of the blur sample region
  27797. */
  27798. get kernel(): number;
  27799. /**
  27800. * Sets wether or not the blur needs to unpack/repack floats
  27801. */
  27802. set packedFloat(v: boolean);
  27803. /**
  27804. * Gets wether or not the blur is unpacking/repacking floats
  27805. */
  27806. get packedFloat(): boolean;
  27807. /**
  27808. * Gets a string identifying the name of the class
  27809. * @returns "BlurPostProcess" string
  27810. */
  27811. getClassName(): string;
  27812. /**
  27813. * Creates a new instance BlurPostProcess
  27814. * @param name The name of the effect.
  27815. * @param direction The direction in which to blur the image.
  27816. * @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.
  27817. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  27818. * @param camera The camera to apply the render pass to.
  27819. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  27820. * @param engine The engine which the post process will be applied. (default: current engine)
  27821. * @param reusable If the post process can be reused on the same frame. (default: false)
  27822. * @param textureType Type of textures used when performing the post process. (default: 0)
  27823. * @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)
  27824. */
  27825. 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);
  27826. /**
  27827. * Updates the effect with the current post process compile time values and recompiles the shader.
  27828. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  27829. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  27830. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  27831. * @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
  27832. * @param onCompiled Called when the shader has been compiled.
  27833. * @param onError Called if there is an error when compiling a shader.
  27834. */
  27835. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  27836. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  27837. /**
  27838. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  27839. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  27840. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  27841. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  27842. * The gaps between physical kernels are compensated for in the weighting of the samples
  27843. * @param idealKernel Ideal blur kernel.
  27844. * @return Nearest best kernel.
  27845. */
  27846. protected _nearestBestKernel(idealKernel: number): number;
  27847. /**
  27848. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  27849. * @param x The point on the Gaussian distribution to sample.
  27850. * @return the value of the Gaussian function at x.
  27851. */
  27852. protected _gaussianWeight(x: number): number;
  27853. /**
  27854. * Generates a string that can be used as a floating point number in GLSL.
  27855. * @param x Value to print.
  27856. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  27857. * @return GLSL float string.
  27858. */
  27859. protected _glslFloat(x: number, decimalFigures?: number): string;
  27860. /** @hidden */
  27861. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  27862. }
  27863. }
  27864. declare module BABYLON {
  27865. /**
  27866. * Mirror texture can be used to simulate the view from a mirror in a scene.
  27867. * It will dynamically be rendered every frame to adapt to the camera point of view.
  27868. * You can then easily use it as a reflectionTexture on a flat surface.
  27869. * In case the surface is not a plane, please consider relying on reflection probes.
  27870. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  27871. */
  27872. export class MirrorTexture extends RenderTargetTexture {
  27873. private scene;
  27874. /**
  27875. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  27876. * 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.
  27877. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  27878. */
  27879. mirrorPlane: Plane;
  27880. /**
  27881. * Define the blur ratio used to blur the reflection if needed.
  27882. */
  27883. set blurRatio(value: number);
  27884. get blurRatio(): number;
  27885. /**
  27886. * Define the adaptive blur kernel used to blur the reflection if needed.
  27887. * This will autocompute the closest best match for the `blurKernel`
  27888. */
  27889. set adaptiveBlurKernel(value: number);
  27890. /**
  27891. * Define the blur kernel used to blur the reflection if needed.
  27892. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  27893. */
  27894. set blurKernel(value: number);
  27895. /**
  27896. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  27897. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  27898. */
  27899. set blurKernelX(value: number);
  27900. get blurKernelX(): number;
  27901. /**
  27902. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  27903. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  27904. */
  27905. set blurKernelY(value: number);
  27906. get blurKernelY(): number;
  27907. private _autoComputeBlurKernel;
  27908. protected _onRatioRescale(): void;
  27909. private _updateGammaSpace;
  27910. private _imageProcessingConfigChangeObserver;
  27911. private _transformMatrix;
  27912. private _mirrorMatrix;
  27913. private _savedViewMatrix;
  27914. private _blurX;
  27915. private _blurY;
  27916. private _adaptiveBlurKernel;
  27917. private _blurKernelX;
  27918. private _blurKernelY;
  27919. private _blurRatio;
  27920. /**
  27921. * Instantiates a Mirror Texture.
  27922. * Mirror texture can be used to simulate the view from a mirror in a scene.
  27923. * It will dynamically be rendered every frame to adapt to the camera point of view.
  27924. * You can then easily use it as a reflectionTexture on a flat surface.
  27925. * In case the surface is not a plane, please consider relying on reflection probes.
  27926. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  27927. * @param name
  27928. * @param size
  27929. * @param scene
  27930. * @param generateMipMaps
  27931. * @param type
  27932. * @param samplingMode
  27933. * @param generateDepthBuffer
  27934. */
  27935. constructor(name: string, size: number | {
  27936. width: number;
  27937. height: number;
  27938. } | {
  27939. ratio: number;
  27940. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  27941. private _preparePostProcesses;
  27942. /**
  27943. * Clone the mirror texture.
  27944. * @returns the cloned texture
  27945. */
  27946. clone(): MirrorTexture;
  27947. /**
  27948. * Serialize the texture to a JSON representation you could use in Parse later on
  27949. * @returns the serialized JSON representation
  27950. */
  27951. serialize(): any;
  27952. /**
  27953. * Dispose the texture and release its associated resources.
  27954. */
  27955. dispose(): void;
  27956. }
  27957. }
  27958. declare module BABYLON {
  27959. /**
  27960. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  27961. * @see https://doc.babylonjs.com/babylon101/materials#texture
  27962. */
  27963. export class Texture extends BaseTexture {
  27964. /**
  27965. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  27966. */
  27967. static SerializeBuffers: boolean;
  27968. /** @hidden */
  27969. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  27970. /** @hidden */
  27971. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  27972. /** @hidden */
  27973. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  27974. /** nearest is mag = nearest and min = nearest and mip = linear */
  27975. static readonly NEAREST_SAMPLINGMODE: number;
  27976. /** nearest is mag = nearest and min = nearest and mip = linear */
  27977. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  27978. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27979. static readonly BILINEAR_SAMPLINGMODE: number;
  27980. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27981. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  27982. /** Trilinear is mag = linear and min = linear and mip = linear */
  27983. static readonly TRILINEAR_SAMPLINGMODE: number;
  27984. /** Trilinear is mag = linear and min = linear and mip = linear */
  27985. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  27986. /** mag = nearest and min = nearest and mip = nearest */
  27987. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  27988. /** mag = nearest and min = linear and mip = nearest */
  27989. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  27990. /** mag = nearest and min = linear and mip = linear */
  27991. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  27992. /** mag = nearest and min = linear and mip = none */
  27993. static readonly NEAREST_LINEAR: number;
  27994. /** mag = nearest and min = nearest and mip = none */
  27995. static readonly NEAREST_NEAREST: number;
  27996. /** mag = linear and min = nearest and mip = nearest */
  27997. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  27998. /** mag = linear and min = nearest and mip = linear */
  27999. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  28000. /** mag = linear and min = linear and mip = none */
  28001. static readonly LINEAR_LINEAR: number;
  28002. /** mag = linear and min = nearest and mip = none */
  28003. static readonly LINEAR_NEAREST: number;
  28004. /** Explicit coordinates mode */
  28005. static readonly EXPLICIT_MODE: number;
  28006. /** Spherical coordinates mode */
  28007. static readonly SPHERICAL_MODE: number;
  28008. /** Planar coordinates mode */
  28009. static readonly PLANAR_MODE: number;
  28010. /** Cubic coordinates mode */
  28011. static readonly CUBIC_MODE: number;
  28012. /** Projection coordinates mode */
  28013. static readonly PROJECTION_MODE: number;
  28014. /** Inverse Cubic coordinates mode */
  28015. static readonly SKYBOX_MODE: number;
  28016. /** Inverse Cubic coordinates mode */
  28017. static readonly INVCUBIC_MODE: number;
  28018. /** Equirectangular coordinates mode */
  28019. static readonly EQUIRECTANGULAR_MODE: number;
  28020. /** Equirectangular Fixed coordinates mode */
  28021. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  28022. /** Equirectangular Fixed Mirrored coordinates mode */
  28023. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  28024. /** Texture is not repeating outside of 0..1 UVs */
  28025. static readonly CLAMP_ADDRESSMODE: number;
  28026. /** Texture is repeating outside of 0..1 UVs */
  28027. static readonly WRAP_ADDRESSMODE: number;
  28028. /** Texture is repeating and mirrored */
  28029. static readonly MIRROR_ADDRESSMODE: number;
  28030. /**
  28031. * 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
  28032. */
  28033. static UseSerializedUrlIfAny: boolean;
  28034. /**
  28035. * Define the url of the texture.
  28036. */
  28037. url: Nullable<string>;
  28038. /**
  28039. * Define an offset on the texture to offset the u coordinates of the UVs
  28040. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  28041. */
  28042. uOffset: number;
  28043. /**
  28044. * Define an offset on the texture to offset the v coordinates of the UVs
  28045. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  28046. */
  28047. vOffset: number;
  28048. /**
  28049. * Define an offset on the texture to scale the u coordinates of the UVs
  28050. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  28051. */
  28052. uScale: number;
  28053. /**
  28054. * Define an offset on the texture to scale the v coordinates of the UVs
  28055. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  28056. */
  28057. vScale: number;
  28058. /**
  28059. * Define an offset on the texture to rotate around the u coordinates of the UVs
  28060. * @see https://doc.babylonjs.com/how_to/more_materials
  28061. */
  28062. uAng: number;
  28063. /**
  28064. * Define an offset on the texture to rotate around the v coordinates of the UVs
  28065. * @see https://doc.babylonjs.com/how_to/more_materials
  28066. */
  28067. vAng: number;
  28068. /**
  28069. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  28070. * @see https://doc.babylonjs.com/how_to/more_materials
  28071. */
  28072. wAng: number;
  28073. /**
  28074. * Defines the center of rotation (U)
  28075. */
  28076. uRotationCenter: number;
  28077. /**
  28078. * Defines the center of rotation (V)
  28079. */
  28080. vRotationCenter: number;
  28081. /**
  28082. * Defines the center of rotation (W)
  28083. */
  28084. wRotationCenter: number;
  28085. /**
  28086. * Sets this property to true to avoid deformations when rotating the texture with non-uniform scaling
  28087. */
  28088. homogeneousRotationInUVTransform: boolean;
  28089. /**
  28090. * Are mip maps generated for this texture or not.
  28091. */
  28092. get noMipmap(): boolean;
  28093. /**
  28094. * List of inspectable custom properties (used by the Inspector)
  28095. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  28096. */
  28097. inspectableCustomProperties: Nullable<IInspectable[]>;
  28098. private _noMipmap;
  28099. /** @hidden */
  28100. _invertY: boolean;
  28101. private _rowGenerationMatrix;
  28102. private _cachedTextureMatrix;
  28103. private _projectionModeMatrix;
  28104. private _t0;
  28105. private _t1;
  28106. private _t2;
  28107. private _cachedUOffset;
  28108. private _cachedVOffset;
  28109. private _cachedUScale;
  28110. private _cachedVScale;
  28111. private _cachedUAng;
  28112. private _cachedVAng;
  28113. private _cachedWAng;
  28114. private _cachedProjectionMatrixId;
  28115. private _cachedURotationCenter;
  28116. private _cachedVRotationCenter;
  28117. private _cachedWRotationCenter;
  28118. private _cachedHomogeneousRotationInUVTransform;
  28119. private _cachedCoordinatesMode;
  28120. /** @hidden */
  28121. protected _initialSamplingMode: number;
  28122. /** @hidden */
  28123. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  28124. private _deleteBuffer;
  28125. protected _format: Nullable<number>;
  28126. private _delayedOnLoad;
  28127. private _delayedOnError;
  28128. private _mimeType?;
  28129. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  28130. get mimeType(): string | undefined;
  28131. /**
  28132. * Observable triggered once the texture has been loaded.
  28133. */
  28134. onLoadObservable: Observable<Texture>;
  28135. protected _isBlocking: boolean;
  28136. /**
  28137. * Is the texture preventing material to render while loading.
  28138. * If false, a default texture will be used instead of the loading one during the preparation step.
  28139. */
  28140. set isBlocking(value: boolean);
  28141. get isBlocking(): boolean;
  28142. /**
  28143. * Get the current sampling mode associated with the texture.
  28144. */
  28145. get samplingMode(): number;
  28146. /**
  28147. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  28148. */
  28149. get invertY(): boolean;
  28150. /**
  28151. * Instantiates a new texture.
  28152. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  28153. * @see https://doc.babylonjs.com/babylon101/materials#texture
  28154. * @param url defines the url of the picture to load as a texture
  28155. * @param sceneOrEngine defines the scene or engine the texture will belong to
  28156. * @param noMipmap defines if the texture will require mip maps or not
  28157. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  28158. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  28159. * @param onLoad defines a callback triggered when the texture has been loaded
  28160. * @param onError defines a callback triggered when an error occurred during the loading session
  28161. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  28162. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  28163. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  28164. * @param mimeType defines an optional mime type information
  28165. */
  28166. 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);
  28167. /**
  28168. * Update the url (and optional buffer) of this texture if url was null during construction.
  28169. * @param url the url of the texture
  28170. * @param buffer the buffer of the texture (defaults to null)
  28171. * @param onLoad callback called when the texture is loaded (defaults to null)
  28172. */
  28173. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  28174. /**
  28175. * Finish the loading sequence of a texture flagged as delayed load.
  28176. * @hidden
  28177. */
  28178. delayLoad(): void;
  28179. private _prepareRowForTextureGeneration;
  28180. /**
  28181. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  28182. * @returns the transform matrix of the texture.
  28183. */
  28184. getTextureMatrix(uBase?: number): Matrix;
  28185. /**
  28186. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  28187. * @returns The reflection texture transform
  28188. */
  28189. getReflectionTextureMatrix(): Matrix;
  28190. /**
  28191. * Clones the texture.
  28192. * @returns the cloned texture
  28193. */
  28194. clone(): Texture;
  28195. /**
  28196. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  28197. * @returns The JSON representation of the texture
  28198. */
  28199. serialize(): any;
  28200. /**
  28201. * Get the current class name of the texture useful for serialization or dynamic coding.
  28202. * @returns "Texture"
  28203. */
  28204. getClassName(): string;
  28205. /**
  28206. * Dispose the texture and release its associated resources.
  28207. */
  28208. dispose(): void;
  28209. /**
  28210. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  28211. * @param parsedTexture Define the JSON representation of the texture
  28212. * @param scene Define the scene the parsed texture should be instantiated in
  28213. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  28214. * @returns The parsed texture if successful
  28215. */
  28216. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  28217. /**
  28218. * Creates a texture from its base 64 representation.
  28219. * @param data Define the base64 payload without the data: prefix
  28220. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  28221. * @param scene Define the scene the texture should belong to
  28222. * @param noMipmap Forces the texture to not create mip map information if true
  28223. * @param invertY define if the texture needs to be inverted on the y axis during loading
  28224. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  28225. * @param onLoad define a callback triggered when the texture has been loaded
  28226. * @param onError define a callback triggered when an error occurred during the loading session
  28227. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  28228. * @returns the created texture
  28229. */
  28230. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  28231. /**
  28232. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  28233. * @param data Define the base64 payload without the data: prefix
  28234. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  28235. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  28236. * @param scene Define the scene the texture should belong to
  28237. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  28238. * @param noMipmap Forces the texture to not create mip map information if true
  28239. * @param invertY define if the texture needs to be inverted on the y axis during loading
  28240. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  28241. * @param onLoad define a callback triggered when the texture has been loaded
  28242. * @param onError define a callback triggered when an error occurred during the loading session
  28243. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  28244. * @returns the created texture
  28245. */
  28246. 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;
  28247. }
  28248. }
  28249. declare module BABYLON {
  28250. /**
  28251. * PostProcessManager is used to manage one or more post processes or post process pipelines
  28252. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  28253. */
  28254. export class PostProcessManager {
  28255. private _scene;
  28256. private _indexBuffer;
  28257. private _vertexBuffers;
  28258. /**
  28259. * Creates a new instance PostProcess
  28260. * @param scene The scene that the post process is associated with.
  28261. */
  28262. constructor(scene: Scene);
  28263. private _prepareBuffers;
  28264. private _buildIndexBuffer;
  28265. /**
  28266. * Rebuilds the vertex buffers of the manager.
  28267. * @hidden
  28268. */
  28269. _rebuild(): void;
  28270. /**
  28271. * Prepares a frame to be run through a post process.
  28272. * @param sourceTexture The input texture to the post procesess. (default: null)
  28273. * @param postProcesses An array of post processes to be run. (default: null)
  28274. * @returns True if the post processes were able to be run.
  28275. * @hidden
  28276. */
  28277. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  28278. /**
  28279. * Manually render a set of post processes to a texture.
  28280. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  28281. * @param postProcesses An array of post processes to be run.
  28282. * @param targetTexture The target texture to render to.
  28283. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  28284. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  28285. * @param lodLevel defines which lod of the texture to render to
  28286. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  28287. */
  28288. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  28289. /**
  28290. * Finalize the result of the output of the postprocesses.
  28291. * @param doNotPresent If true the result will not be displayed to the screen.
  28292. * @param targetTexture The target texture to render to.
  28293. * @param faceIndex The index of the face to bind the target texture to.
  28294. * @param postProcesses The array of post processes to render.
  28295. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  28296. * @hidden
  28297. */
  28298. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  28299. /**
  28300. * Disposes of the post process manager.
  28301. */
  28302. dispose(): void;
  28303. }
  28304. }
  28305. declare module BABYLON {
  28306. /**
  28307. * This Helps creating a texture that will be created from a camera in your scene.
  28308. * It is basically a dynamic texture that could be used to create special effects for instance.
  28309. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  28310. */
  28311. export class RenderTargetTexture extends Texture {
  28312. /**
  28313. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  28314. */
  28315. static readonly REFRESHRATE_RENDER_ONCE: number;
  28316. /**
  28317. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  28318. */
  28319. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  28320. /**
  28321. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  28322. * the central point of your effect and can save a lot of performances.
  28323. */
  28324. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  28325. /**
  28326. * Use this predicate to dynamically define the list of mesh you want to render.
  28327. * If set, the renderList property will be overwritten.
  28328. */
  28329. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  28330. private _renderList;
  28331. /**
  28332. * Use this list to define the list of mesh you want to render.
  28333. */
  28334. get renderList(): Nullable<Array<AbstractMesh>>;
  28335. set renderList(value: Nullable<Array<AbstractMesh>>);
  28336. /**
  28337. * Use this function to overload the renderList array at rendering time.
  28338. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  28339. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  28340. * the cube (if the RTT is a cube, else layerOrFace=0).
  28341. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  28342. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  28343. * hold dummy elements!
  28344. */
  28345. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  28346. private _hookArray;
  28347. /**
  28348. * Define if particles should be rendered in your texture.
  28349. */
  28350. renderParticles: boolean;
  28351. /**
  28352. * Define if sprites should be rendered in your texture.
  28353. */
  28354. renderSprites: boolean;
  28355. /**
  28356. * Define the camera used to render the texture.
  28357. */
  28358. activeCamera: Nullable<Camera>;
  28359. /**
  28360. * Override the mesh isReady function with your own one.
  28361. */
  28362. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  28363. /**
  28364. * Override the render function of the texture with your own one.
  28365. */
  28366. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  28367. /**
  28368. * Define if camera post processes should be use while rendering the texture.
  28369. */
  28370. useCameraPostProcesses: boolean;
  28371. /**
  28372. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  28373. */
  28374. ignoreCameraViewport: boolean;
  28375. private _postProcessManager;
  28376. private _postProcesses;
  28377. private _resizeObserver;
  28378. /**
  28379. * An event triggered when the texture is unbind.
  28380. */
  28381. onBeforeBindObservable: Observable<RenderTargetTexture>;
  28382. /**
  28383. * An event triggered when the texture is unbind.
  28384. */
  28385. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  28386. private _onAfterUnbindObserver;
  28387. /**
  28388. * Set a after unbind callback in the texture.
  28389. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  28390. */
  28391. set onAfterUnbind(callback: () => void);
  28392. /**
  28393. * An event triggered before rendering the texture
  28394. */
  28395. onBeforeRenderObservable: Observable<number>;
  28396. private _onBeforeRenderObserver;
  28397. /**
  28398. * Set a before render callback in the texture.
  28399. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  28400. */
  28401. set onBeforeRender(callback: (faceIndex: number) => void);
  28402. /**
  28403. * An event triggered after rendering the texture
  28404. */
  28405. onAfterRenderObservable: Observable<number>;
  28406. private _onAfterRenderObserver;
  28407. /**
  28408. * Set a after render callback in the texture.
  28409. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  28410. */
  28411. set onAfterRender(callback: (faceIndex: number) => void);
  28412. /**
  28413. * An event triggered after the texture clear
  28414. */
  28415. onClearObservable: Observable<Engine>;
  28416. private _onClearObserver;
  28417. /**
  28418. * Set a clear callback in the texture.
  28419. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  28420. */
  28421. set onClear(callback: (Engine: Engine) => void);
  28422. /**
  28423. * An event triggered when the texture is resized.
  28424. */
  28425. onResizeObservable: Observable<RenderTargetTexture>;
  28426. /**
  28427. * Define the clear color of the Render Target if it should be different from the scene.
  28428. */
  28429. clearColor: Color4;
  28430. protected _size: number | {
  28431. width: number;
  28432. height: number;
  28433. layers?: number;
  28434. };
  28435. protected _initialSizeParameter: number | {
  28436. width: number;
  28437. height: number;
  28438. } | {
  28439. ratio: number;
  28440. };
  28441. protected _sizeRatio: Nullable<number>;
  28442. /** @hidden */
  28443. _generateMipMaps: boolean;
  28444. protected _renderingManager: RenderingManager;
  28445. /** @hidden */
  28446. _waitingRenderList?: string[];
  28447. protected _doNotChangeAspectRatio: boolean;
  28448. protected _currentRefreshId: number;
  28449. protected _refreshRate: number;
  28450. protected _textureMatrix: Matrix;
  28451. protected _samples: number;
  28452. protected _renderTargetOptions: RenderTargetCreationOptions;
  28453. /**
  28454. * Gets render target creation options that were used.
  28455. */
  28456. get renderTargetOptions(): RenderTargetCreationOptions;
  28457. protected _onRatioRescale(): void;
  28458. /**
  28459. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  28460. * It must define where the camera used to render the texture is set
  28461. */
  28462. boundingBoxPosition: Vector3;
  28463. private _boundingBoxSize;
  28464. /**
  28465. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  28466. * When defined, the cubemap will switch to local mode
  28467. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  28468. * @example https://www.babylonjs-playground.com/#RNASML
  28469. */
  28470. set boundingBoxSize(value: Vector3);
  28471. get boundingBoxSize(): Vector3;
  28472. /**
  28473. * In case the RTT has been created with a depth texture, get the associated
  28474. * depth texture.
  28475. * Otherwise, return null.
  28476. */
  28477. get depthStencilTexture(): Nullable<InternalTexture>;
  28478. /**
  28479. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  28480. * or used a shadow, depth texture...
  28481. * @param name The friendly name of the texture
  28482. * @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)
  28483. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  28484. * @param generateMipMaps True if mip maps need to be generated after render.
  28485. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  28486. * @param type The type of the buffer in the RTT (int, half float, float...)
  28487. * @param isCube True if a cube texture needs to be created
  28488. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  28489. * @param generateDepthBuffer True to generate a depth buffer
  28490. * @param generateStencilBuffer True to generate a stencil buffer
  28491. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  28492. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  28493. * @param delayAllocation if the texture allocation should be delayed (default: false)
  28494. */
  28495. constructor(name: string, size: number | {
  28496. width: number;
  28497. height: number;
  28498. layers?: number;
  28499. } | {
  28500. ratio: number;
  28501. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  28502. /**
  28503. * Creates a depth stencil texture.
  28504. * This is only available in WebGL 2 or with the depth texture extension available.
  28505. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  28506. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  28507. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  28508. */
  28509. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  28510. private _processSizeParameter;
  28511. /**
  28512. * Define the number of samples to use in case of MSAA.
  28513. * It defaults to one meaning no MSAA has been enabled.
  28514. */
  28515. get samples(): number;
  28516. set samples(value: number);
  28517. /**
  28518. * Resets the refresh counter of the texture and start bak from scratch.
  28519. * Could be useful to regenerate the texture if it is setup to render only once.
  28520. */
  28521. resetRefreshCounter(): void;
  28522. /**
  28523. * Define the refresh rate of the texture or the rendering frequency.
  28524. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  28525. */
  28526. get refreshRate(): number;
  28527. set refreshRate(value: number);
  28528. /**
  28529. * Adds a post process to the render target rendering passes.
  28530. * @param postProcess define the post process to add
  28531. */
  28532. addPostProcess(postProcess: PostProcess): void;
  28533. /**
  28534. * Clear all the post processes attached to the render target
  28535. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  28536. */
  28537. clearPostProcesses(dispose?: boolean): void;
  28538. /**
  28539. * Remove one of the post process from the list of attached post processes to the texture
  28540. * @param postProcess define the post process to remove from the list
  28541. */
  28542. removePostProcess(postProcess: PostProcess): void;
  28543. /** @hidden */
  28544. _shouldRender(): boolean;
  28545. /**
  28546. * Gets the actual render size of the texture.
  28547. * @returns the width of the render size
  28548. */
  28549. getRenderSize(): number;
  28550. /**
  28551. * Gets the actual render width of the texture.
  28552. * @returns the width of the render size
  28553. */
  28554. getRenderWidth(): number;
  28555. /**
  28556. * Gets the actual render height of the texture.
  28557. * @returns the height of the render size
  28558. */
  28559. getRenderHeight(): number;
  28560. /**
  28561. * Gets the actual number of layers of the texture.
  28562. * @returns the number of layers
  28563. */
  28564. getRenderLayers(): number;
  28565. /**
  28566. * Get if the texture can be rescaled or not.
  28567. */
  28568. get canRescale(): boolean;
  28569. /**
  28570. * Resize the texture using a ratio.
  28571. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  28572. */
  28573. scale(ratio: number): void;
  28574. /**
  28575. * Get the texture reflection matrix used to rotate/transform the reflection.
  28576. * @returns the reflection matrix
  28577. */
  28578. getReflectionTextureMatrix(): Matrix;
  28579. /**
  28580. * Resize the texture to a new desired size.
  28581. * Be carrefull as it will recreate all the data in the new texture.
  28582. * @param size Define the new size. It can be:
  28583. * - a number for squared texture,
  28584. * - an object containing { width: number, height: number }
  28585. * - or an object containing a ratio { ratio: number }
  28586. */
  28587. resize(size: number | {
  28588. width: number;
  28589. height: number;
  28590. } | {
  28591. ratio: number;
  28592. }): void;
  28593. private _defaultRenderListPrepared;
  28594. /**
  28595. * Renders all the objects from the render list into the texture.
  28596. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  28597. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  28598. */
  28599. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  28600. private _bestReflectionRenderTargetDimension;
  28601. private _prepareRenderingManager;
  28602. /**
  28603. * @hidden
  28604. * @param faceIndex face index to bind to if this is a cubetexture
  28605. * @param layer defines the index of the texture to bind in the array
  28606. */
  28607. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  28608. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  28609. private renderToTarget;
  28610. /**
  28611. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  28612. * This allowed control for front to back rendering or reversly depending of the special needs.
  28613. *
  28614. * @param renderingGroupId The rendering group id corresponding to its index
  28615. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  28616. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  28617. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  28618. */
  28619. 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;
  28620. /**
  28621. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  28622. *
  28623. * @param renderingGroupId The rendering group id corresponding to its index
  28624. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  28625. */
  28626. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  28627. /**
  28628. * Clones the texture.
  28629. * @returns the cloned texture
  28630. */
  28631. clone(): RenderTargetTexture;
  28632. /**
  28633. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  28634. * @returns The JSON representation of the texture
  28635. */
  28636. serialize(): any;
  28637. /**
  28638. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  28639. */
  28640. disposeFramebufferObjects(): void;
  28641. /**
  28642. * Dispose the texture and release its associated resources.
  28643. */
  28644. dispose(): void;
  28645. /** @hidden */
  28646. _rebuild(): void;
  28647. /**
  28648. * Clear the info related to rendering groups preventing retention point in material dispose.
  28649. */
  28650. freeRenderingGroups(): void;
  28651. /**
  28652. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  28653. * @returns the view count
  28654. */
  28655. getViewCount(): number;
  28656. }
  28657. }
  28658. declare module BABYLON {
  28659. /**
  28660. * Class used to manipulate GUIDs
  28661. */
  28662. export class GUID {
  28663. /**
  28664. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  28665. * Be aware Math.random() could cause collisions, but:
  28666. * "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"
  28667. * @returns a pseudo random id
  28668. */
  28669. static RandomId(): string;
  28670. }
  28671. }
  28672. declare module BABYLON {
  28673. /**
  28674. * Options to be used when creating a shadow depth material
  28675. */
  28676. export interface IIOptionShadowDepthMaterial {
  28677. /** Variables in the vertex shader code that need to have their names remapped.
  28678. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  28679. * "var_name" should be either: worldPos or vNormalW
  28680. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  28681. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  28682. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  28683. */
  28684. remappedVariables?: string[];
  28685. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  28686. standalone?: boolean;
  28687. }
  28688. /**
  28689. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  28690. */
  28691. export class ShadowDepthWrapper {
  28692. private _scene;
  28693. private _options?;
  28694. private _baseMaterial;
  28695. private _onEffectCreatedObserver;
  28696. private _subMeshToEffect;
  28697. private _subMeshToDepthEffect;
  28698. private _meshes;
  28699. /** @hidden */
  28700. _matriceNames: any;
  28701. /** Gets the standalone status of the wrapper */
  28702. get standalone(): boolean;
  28703. /** Gets the base material the wrapper is built upon */
  28704. get baseMaterial(): Material;
  28705. /**
  28706. * Instantiate a new shadow depth wrapper.
  28707. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  28708. * generate the shadow depth map. For more information, please refer to the documentation:
  28709. * https://doc.babylonjs.com/babylon101/shadows
  28710. * @param baseMaterial Material to wrap
  28711. * @param scene Define the scene the material belongs to
  28712. * @param options Options used to create the wrapper
  28713. */
  28714. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  28715. /**
  28716. * Gets the effect to use to generate the depth map
  28717. * @param subMesh subMesh to get the effect for
  28718. * @param shadowGenerator shadow generator to get the effect for
  28719. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  28720. */
  28721. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  28722. /**
  28723. * Specifies that the submesh is ready to be used for depth rendering
  28724. * @param subMesh submesh to check
  28725. * @param defines the list of defines to take into account when checking the effect
  28726. * @param shadowGenerator combined with subMesh, it defines the effect to check
  28727. * @param useInstances specifies that instances should be used
  28728. * @returns a boolean indicating that the submesh is ready or not
  28729. */
  28730. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  28731. /**
  28732. * Disposes the resources
  28733. */
  28734. dispose(): void;
  28735. private _makeEffect;
  28736. }
  28737. }
  28738. declare module BABYLON {
  28739. /**
  28740. * Options for compiling materials.
  28741. */
  28742. export interface IMaterialCompilationOptions {
  28743. /**
  28744. * Defines whether clip planes are enabled.
  28745. */
  28746. clipPlane: boolean;
  28747. /**
  28748. * Defines whether instances are enabled.
  28749. */
  28750. useInstances: boolean;
  28751. }
  28752. /**
  28753. * Options passed when calling customShaderNameResolve
  28754. */
  28755. export interface ICustomShaderNameResolveOptions {
  28756. /**
  28757. * 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
  28758. */
  28759. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  28760. }
  28761. /**
  28762. * Base class for the main features of a material in Babylon.js
  28763. */
  28764. export class Material implements IAnimatable {
  28765. /**
  28766. * Returns the triangle fill mode
  28767. */
  28768. static readonly TriangleFillMode: number;
  28769. /**
  28770. * Returns the wireframe mode
  28771. */
  28772. static readonly WireFrameFillMode: number;
  28773. /**
  28774. * Returns the point fill mode
  28775. */
  28776. static readonly PointFillMode: number;
  28777. /**
  28778. * Returns the point list draw mode
  28779. */
  28780. static readonly PointListDrawMode: number;
  28781. /**
  28782. * Returns the line list draw mode
  28783. */
  28784. static readonly LineListDrawMode: number;
  28785. /**
  28786. * Returns the line loop draw mode
  28787. */
  28788. static readonly LineLoopDrawMode: number;
  28789. /**
  28790. * Returns the line strip draw mode
  28791. */
  28792. static readonly LineStripDrawMode: number;
  28793. /**
  28794. * Returns the triangle strip draw mode
  28795. */
  28796. static readonly TriangleStripDrawMode: number;
  28797. /**
  28798. * Returns the triangle fan draw mode
  28799. */
  28800. static readonly TriangleFanDrawMode: number;
  28801. /**
  28802. * Stores the clock-wise side orientation
  28803. */
  28804. static readonly ClockWiseSideOrientation: number;
  28805. /**
  28806. * Stores the counter clock-wise side orientation
  28807. */
  28808. static readonly CounterClockWiseSideOrientation: number;
  28809. /**
  28810. * The dirty texture flag value
  28811. */
  28812. static readonly TextureDirtyFlag: number;
  28813. /**
  28814. * The dirty light flag value
  28815. */
  28816. static readonly LightDirtyFlag: number;
  28817. /**
  28818. * The dirty fresnel flag value
  28819. */
  28820. static readonly FresnelDirtyFlag: number;
  28821. /**
  28822. * The dirty attribute flag value
  28823. */
  28824. static readonly AttributesDirtyFlag: number;
  28825. /**
  28826. * The dirty misc flag value
  28827. */
  28828. static readonly MiscDirtyFlag: number;
  28829. /**
  28830. * The dirty prepass flag value
  28831. */
  28832. static readonly PrePassDirtyFlag: number;
  28833. /**
  28834. * The all dirty flag value
  28835. */
  28836. static readonly AllDirtyFlag: number;
  28837. /**
  28838. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  28839. */
  28840. static readonly MATERIAL_OPAQUE: number;
  28841. /**
  28842. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  28843. */
  28844. static readonly MATERIAL_ALPHATEST: number;
  28845. /**
  28846. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  28847. */
  28848. static readonly MATERIAL_ALPHABLEND: number;
  28849. /**
  28850. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  28851. * They are also discarded below the alpha cutoff threshold to improve performances.
  28852. */
  28853. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  28854. /**
  28855. * The Whiteout method is used to blend normals.
  28856. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  28857. */
  28858. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  28859. /**
  28860. * The Reoriented Normal Mapping method is used to blend normals.
  28861. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  28862. */
  28863. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  28864. /**
  28865. * Custom callback helping to override the default shader used in the material.
  28866. */
  28867. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  28868. /**
  28869. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  28870. */
  28871. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  28872. /**
  28873. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  28874. * This means that the material can keep using a previous shader while a new one is being compiled.
  28875. * This is mostly used when shader parallel compilation is supported (true by default)
  28876. */
  28877. allowShaderHotSwapping: boolean;
  28878. /**
  28879. * The ID of the material
  28880. */
  28881. id: string;
  28882. /**
  28883. * Gets or sets the unique id of the material
  28884. */
  28885. uniqueId: number;
  28886. /**
  28887. * The name of the material
  28888. */
  28889. name: string;
  28890. /**
  28891. * Gets or sets user defined metadata
  28892. */
  28893. metadata: any;
  28894. /**
  28895. * For internal use only. Please do not use.
  28896. */
  28897. reservedDataStore: any;
  28898. /**
  28899. * Specifies if the ready state should be checked on each call
  28900. */
  28901. checkReadyOnEveryCall: boolean;
  28902. /**
  28903. * Specifies if the ready state should be checked once
  28904. */
  28905. checkReadyOnlyOnce: boolean;
  28906. /**
  28907. * The state of the material
  28908. */
  28909. state: string;
  28910. /**
  28911. * If the material can be rendered to several textures with MRT extension
  28912. */
  28913. get canRenderToMRT(): boolean;
  28914. /**
  28915. * The alpha value of the material
  28916. */
  28917. protected _alpha: number;
  28918. /**
  28919. * List of inspectable custom properties (used by the Inspector)
  28920. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  28921. */
  28922. inspectableCustomProperties: IInspectable[];
  28923. /**
  28924. * Sets the alpha value of the material
  28925. */
  28926. set alpha(value: number);
  28927. /**
  28928. * Gets the alpha value of the material
  28929. */
  28930. get alpha(): number;
  28931. /**
  28932. * Specifies if back face culling is enabled
  28933. */
  28934. protected _backFaceCulling: boolean;
  28935. /**
  28936. * Sets the back-face culling state
  28937. */
  28938. set backFaceCulling(value: boolean);
  28939. /**
  28940. * Gets the back-face culling state
  28941. */
  28942. get backFaceCulling(): boolean;
  28943. /**
  28944. * Stores the value for side orientation
  28945. */
  28946. sideOrientation: number;
  28947. /**
  28948. * Callback triggered when the material is compiled
  28949. */
  28950. onCompiled: Nullable<(effect: Effect) => void>;
  28951. /**
  28952. * Callback triggered when an error occurs
  28953. */
  28954. onError: Nullable<(effect: Effect, errors: string) => void>;
  28955. /**
  28956. * Callback triggered to get the render target textures
  28957. */
  28958. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  28959. /**
  28960. * Gets a boolean indicating that current material needs to register RTT
  28961. */
  28962. get hasRenderTargetTextures(): boolean;
  28963. /**
  28964. * Specifies if the material should be serialized
  28965. */
  28966. doNotSerialize: boolean;
  28967. /**
  28968. * @hidden
  28969. */
  28970. _storeEffectOnSubMeshes: boolean;
  28971. /**
  28972. * Stores the animations for the material
  28973. */
  28974. animations: Nullable<Array<Animation>>;
  28975. /**
  28976. * An event triggered when the material is disposed
  28977. */
  28978. onDisposeObservable: Observable<Material>;
  28979. /**
  28980. * An observer which watches for dispose events
  28981. */
  28982. private _onDisposeObserver;
  28983. private _onUnBindObservable;
  28984. /**
  28985. * Called during a dispose event
  28986. */
  28987. set onDispose(callback: () => void);
  28988. private _onBindObservable;
  28989. /**
  28990. * An event triggered when the material is bound
  28991. */
  28992. get onBindObservable(): Observable<AbstractMesh>;
  28993. /**
  28994. * An observer which watches for bind events
  28995. */
  28996. private _onBindObserver;
  28997. /**
  28998. * Called during a bind event
  28999. */
  29000. set onBind(callback: (Mesh: AbstractMesh) => void);
  29001. /**
  29002. * An event triggered when the material is unbound
  29003. */
  29004. get onUnBindObservable(): Observable<Material>;
  29005. protected _onEffectCreatedObservable: Nullable<Observable<{
  29006. effect: Effect;
  29007. subMesh: Nullable<SubMesh>;
  29008. }>>;
  29009. /**
  29010. * An event triggered when the effect is (re)created
  29011. */
  29012. get onEffectCreatedObservable(): Observable<{
  29013. effect: Effect;
  29014. subMesh: Nullable<SubMesh>;
  29015. }>;
  29016. /**
  29017. * Stores the value of the alpha mode
  29018. */
  29019. private _alphaMode;
  29020. /**
  29021. * Sets the value of the alpha mode.
  29022. *
  29023. * | Value | Type | Description |
  29024. * | --- | --- | --- |
  29025. * | 0 | ALPHA_DISABLE | |
  29026. * | 1 | ALPHA_ADD | |
  29027. * | 2 | ALPHA_COMBINE | |
  29028. * | 3 | ALPHA_SUBTRACT | |
  29029. * | 4 | ALPHA_MULTIPLY | |
  29030. * | 5 | ALPHA_MAXIMIZED | |
  29031. * | 6 | ALPHA_ONEONE | |
  29032. * | 7 | ALPHA_PREMULTIPLIED | |
  29033. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  29034. * | 9 | ALPHA_INTERPOLATE | |
  29035. * | 10 | ALPHA_SCREENMODE | |
  29036. *
  29037. */
  29038. set alphaMode(value: number);
  29039. /**
  29040. * Gets the value of the alpha mode
  29041. */
  29042. get alphaMode(): number;
  29043. /**
  29044. * Stores the state of the need depth pre-pass value
  29045. */
  29046. private _needDepthPrePass;
  29047. /**
  29048. * Sets the need depth pre-pass value
  29049. */
  29050. set needDepthPrePass(value: boolean);
  29051. /**
  29052. * Gets the depth pre-pass value
  29053. */
  29054. get needDepthPrePass(): boolean;
  29055. /**
  29056. * Specifies if depth writing should be disabled
  29057. */
  29058. disableDepthWrite: boolean;
  29059. /**
  29060. * Specifies if color writing should be disabled
  29061. */
  29062. disableColorWrite: boolean;
  29063. /**
  29064. * Specifies if depth writing should be forced
  29065. */
  29066. forceDepthWrite: boolean;
  29067. /**
  29068. * Specifies the depth function that should be used. 0 means the default engine function
  29069. */
  29070. depthFunction: number;
  29071. /**
  29072. * Specifies if there should be a separate pass for culling
  29073. */
  29074. separateCullingPass: boolean;
  29075. /**
  29076. * Stores the state specifing if fog should be enabled
  29077. */
  29078. private _fogEnabled;
  29079. /**
  29080. * Sets the state for enabling fog
  29081. */
  29082. set fogEnabled(value: boolean);
  29083. /**
  29084. * Gets the value of the fog enabled state
  29085. */
  29086. get fogEnabled(): boolean;
  29087. /**
  29088. * Stores the size of points
  29089. */
  29090. pointSize: number;
  29091. /**
  29092. * Stores the z offset value
  29093. */
  29094. zOffset: number;
  29095. get wireframe(): boolean;
  29096. /**
  29097. * Sets the state of wireframe mode
  29098. */
  29099. set wireframe(value: boolean);
  29100. /**
  29101. * Gets the value specifying if point clouds are enabled
  29102. */
  29103. get pointsCloud(): boolean;
  29104. /**
  29105. * Sets the state of point cloud mode
  29106. */
  29107. set pointsCloud(value: boolean);
  29108. /**
  29109. * Gets the material fill mode
  29110. */
  29111. get fillMode(): number;
  29112. /**
  29113. * Sets the material fill mode
  29114. */
  29115. set fillMode(value: number);
  29116. /**
  29117. * @hidden
  29118. * Stores the effects for the material
  29119. */
  29120. _effect: Nullable<Effect>;
  29121. /**
  29122. * Specifies if uniform buffers should be used
  29123. */
  29124. private _useUBO;
  29125. /**
  29126. * Stores a reference to the scene
  29127. */
  29128. private _scene;
  29129. /**
  29130. * Stores the fill mode state
  29131. */
  29132. private _fillMode;
  29133. /**
  29134. * Specifies if the depth write state should be cached
  29135. */
  29136. private _cachedDepthWriteState;
  29137. /**
  29138. * Specifies if the color write state should be cached
  29139. */
  29140. private _cachedColorWriteState;
  29141. /**
  29142. * Specifies if the depth function state should be cached
  29143. */
  29144. private _cachedDepthFunctionState;
  29145. /**
  29146. * Stores the uniform buffer
  29147. */
  29148. protected _uniformBuffer: UniformBuffer;
  29149. /** @hidden */
  29150. _indexInSceneMaterialArray: number;
  29151. /** @hidden */
  29152. meshMap: Nullable<{
  29153. [id: string]: AbstractMesh | undefined;
  29154. }>;
  29155. /**
  29156. * Creates a material instance
  29157. * @param name defines the name of the material
  29158. * @param scene defines the scene to reference
  29159. * @param doNotAdd specifies if the material should be added to the scene
  29160. */
  29161. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  29162. /**
  29163. * Returns a string representation of the current material
  29164. * @param fullDetails defines a boolean indicating which levels of logging is desired
  29165. * @returns a string with material information
  29166. */
  29167. toString(fullDetails?: boolean): string;
  29168. /**
  29169. * Gets the class name of the material
  29170. * @returns a string with the class name of the material
  29171. */
  29172. getClassName(): string;
  29173. /**
  29174. * Specifies if updates for the material been locked
  29175. */
  29176. get isFrozen(): boolean;
  29177. /**
  29178. * Locks updates for the material
  29179. */
  29180. freeze(): void;
  29181. /**
  29182. * Unlocks updates for the material
  29183. */
  29184. unfreeze(): void;
  29185. /**
  29186. * Specifies if the material is ready to be used
  29187. * @param mesh defines the mesh to check
  29188. * @param useInstances specifies if instances should be used
  29189. * @returns a boolean indicating if the material is ready to be used
  29190. */
  29191. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  29192. /**
  29193. * Specifies that the submesh is ready to be used
  29194. * @param mesh defines the mesh to check
  29195. * @param subMesh defines which submesh to check
  29196. * @param useInstances specifies that instances should be used
  29197. * @returns a boolean indicating that the submesh is ready or not
  29198. */
  29199. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  29200. /**
  29201. * Returns the material effect
  29202. * @returns the effect associated with the material
  29203. */
  29204. getEffect(): Nullable<Effect>;
  29205. /**
  29206. * Returns the current scene
  29207. * @returns a Scene
  29208. */
  29209. getScene(): Scene;
  29210. /**
  29211. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  29212. */
  29213. protected _forceAlphaTest: boolean;
  29214. /**
  29215. * The transparency mode of the material.
  29216. */
  29217. protected _transparencyMode: Nullable<number>;
  29218. /**
  29219. * Gets the current transparency mode.
  29220. */
  29221. get transparencyMode(): Nullable<number>;
  29222. /**
  29223. * Sets the transparency mode of the material.
  29224. *
  29225. * | Value | Type | Description |
  29226. * | ----- | ----------------------------------- | ----------- |
  29227. * | 0 | OPAQUE | |
  29228. * | 1 | ALPHATEST | |
  29229. * | 2 | ALPHABLEND | |
  29230. * | 3 | ALPHATESTANDBLEND | |
  29231. *
  29232. */
  29233. set transparencyMode(value: Nullable<number>);
  29234. /**
  29235. * Returns true if alpha blending should be disabled.
  29236. */
  29237. protected get _disableAlphaBlending(): boolean;
  29238. /**
  29239. * Specifies whether or not this material should be rendered in alpha blend mode.
  29240. * @returns a boolean specifying if alpha blending is needed
  29241. */
  29242. needAlphaBlending(): boolean;
  29243. /**
  29244. * Specifies if the mesh will require alpha blending
  29245. * @param mesh defines the mesh to check
  29246. * @returns a boolean specifying if alpha blending is needed for the mesh
  29247. */
  29248. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  29249. /**
  29250. * Specifies whether or not this material should be rendered in alpha test mode.
  29251. * @returns a boolean specifying if an alpha test is needed.
  29252. */
  29253. needAlphaTesting(): boolean;
  29254. /**
  29255. * Specifies if material alpha testing should be turned on for the mesh
  29256. * @param mesh defines the mesh to check
  29257. */
  29258. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  29259. /**
  29260. * Gets the texture used for the alpha test
  29261. * @returns the texture to use for alpha testing
  29262. */
  29263. getAlphaTestTexture(): Nullable<BaseTexture>;
  29264. /**
  29265. * Marks the material to indicate that it needs to be re-calculated
  29266. */
  29267. markDirty(): void;
  29268. /** @hidden */
  29269. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  29270. /**
  29271. * Binds the material to the mesh
  29272. * @param world defines the world transformation matrix
  29273. * @param mesh defines the mesh to bind the material to
  29274. */
  29275. bind(world: Matrix, mesh?: Mesh): void;
  29276. /**
  29277. * Binds the submesh to the material
  29278. * @param world defines the world transformation matrix
  29279. * @param mesh defines the mesh containing the submesh
  29280. * @param subMesh defines the submesh to bind the material to
  29281. */
  29282. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  29283. /**
  29284. * Binds the world matrix to the material
  29285. * @param world defines the world transformation matrix
  29286. */
  29287. bindOnlyWorldMatrix(world: Matrix): void;
  29288. /**
  29289. * Binds the scene's uniform buffer to the effect.
  29290. * @param effect defines the effect to bind to the scene uniform buffer
  29291. * @param sceneUbo defines the uniform buffer storing scene data
  29292. */
  29293. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  29294. /**
  29295. * Binds the view matrix to the effect
  29296. * @param effect defines the effect to bind the view matrix to
  29297. */
  29298. bindView(effect: Effect): void;
  29299. /**
  29300. * Binds the view projection matrix to the effect
  29301. * @param effect defines the effect to bind the view projection matrix to
  29302. */
  29303. bindViewProjection(effect: Effect): void;
  29304. /**
  29305. * Processes to execute after binding the material to a mesh
  29306. * @param mesh defines the rendered mesh
  29307. */
  29308. protected _afterBind(mesh?: Mesh): void;
  29309. /**
  29310. * Unbinds the material from the mesh
  29311. */
  29312. unbind(): void;
  29313. /**
  29314. * Gets the active textures from the material
  29315. * @returns an array of textures
  29316. */
  29317. getActiveTextures(): BaseTexture[];
  29318. /**
  29319. * Specifies if the material uses a texture
  29320. * @param texture defines the texture to check against the material
  29321. * @returns a boolean specifying if the material uses the texture
  29322. */
  29323. hasTexture(texture: BaseTexture): boolean;
  29324. /**
  29325. * Makes a duplicate of the material, and gives it a new name
  29326. * @param name defines the new name for the duplicated material
  29327. * @returns the cloned material
  29328. */
  29329. clone(name: string): Nullable<Material>;
  29330. /**
  29331. * Gets the meshes bound to the material
  29332. * @returns an array of meshes bound to the material
  29333. */
  29334. getBindedMeshes(): AbstractMesh[];
  29335. /**
  29336. * Force shader compilation
  29337. * @param mesh defines the mesh associated with this material
  29338. * @param onCompiled defines a function to execute once the material is compiled
  29339. * @param options defines the options to configure the compilation
  29340. * @param onError defines a function to execute if the material fails compiling
  29341. */
  29342. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  29343. /**
  29344. * Force shader compilation
  29345. * @param mesh defines the mesh that will use this material
  29346. * @param options defines additional options for compiling the shaders
  29347. * @returns a promise that resolves when the compilation completes
  29348. */
  29349. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  29350. private static readonly _AllDirtyCallBack;
  29351. private static readonly _ImageProcessingDirtyCallBack;
  29352. private static readonly _TextureDirtyCallBack;
  29353. private static readonly _FresnelDirtyCallBack;
  29354. private static readonly _MiscDirtyCallBack;
  29355. private static readonly _PrePassDirtyCallBack;
  29356. private static readonly _LightsDirtyCallBack;
  29357. private static readonly _AttributeDirtyCallBack;
  29358. private static _FresnelAndMiscDirtyCallBack;
  29359. private static _TextureAndMiscDirtyCallBack;
  29360. private static readonly _DirtyCallbackArray;
  29361. private static readonly _RunDirtyCallBacks;
  29362. /**
  29363. * Marks a define in the material to indicate that it needs to be re-computed
  29364. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  29365. */
  29366. markAsDirty(flag: number): void;
  29367. /**
  29368. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  29369. * @param func defines a function which checks material defines against the submeshes
  29370. */
  29371. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  29372. /**
  29373. * Indicates that the scene should check if the rendering now needs a prepass
  29374. */
  29375. protected _markScenePrePassDirty(): void;
  29376. /**
  29377. * Indicates that we need to re-calculated for all submeshes
  29378. */
  29379. protected _markAllSubMeshesAsAllDirty(): void;
  29380. /**
  29381. * Indicates that image processing needs to be re-calculated for all submeshes
  29382. */
  29383. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  29384. /**
  29385. * Indicates that textures need to be re-calculated for all submeshes
  29386. */
  29387. protected _markAllSubMeshesAsTexturesDirty(): void;
  29388. /**
  29389. * Indicates that fresnel needs to be re-calculated for all submeshes
  29390. */
  29391. protected _markAllSubMeshesAsFresnelDirty(): void;
  29392. /**
  29393. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  29394. */
  29395. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  29396. /**
  29397. * Indicates that lights need to be re-calculated for all submeshes
  29398. */
  29399. protected _markAllSubMeshesAsLightsDirty(): void;
  29400. /**
  29401. * Indicates that attributes need to be re-calculated for all submeshes
  29402. */
  29403. protected _markAllSubMeshesAsAttributesDirty(): void;
  29404. /**
  29405. * Indicates that misc needs to be re-calculated for all submeshes
  29406. */
  29407. protected _markAllSubMeshesAsMiscDirty(): void;
  29408. /**
  29409. * Indicates that prepass needs to be re-calculated for all submeshes
  29410. */
  29411. protected _markAllSubMeshesAsPrePassDirty(): void;
  29412. /**
  29413. * Indicates that textures and misc need to be re-calculated for all submeshes
  29414. */
  29415. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  29416. /**
  29417. * Sets the required values to the prepass renderer.
  29418. * @param prePassRenderer defines the prepass renderer to setup.
  29419. * @returns true if the pre pass is needed.
  29420. */
  29421. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  29422. /**
  29423. * Disposes the material
  29424. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  29425. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  29426. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  29427. */
  29428. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  29429. /** @hidden */
  29430. private releaseVertexArrayObject;
  29431. /**
  29432. * Serializes this material
  29433. * @returns the serialized material object
  29434. */
  29435. serialize(): any;
  29436. /**
  29437. * Creates a material from parsed material data
  29438. * @param parsedMaterial defines parsed material data
  29439. * @param scene defines the hosting scene
  29440. * @param rootUrl defines the root URL to use to load textures
  29441. * @returns a new material
  29442. */
  29443. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  29444. }
  29445. }
  29446. declare module BABYLON {
  29447. /**
  29448. * A multi-material is used to apply different materials to different parts of the same object without the need of
  29449. * separate meshes. This can be use to improve performances.
  29450. * @see https://doc.babylonjs.com/how_to/multi_materials
  29451. */
  29452. export class MultiMaterial extends Material {
  29453. private _subMaterials;
  29454. /**
  29455. * Gets or Sets the list of Materials used within the multi material.
  29456. * They need to be ordered according to the submeshes order in the associated mesh
  29457. */
  29458. get subMaterials(): Nullable<Material>[];
  29459. set subMaterials(value: Nullable<Material>[]);
  29460. /**
  29461. * Function used to align with Node.getChildren()
  29462. * @returns the list of Materials used within the multi material
  29463. */
  29464. getChildren(): Nullable<Material>[];
  29465. /**
  29466. * Instantiates a new Multi Material
  29467. * A multi-material is used to apply different materials to different parts of the same object without the need of
  29468. * separate meshes. This can be use to improve performances.
  29469. * @see https://doc.babylonjs.com/how_to/multi_materials
  29470. * @param name Define the name in the scene
  29471. * @param scene Define the scene the material belongs to
  29472. */
  29473. constructor(name: string, scene: Scene);
  29474. private _hookArray;
  29475. /**
  29476. * Get one of the submaterial by its index in the submaterials array
  29477. * @param index The index to look the sub material at
  29478. * @returns The Material if the index has been defined
  29479. */
  29480. getSubMaterial(index: number): Nullable<Material>;
  29481. /**
  29482. * Get the list of active textures for the whole sub materials list.
  29483. * @returns All the textures that will be used during the rendering
  29484. */
  29485. getActiveTextures(): BaseTexture[];
  29486. /**
  29487. * Gets the current class name of the material e.g. "MultiMaterial"
  29488. * Mainly use in serialization.
  29489. * @returns the class name
  29490. */
  29491. getClassName(): string;
  29492. /**
  29493. * Checks if the material is ready to render the requested sub mesh
  29494. * @param mesh Define the mesh the submesh belongs to
  29495. * @param subMesh Define the sub mesh to look readyness for
  29496. * @param useInstances Define whether or not the material is used with instances
  29497. * @returns true if ready, otherwise false
  29498. */
  29499. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  29500. /**
  29501. * Clones the current material and its related sub materials
  29502. * @param name Define the name of the newly cloned material
  29503. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  29504. * @returns the cloned material
  29505. */
  29506. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  29507. /**
  29508. * Serializes the materials into a JSON representation.
  29509. * @returns the JSON representation
  29510. */
  29511. serialize(): any;
  29512. /**
  29513. * Dispose the material and release its associated resources
  29514. * @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)
  29515. * @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)
  29516. * @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)
  29517. */
  29518. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  29519. /**
  29520. * Creates a MultiMaterial from parsed MultiMaterial data.
  29521. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  29522. * @param scene defines the hosting scene
  29523. * @returns a new MultiMaterial
  29524. */
  29525. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  29526. }
  29527. }
  29528. declare module BABYLON {
  29529. /**
  29530. * Defines a subdivision inside a mesh
  29531. */
  29532. export class SubMesh implements ICullable {
  29533. /** the material index to use */
  29534. materialIndex: number;
  29535. /** vertex index start */
  29536. verticesStart: number;
  29537. /** vertices count */
  29538. verticesCount: number;
  29539. /** index start */
  29540. indexStart: number;
  29541. /** indices count */
  29542. indexCount: number;
  29543. /** @hidden */
  29544. _materialDefines: Nullable<MaterialDefines>;
  29545. /** @hidden */
  29546. _materialEffect: Nullable<Effect>;
  29547. /** @hidden */
  29548. _effectOverride: Nullable<Effect>;
  29549. /**
  29550. * Gets material defines used by the effect associated to the sub mesh
  29551. */
  29552. get materialDefines(): Nullable<MaterialDefines>;
  29553. /**
  29554. * Sets material defines used by the effect associated to the sub mesh
  29555. */
  29556. set materialDefines(defines: Nullable<MaterialDefines>);
  29557. /**
  29558. * Gets associated effect
  29559. */
  29560. get effect(): Nullable<Effect>;
  29561. /**
  29562. * Sets associated effect (effect used to render this submesh)
  29563. * @param effect defines the effect to associate with
  29564. * @param defines defines the set of defines used to compile this effect
  29565. */
  29566. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  29567. /** @hidden */
  29568. _linesIndexCount: number;
  29569. private _mesh;
  29570. private _renderingMesh;
  29571. private _boundingInfo;
  29572. private _linesIndexBuffer;
  29573. /** @hidden */
  29574. _lastColliderWorldVertices: Nullable<Vector3[]>;
  29575. /** @hidden */
  29576. _trianglePlanes: Plane[];
  29577. /** @hidden */
  29578. _lastColliderTransformMatrix: Nullable<Matrix>;
  29579. /** @hidden */
  29580. _renderId: number;
  29581. /** @hidden */
  29582. _alphaIndex: number;
  29583. /** @hidden */
  29584. _distanceToCamera: number;
  29585. /** @hidden */
  29586. _id: number;
  29587. private _currentMaterial;
  29588. /**
  29589. * Add a new submesh to a mesh
  29590. * @param materialIndex defines the material index to use
  29591. * @param verticesStart defines vertex index start
  29592. * @param verticesCount defines vertices count
  29593. * @param indexStart defines index start
  29594. * @param indexCount defines indices count
  29595. * @param mesh defines the parent mesh
  29596. * @param renderingMesh defines an optional rendering mesh
  29597. * @param createBoundingBox defines if bounding box should be created for this submesh
  29598. * @returns the new submesh
  29599. */
  29600. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  29601. /**
  29602. * Creates a new submesh
  29603. * @param materialIndex defines the material index to use
  29604. * @param verticesStart defines vertex index start
  29605. * @param verticesCount defines vertices count
  29606. * @param indexStart defines index start
  29607. * @param indexCount defines indices count
  29608. * @param mesh defines the parent mesh
  29609. * @param renderingMesh defines an optional rendering mesh
  29610. * @param createBoundingBox defines if bounding box should be created for this submesh
  29611. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  29612. */
  29613. constructor(
  29614. /** the material index to use */
  29615. materialIndex: number,
  29616. /** vertex index start */
  29617. verticesStart: number,
  29618. /** vertices count */
  29619. verticesCount: number,
  29620. /** index start */
  29621. indexStart: number,
  29622. /** indices count */
  29623. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  29624. /**
  29625. * Returns true if this submesh covers the entire parent mesh
  29626. * @ignorenaming
  29627. */
  29628. get IsGlobal(): boolean;
  29629. /**
  29630. * Returns the submesh BoudingInfo object
  29631. * @returns current bounding info (or mesh's one if the submesh is global)
  29632. */
  29633. getBoundingInfo(): BoundingInfo;
  29634. /**
  29635. * Sets the submesh BoundingInfo
  29636. * @param boundingInfo defines the new bounding info to use
  29637. * @returns the SubMesh
  29638. */
  29639. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  29640. /**
  29641. * Returns the mesh of the current submesh
  29642. * @return the parent mesh
  29643. */
  29644. getMesh(): AbstractMesh;
  29645. /**
  29646. * Returns the rendering mesh of the submesh
  29647. * @returns the rendering mesh (could be different from parent mesh)
  29648. */
  29649. getRenderingMesh(): Mesh;
  29650. /**
  29651. * Returns the replacement mesh of the submesh
  29652. * @returns the replacement mesh (could be different from parent mesh)
  29653. */
  29654. getReplacementMesh(): Nullable<AbstractMesh>;
  29655. /**
  29656. * Returns the effective mesh of the submesh
  29657. * @returns the effective mesh (could be different from parent mesh)
  29658. */
  29659. getEffectiveMesh(): AbstractMesh;
  29660. /**
  29661. * Returns the submesh material
  29662. * @returns null or the current material
  29663. */
  29664. getMaterial(): Nullable<Material>;
  29665. private _IsMultiMaterial;
  29666. /**
  29667. * Sets a new updated BoundingInfo object to the submesh
  29668. * @param data defines an optional position array to use to determine the bounding info
  29669. * @returns the SubMesh
  29670. */
  29671. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  29672. /** @hidden */
  29673. _checkCollision(collider: Collider): boolean;
  29674. /**
  29675. * Updates the submesh BoundingInfo
  29676. * @param world defines the world matrix to use to update the bounding info
  29677. * @returns the submesh
  29678. */
  29679. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  29680. /**
  29681. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  29682. * @param frustumPlanes defines the frustum planes
  29683. * @returns true if the submesh is intersecting with the frustum
  29684. */
  29685. isInFrustum(frustumPlanes: Plane[]): boolean;
  29686. /**
  29687. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  29688. * @param frustumPlanes defines the frustum planes
  29689. * @returns true if the submesh is inside the frustum
  29690. */
  29691. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  29692. /**
  29693. * Renders the submesh
  29694. * @param enableAlphaMode defines if alpha needs to be used
  29695. * @returns the submesh
  29696. */
  29697. render(enableAlphaMode: boolean): SubMesh;
  29698. /**
  29699. * @hidden
  29700. */
  29701. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  29702. /**
  29703. * Checks if the submesh intersects with a ray
  29704. * @param ray defines the ray to test
  29705. * @returns true is the passed ray intersects the submesh bounding box
  29706. */
  29707. canIntersects(ray: Ray): boolean;
  29708. /**
  29709. * Intersects current submesh with a ray
  29710. * @param ray defines the ray to test
  29711. * @param positions defines mesh's positions array
  29712. * @param indices defines mesh's indices array
  29713. * @param fastCheck defines if the first intersection will be used (and not the closest)
  29714. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  29715. * @returns intersection info or null if no intersection
  29716. */
  29717. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  29718. /** @hidden */
  29719. private _intersectLines;
  29720. /** @hidden */
  29721. private _intersectUnIndexedLines;
  29722. /** @hidden */
  29723. private _intersectTriangles;
  29724. /** @hidden */
  29725. private _intersectUnIndexedTriangles;
  29726. /** @hidden */
  29727. _rebuild(): void;
  29728. /**
  29729. * Creates a new submesh from the passed mesh
  29730. * @param newMesh defines the new hosting mesh
  29731. * @param newRenderingMesh defines an optional rendering mesh
  29732. * @returns the new submesh
  29733. */
  29734. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  29735. /**
  29736. * Release associated resources
  29737. */
  29738. dispose(): void;
  29739. /**
  29740. * Gets the class name
  29741. * @returns the string "SubMesh".
  29742. */
  29743. getClassName(): string;
  29744. /**
  29745. * Creates a new submesh from indices data
  29746. * @param materialIndex the index of the main mesh material
  29747. * @param startIndex the index where to start the copy in the mesh indices array
  29748. * @param indexCount the number of indices to copy then from the startIndex
  29749. * @param mesh the main mesh to create the submesh from
  29750. * @param renderingMesh the optional rendering mesh
  29751. * @returns a new submesh
  29752. */
  29753. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  29754. }
  29755. }
  29756. declare module BABYLON {
  29757. /**
  29758. * Class used to represent data loading progression
  29759. */
  29760. export class SceneLoaderFlags {
  29761. private static _ForceFullSceneLoadingForIncremental;
  29762. private static _ShowLoadingScreen;
  29763. private static _CleanBoneMatrixWeights;
  29764. private static _loggingLevel;
  29765. /**
  29766. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  29767. */
  29768. static get ForceFullSceneLoadingForIncremental(): boolean;
  29769. static set ForceFullSceneLoadingForIncremental(value: boolean);
  29770. /**
  29771. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  29772. */
  29773. static get ShowLoadingScreen(): boolean;
  29774. static set ShowLoadingScreen(value: boolean);
  29775. /**
  29776. * Defines the current logging level (while loading the scene)
  29777. * @ignorenaming
  29778. */
  29779. static get loggingLevel(): number;
  29780. static set loggingLevel(value: number);
  29781. /**
  29782. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  29783. */
  29784. static get CleanBoneMatrixWeights(): boolean;
  29785. static set CleanBoneMatrixWeights(value: boolean);
  29786. }
  29787. }
  29788. declare module BABYLON {
  29789. /**
  29790. * Class used to store geometry data (vertex buffers + index buffer)
  29791. */
  29792. export class Geometry implements IGetSetVerticesData {
  29793. /**
  29794. * Gets or sets the ID of the geometry
  29795. */
  29796. id: string;
  29797. /**
  29798. * Gets or sets the unique ID of the geometry
  29799. */
  29800. uniqueId: number;
  29801. /**
  29802. * Gets the delay loading state of the geometry (none by default which means not delayed)
  29803. */
  29804. delayLoadState: number;
  29805. /**
  29806. * Gets the file containing the data to load when running in delay load state
  29807. */
  29808. delayLoadingFile: Nullable<string>;
  29809. /**
  29810. * Callback called when the geometry is updated
  29811. */
  29812. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  29813. private _scene;
  29814. private _engine;
  29815. private _meshes;
  29816. private _totalVertices;
  29817. /** @hidden */
  29818. _indices: IndicesArray;
  29819. /** @hidden */
  29820. _vertexBuffers: {
  29821. [key: string]: VertexBuffer;
  29822. };
  29823. private _isDisposed;
  29824. private _extend;
  29825. private _boundingBias;
  29826. /** @hidden */
  29827. _delayInfo: Array<string>;
  29828. private _indexBuffer;
  29829. private _indexBufferIsUpdatable;
  29830. /** @hidden */
  29831. _boundingInfo: Nullable<BoundingInfo>;
  29832. /** @hidden */
  29833. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  29834. /** @hidden */
  29835. _softwareSkinningFrameId: number;
  29836. private _vertexArrayObjects;
  29837. private _updatable;
  29838. /** @hidden */
  29839. _positions: Nullable<Vector3[]>;
  29840. /**
  29841. * 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
  29842. */
  29843. get boundingBias(): Vector2;
  29844. /**
  29845. * 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
  29846. */
  29847. set boundingBias(value: Vector2);
  29848. /**
  29849. * Static function used to attach a new empty geometry to a mesh
  29850. * @param mesh defines the mesh to attach the geometry to
  29851. * @returns the new Geometry
  29852. */
  29853. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  29854. /** Get the list of meshes using this geometry */
  29855. get meshes(): Mesh[];
  29856. /**
  29857. * 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
  29858. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  29859. */
  29860. useBoundingInfoFromGeometry: boolean;
  29861. /**
  29862. * Creates a new geometry
  29863. * @param id defines the unique ID
  29864. * @param scene defines the hosting scene
  29865. * @param vertexData defines the VertexData used to get geometry data
  29866. * @param updatable defines if geometry must be updatable (false by default)
  29867. * @param mesh defines the mesh that will be associated with the geometry
  29868. */
  29869. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  29870. /**
  29871. * Gets the current extend of the geometry
  29872. */
  29873. get extend(): {
  29874. minimum: Vector3;
  29875. maximum: Vector3;
  29876. };
  29877. /**
  29878. * Gets the hosting scene
  29879. * @returns the hosting Scene
  29880. */
  29881. getScene(): Scene;
  29882. /**
  29883. * Gets the hosting engine
  29884. * @returns the hosting Engine
  29885. */
  29886. getEngine(): Engine;
  29887. /**
  29888. * Defines if the geometry is ready to use
  29889. * @returns true if the geometry is ready to be used
  29890. */
  29891. isReady(): boolean;
  29892. /**
  29893. * Gets a value indicating that the geometry should not be serialized
  29894. */
  29895. get doNotSerialize(): boolean;
  29896. /** @hidden */
  29897. _rebuild(): void;
  29898. /**
  29899. * Affects all geometry data in one call
  29900. * @param vertexData defines the geometry data
  29901. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  29902. */
  29903. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  29904. /**
  29905. * Set specific vertex data
  29906. * @param kind defines the data kind (Position, normal, etc...)
  29907. * @param data defines the vertex data to use
  29908. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  29909. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  29910. */
  29911. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  29912. /**
  29913. * Removes a specific vertex data
  29914. * @param kind defines the data kind (Position, normal, etc...)
  29915. */
  29916. removeVerticesData(kind: string): void;
  29917. /**
  29918. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  29919. * @param buffer defines the vertex buffer to use
  29920. * @param totalVertices defines the total number of vertices for position kind (could be null)
  29921. */
  29922. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  29923. /**
  29924. * Update a specific vertex buffer
  29925. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  29926. * It will do nothing if the buffer is not updatable
  29927. * @param kind defines the data kind (Position, normal, etc...)
  29928. * @param data defines the data to use
  29929. * @param offset defines the offset in the target buffer where to store the data
  29930. * @param useBytes set to true if the offset is in bytes
  29931. */
  29932. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  29933. /**
  29934. * Update a specific vertex buffer
  29935. * This function will create a new buffer if the current one is not updatable
  29936. * @param kind defines the data kind (Position, normal, etc...)
  29937. * @param data defines the data to use
  29938. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  29939. */
  29940. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  29941. private _updateBoundingInfo;
  29942. /** @hidden */
  29943. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  29944. /**
  29945. * Gets total number of vertices
  29946. * @returns the total number of vertices
  29947. */
  29948. getTotalVertices(): number;
  29949. /**
  29950. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  29951. * @param kind defines the data kind (Position, normal, etc...)
  29952. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  29953. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  29954. * @returns a float array containing vertex data
  29955. */
  29956. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  29957. /**
  29958. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  29959. * @param kind defines the data kind (Position, normal, etc...)
  29960. * @returns true if the vertex buffer with the specified kind is updatable
  29961. */
  29962. isVertexBufferUpdatable(kind: string): boolean;
  29963. /**
  29964. * Gets a specific vertex buffer
  29965. * @param kind defines the data kind (Position, normal, etc...)
  29966. * @returns a VertexBuffer
  29967. */
  29968. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  29969. /**
  29970. * Returns all vertex buffers
  29971. * @return an object holding all vertex buffers indexed by kind
  29972. */
  29973. getVertexBuffers(): Nullable<{
  29974. [key: string]: VertexBuffer;
  29975. }>;
  29976. /**
  29977. * Gets a boolean indicating if specific vertex buffer is present
  29978. * @param kind defines the data kind (Position, normal, etc...)
  29979. * @returns true if data is present
  29980. */
  29981. isVerticesDataPresent(kind: string): boolean;
  29982. /**
  29983. * Gets a list of all attached data kinds (Position, normal, etc...)
  29984. * @returns a list of string containing all kinds
  29985. */
  29986. getVerticesDataKinds(): string[];
  29987. /**
  29988. * Update index buffer
  29989. * @param indices defines the indices to store in the index buffer
  29990. * @param offset defines the offset in the target buffer where to store the data
  29991. * @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)
  29992. */
  29993. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  29994. /**
  29995. * Creates a new index buffer
  29996. * @param indices defines the indices to store in the index buffer
  29997. * @param totalVertices defines the total number of vertices (could be null)
  29998. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  29999. */
  30000. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  30001. /**
  30002. * Return the total number of indices
  30003. * @returns the total number of indices
  30004. */
  30005. getTotalIndices(): number;
  30006. /**
  30007. * Gets the index buffer array
  30008. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  30009. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  30010. * @returns the index buffer array
  30011. */
  30012. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  30013. /**
  30014. * Gets the index buffer
  30015. * @return the index buffer
  30016. */
  30017. getIndexBuffer(): Nullable<DataBuffer>;
  30018. /** @hidden */
  30019. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  30020. /**
  30021. * Release the associated resources for a specific mesh
  30022. * @param mesh defines the source mesh
  30023. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  30024. */
  30025. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  30026. /**
  30027. * Apply current geometry to a given mesh
  30028. * @param mesh defines the mesh to apply geometry to
  30029. */
  30030. applyToMesh(mesh: Mesh): void;
  30031. private _updateExtend;
  30032. private _applyToMesh;
  30033. private notifyUpdate;
  30034. /**
  30035. * Load the geometry if it was flagged as delay loaded
  30036. * @param scene defines the hosting scene
  30037. * @param onLoaded defines a callback called when the geometry is loaded
  30038. */
  30039. load(scene: Scene, onLoaded?: () => void): void;
  30040. private _queueLoad;
  30041. /**
  30042. * Invert the geometry to move from a right handed system to a left handed one.
  30043. */
  30044. toLeftHanded(): void;
  30045. /** @hidden */
  30046. _resetPointsArrayCache(): void;
  30047. /** @hidden */
  30048. _generatePointsArray(): boolean;
  30049. /**
  30050. * Gets a value indicating if the geometry is disposed
  30051. * @returns true if the geometry was disposed
  30052. */
  30053. isDisposed(): boolean;
  30054. private _disposeVertexArrayObjects;
  30055. /**
  30056. * Free all associated resources
  30057. */
  30058. dispose(): void;
  30059. /**
  30060. * Clone the current geometry into a new geometry
  30061. * @param id defines the unique ID of the new geometry
  30062. * @returns a new geometry object
  30063. */
  30064. copy(id: string): Geometry;
  30065. /**
  30066. * Serialize the current geometry info (and not the vertices data) into a JSON object
  30067. * @return a JSON representation of the current geometry data (without the vertices data)
  30068. */
  30069. serialize(): any;
  30070. private toNumberArray;
  30071. /**
  30072. * Serialize all vertices data into a JSON oject
  30073. * @returns a JSON representation of the current geometry data
  30074. */
  30075. serializeVerticeData(): any;
  30076. /**
  30077. * Extracts a clone of a mesh geometry
  30078. * @param mesh defines the source mesh
  30079. * @param id defines the unique ID of the new geometry object
  30080. * @returns the new geometry object
  30081. */
  30082. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  30083. /**
  30084. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  30085. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  30086. * Be aware Math.random() could cause collisions, but:
  30087. * "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"
  30088. * @returns a string containing a new GUID
  30089. */
  30090. static RandomId(): string;
  30091. /** @hidden */
  30092. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  30093. private static _CleanMatricesWeights;
  30094. /**
  30095. * Create a new geometry from persisted data (Using .babylon file format)
  30096. * @param parsedVertexData defines the persisted data
  30097. * @param scene defines the hosting scene
  30098. * @param rootUrl defines the root url to use to load assets (like delayed data)
  30099. * @returns the new geometry object
  30100. */
  30101. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  30102. }
  30103. }
  30104. declare module BABYLON {
  30105. /**
  30106. * Define an interface for all classes that will get and set the data on vertices
  30107. */
  30108. export interface IGetSetVerticesData {
  30109. /**
  30110. * Gets a boolean indicating if specific vertex data is present
  30111. * @param kind defines the vertex data kind to use
  30112. * @returns true is data kind is present
  30113. */
  30114. isVerticesDataPresent(kind: string): boolean;
  30115. /**
  30116. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  30117. * @param kind defines the data kind (Position, normal, etc...)
  30118. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  30119. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  30120. * @returns a float array containing vertex data
  30121. */
  30122. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  30123. /**
  30124. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  30125. * @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.
  30126. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  30127. * @returns the indices array or an empty array if the mesh has no geometry
  30128. */
  30129. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  30130. /**
  30131. * Set specific vertex data
  30132. * @param kind defines the data kind (Position, normal, etc...)
  30133. * @param data defines the vertex data to use
  30134. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  30135. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  30136. */
  30137. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  30138. /**
  30139. * Update a specific associated vertex buffer
  30140. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  30141. * - VertexBuffer.PositionKind
  30142. * - VertexBuffer.UVKind
  30143. * - VertexBuffer.UV2Kind
  30144. * - VertexBuffer.UV3Kind
  30145. * - VertexBuffer.UV4Kind
  30146. * - VertexBuffer.UV5Kind
  30147. * - VertexBuffer.UV6Kind
  30148. * - VertexBuffer.ColorKind
  30149. * - VertexBuffer.MatricesIndicesKind
  30150. * - VertexBuffer.MatricesIndicesExtraKind
  30151. * - VertexBuffer.MatricesWeightsKind
  30152. * - VertexBuffer.MatricesWeightsExtraKind
  30153. * @param data defines the data source
  30154. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  30155. * @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)
  30156. */
  30157. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  30158. /**
  30159. * Creates a new index buffer
  30160. * @param indices defines the indices to store in the index buffer
  30161. * @param totalVertices defines the total number of vertices (could be null)
  30162. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  30163. */
  30164. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  30165. }
  30166. /**
  30167. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  30168. */
  30169. export class VertexData {
  30170. /**
  30171. * Mesh side orientation : usually the external or front surface
  30172. */
  30173. static readonly FRONTSIDE: number;
  30174. /**
  30175. * Mesh side orientation : usually the internal or back surface
  30176. */
  30177. static readonly BACKSIDE: number;
  30178. /**
  30179. * Mesh side orientation : both internal and external or front and back surfaces
  30180. */
  30181. static readonly DOUBLESIDE: number;
  30182. /**
  30183. * Mesh side orientation : by default, `FRONTSIDE`
  30184. */
  30185. static readonly DEFAULTSIDE: number;
  30186. /**
  30187. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  30188. */
  30189. positions: Nullable<FloatArray>;
  30190. /**
  30191. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  30192. */
  30193. normals: Nullable<FloatArray>;
  30194. /**
  30195. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  30196. */
  30197. tangents: Nullable<FloatArray>;
  30198. /**
  30199. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  30200. */
  30201. uvs: Nullable<FloatArray>;
  30202. /**
  30203. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  30204. */
  30205. uvs2: Nullable<FloatArray>;
  30206. /**
  30207. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  30208. */
  30209. uvs3: Nullable<FloatArray>;
  30210. /**
  30211. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  30212. */
  30213. uvs4: Nullable<FloatArray>;
  30214. /**
  30215. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  30216. */
  30217. uvs5: Nullable<FloatArray>;
  30218. /**
  30219. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  30220. */
  30221. uvs6: Nullable<FloatArray>;
  30222. /**
  30223. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  30224. */
  30225. colors: Nullable<FloatArray>;
  30226. /**
  30227. * 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).
  30228. */
  30229. matricesIndices: Nullable<FloatArray>;
  30230. /**
  30231. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  30232. */
  30233. matricesWeights: Nullable<FloatArray>;
  30234. /**
  30235. * An array extending the number of possible indices
  30236. */
  30237. matricesIndicesExtra: Nullable<FloatArray>;
  30238. /**
  30239. * An array extending the number of possible weights when the number of indices is extended
  30240. */
  30241. matricesWeightsExtra: Nullable<FloatArray>;
  30242. /**
  30243. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  30244. */
  30245. indices: Nullable<IndicesArray>;
  30246. /**
  30247. * Uses the passed data array to set the set the values for the specified kind of data
  30248. * @param data a linear array of floating numbers
  30249. * @param kind the type of data that is being set, eg positions, colors etc
  30250. */
  30251. set(data: FloatArray, kind: string): void;
  30252. /**
  30253. * Associates the vertexData to the passed Mesh.
  30254. * Sets it as updatable or not (default `false`)
  30255. * @param mesh the mesh the vertexData is applied to
  30256. * @param updatable when used and having the value true allows new data to update the vertexData
  30257. * @returns the VertexData
  30258. */
  30259. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  30260. /**
  30261. * Associates the vertexData to the passed Geometry.
  30262. * Sets it as updatable or not (default `false`)
  30263. * @param geometry the geometry the vertexData is applied to
  30264. * @param updatable when used and having the value true allows new data to update the vertexData
  30265. * @returns VertexData
  30266. */
  30267. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  30268. /**
  30269. * Updates the associated mesh
  30270. * @param mesh the mesh to be updated
  30271. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  30272. * @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
  30273. * @returns VertexData
  30274. */
  30275. updateMesh(mesh: Mesh): VertexData;
  30276. /**
  30277. * Updates the associated geometry
  30278. * @param geometry the geometry to be updated
  30279. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  30280. * @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
  30281. * @returns VertexData.
  30282. */
  30283. updateGeometry(geometry: Geometry): VertexData;
  30284. private _applyTo;
  30285. private _update;
  30286. /**
  30287. * Transforms each position and each normal of the vertexData according to the passed Matrix
  30288. * @param matrix the transforming matrix
  30289. * @returns the VertexData
  30290. */
  30291. transform(matrix: Matrix): VertexData;
  30292. /**
  30293. * Merges the passed VertexData into the current one
  30294. * @param other the VertexData to be merged into the current one
  30295. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  30296. * @returns the modified VertexData
  30297. */
  30298. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  30299. private _mergeElement;
  30300. private _validate;
  30301. /**
  30302. * Serializes the VertexData
  30303. * @returns a serialized object
  30304. */
  30305. serialize(): any;
  30306. /**
  30307. * Extracts the vertexData from a mesh
  30308. * @param mesh the mesh from which to extract the VertexData
  30309. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  30310. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  30311. * @returns the object VertexData associated to the passed mesh
  30312. */
  30313. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  30314. /**
  30315. * Extracts the vertexData from the geometry
  30316. * @param geometry the geometry from which to extract the VertexData
  30317. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  30318. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  30319. * @returns the object VertexData associated to the passed mesh
  30320. */
  30321. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  30322. private static _ExtractFrom;
  30323. /**
  30324. * Creates the VertexData for a Ribbon
  30325. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  30326. * * pathArray array of paths, each of which an array of successive Vector3
  30327. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  30328. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  30329. * * 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
  30330. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30331. * * 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)
  30332. * * 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)
  30333. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  30334. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  30335. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  30336. * @returns the VertexData of the ribbon
  30337. */
  30338. static CreateRibbon(options: {
  30339. pathArray: Vector3[][];
  30340. closeArray?: boolean;
  30341. closePath?: boolean;
  30342. offset?: number;
  30343. sideOrientation?: number;
  30344. frontUVs?: Vector4;
  30345. backUVs?: Vector4;
  30346. invertUV?: boolean;
  30347. uvs?: Vector2[];
  30348. colors?: Color4[];
  30349. }): VertexData;
  30350. /**
  30351. * Creates the VertexData for a box
  30352. * @param options an object used to set the following optional parameters for the box, required but can be empty
  30353. * * size sets the width, height and depth of the box to the value of size, optional default 1
  30354. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  30355. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  30356. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  30357. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  30358. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  30359. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30360. * * 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)
  30361. * * 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)
  30362. * @returns the VertexData of the box
  30363. */
  30364. static CreateBox(options: {
  30365. size?: number;
  30366. width?: number;
  30367. height?: number;
  30368. depth?: number;
  30369. faceUV?: Vector4[];
  30370. faceColors?: Color4[];
  30371. sideOrientation?: number;
  30372. frontUVs?: Vector4;
  30373. backUVs?: Vector4;
  30374. }): VertexData;
  30375. /**
  30376. * Creates the VertexData for a tiled box
  30377. * @param options an object used to set the following optional parameters for the box, required but can be empty
  30378. * * faceTiles sets the pattern, tile size and number of tiles for a face
  30379. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  30380. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  30381. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30382. * @returns the VertexData of the box
  30383. */
  30384. static CreateTiledBox(options: {
  30385. pattern?: number;
  30386. width?: number;
  30387. height?: number;
  30388. depth?: number;
  30389. tileSize?: number;
  30390. tileWidth?: number;
  30391. tileHeight?: number;
  30392. alignHorizontal?: number;
  30393. alignVertical?: number;
  30394. faceUV?: Vector4[];
  30395. faceColors?: Color4[];
  30396. sideOrientation?: number;
  30397. }): VertexData;
  30398. /**
  30399. * Creates the VertexData for a tiled plane
  30400. * @param options an object used to set the following optional parameters for the box, required but can be empty
  30401. * * pattern a limited pattern arrangement depending on the number
  30402. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  30403. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  30404. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  30405. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30406. * * 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)
  30407. * * 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)
  30408. * @returns the VertexData of the tiled plane
  30409. */
  30410. static CreateTiledPlane(options: {
  30411. pattern?: number;
  30412. tileSize?: number;
  30413. tileWidth?: number;
  30414. tileHeight?: number;
  30415. size?: number;
  30416. width?: number;
  30417. height?: number;
  30418. alignHorizontal?: number;
  30419. alignVertical?: number;
  30420. sideOrientation?: number;
  30421. frontUVs?: Vector4;
  30422. backUVs?: Vector4;
  30423. }): VertexData;
  30424. /**
  30425. * Creates the VertexData for an ellipsoid, defaults to a sphere
  30426. * @param options an object used to set the following optional parameters for the box, required but can be empty
  30427. * * segments sets the number of horizontal strips optional, default 32
  30428. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  30429. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  30430. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  30431. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  30432. * * 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
  30433. * * 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
  30434. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30435. * * 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)
  30436. * * 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)
  30437. * @returns the VertexData of the ellipsoid
  30438. */
  30439. static CreateSphere(options: {
  30440. segments?: number;
  30441. diameter?: number;
  30442. diameterX?: number;
  30443. diameterY?: number;
  30444. diameterZ?: number;
  30445. arc?: number;
  30446. slice?: number;
  30447. sideOrientation?: number;
  30448. frontUVs?: Vector4;
  30449. backUVs?: Vector4;
  30450. }): VertexData;
  30451. /**
  30452. * Creates the VertexData for a cylinder, cone or prism
  30453. * @param options an object used to set the following optional parameters for the box, required but can be empty
  30454. * * height sets the height (y direction) of the cylinder, optional, default 2
  30455. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  30456. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  30457. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  30458. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  30459. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  30460. * * 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
  30461. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  30462. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  30463. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  30464. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  30465. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30466. * * 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)
  30467. * * 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)
  30468. * @returns the VertexData of the cylinder, cone or prism
  30469. */
  30470. static CreateCylinder(options: {
  30471. height?: number;
  30472. diameterTop?: number;
  30473. diameterBottom?: number;
  30474. diameter?: number;
  30475. tessellation?: number;
  30476. subdivisions?: number;
  30477. arc?: number;
  30478. faceColors?: Color4[];
  30479. faceUV?: Vector4[];
  30480. hasRings?: boolean;
  30481. enclose?: boolean;
  30482. sideOrientation?: number;
  30483. frontUVs?: Vector4;
  30484. backUVs?: Vector4;
  30485. }): VertexData;
  30486. /**
  30487. * Creates the VertexData for a torus
  30488. * @param options an object used to set the following optional parameters for the box, required but can be empty
  30489. * * diameter the diameter of the torus, optional default 1
  30490. * * thickness the diameter of the tube forming the torus, optional default 0.5
  30491. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  30492. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30493. * * 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)
  30494. * * 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)
  30495. * @returns the VertexData of the torus
  30496. */
  30497. static CreateTorus(options: {
  30498. diameter?: number;
  30499. thickness?: number;
  30500. tessellation?: number;
  30501. sideOrientation?: number;
  30502. frontUVs?: Vector4;
  30503. backUVs?: Vector4;
  30504. }): VertexData;
  30505. /**
  30506. * Creates the VertexData of the LineSystem
  30507. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  30508. * - lines an array of lines, each line being an array of successive Vector3
  30509. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  30510. * @returns the VertexData of the LineSystem
  30511. */
  30512. static CreateLineSystem(options: {
  30513. lines: Vector3[][];
  30514. colors?: Nullable<Color4[][]>;
  30515. }): VertexData;
  30516. /**
  30517. * Create the VertexData for a DashedLines
  30518. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  30519. * - points an array successive Vector3
  30520. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  30521. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  30522. * - dashNb the intended total number of dashes, optional, default 200
  30523. * @returns the VertexData for the DashedLines
  30524. */
  30525. static CreateDashedLines(options: {
  30526. points: Vector3[];
  30527. dashSize?: number;
  30528. gapSize?: number;
  30529. dashNb?: number;
  30530. }): VertexData;
  30531. /**
  30532. * Creates the VertexData for a Ground
  30533. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  30534. * - width the width (x direction) of the ground, optional, default 1
  30535. * - height the height (z direction) of the ground, optional, default 1
  30536. * - subdivisions the number of subdivisions per side, optional, default 1
  30537. * @returns the VertexData of the Ground
  30538. */
  30539. static CreateGround(options: {
  30540. width?: number;
  30541. height?: number;
  30542. subdivisions?: number;
  30543. subdivisionsX?: number;
  30544. subdivisionsY?: number;
  30545. }): VertexData;
  30546. /**
  30547. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  30548. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  30549. * * xmin the ground minimum X coordinate, optional, default -1
  30550. * * zmin the ground minimum Z coordinate, optional, default -1
  30551. * * xmax the ground maximum X coordinate, optional, default 1
  30552. * * zmax the ground maximum Z coordinate, optional, default 1
  30553. * * 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}
  30554. * * 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}
  30555. * @returns the VertexData of the TiledGround
  30556. */
  30557. static CreateTiledGround(options: {
  30558. xmin: number;
  30559. zmin: number;
  30560. xmax: number;
  30561. zmax: number;
  30562. subdivisions?: {
  30563. w: number;
  30564. h: number;
  30565. };
  30566. precision?: {
  30567. w: number;
  30568. h: number;
  30569. };
  30570. }): VertexData;
  30571. /**
  30572. * Creates the VertexData of the Ground designed from a heightmap
  30573. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  30574. * * width the width (x direction) of the ground
  30575. * * height the height (z direction) of the ground
  30576. * * subdivisions the number of subdivisions per side
  30577. * * minHeight the minimum altitude on the ground, optional, default 0
  30578. * * maxHeight the maximum altitude on the ground, optional default 1
  30579. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  30580. * * buffer the array holding the image color data
  30581. * * bufferWidth the width of image
  30582. * * bufferHeight the height of image
  30583. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  30584. * @returns the VertexData of the Ground designed from a heightmap
  30585. */
  30586. static CreateGroundFromHeightMap(options: {
  30587. width: number;
  30588. height: number;
  30589. subdivisions: number;
  30590. minHeight: number;
  30591. maxHeight: number;
  30592. colorFilter: Color3;
  30593. buffer: Uint8Array;
  30594. bufferWidth: number;
  30595. bufferHeight: number;
  30596. alphaFilter: number;
  30597. }): VertexData;
  30598. /**
  30599. * Creates the VertexData for a Plane
  30600. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  30601. * * size sets the width and height of the plane to the value of size, optional default 1
  30602. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  30603. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  30604. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30605. * * 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)
  30606. * * 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)
  30607. * @returns the VertexData of the box
  30608. */
  30609. static CreatePlane(options: {
  30610. size?: number;
  30611. width?: number;
  30612. height?: number;
  30613. sideOrientation?: number;
  30614. frontUVs?: Vector4;
  30615. backUVs?: Vector4;
  30616. }): VertexData;
  30617. /**
  30618. * Creates the VertexData of the Disc or regular Polygon
  30619. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  30620. * * radius the radius of the disc, optional default 0.5
  30621. * * tessellation the number of polygon sides, optional, default 64
  30622. * * 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
  30623. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30624. * * 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)
  30625. * * 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)
  30626. * @returns the VertexData of the box
  30627. */
  30628. static CreateDisc(options: {
  30629. radius?: number;
  30630. tessellation?: number;
  30631. arc?: number;
  30632. sideOrientation?: number;
  30633. frontUVs?: Vector4;
  30634. backUVs?: Vector4;
  30635. }): VertexData;
  30636. /**
  30637. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  30638. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  30639. * @param polygon a mesh built from polygonTriangulation.build()
  30640. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30641. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  30642. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  30643. * @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)
  30644. * @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)
  30645. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  30646. * @returns the VertexData of the Polygon
  30647. */
  30648. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  30649. /**
  30650. * Creates the VertexData of the IcoSphere
  30651. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  30652. * * radius the radius of the IcoSphere, optional default 1
  30653. * * radiusX allows stretching in the x direction, optional, default radius
  30654. * * radiusY allows stretching in the y direction, optional, default radius
  30655. * * radiusZ allows stretching in the z direction, optional, default radius
  30656. * * flat when true creates a flat shaded mesh, optional, default true
  30657. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  30658. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30659. * * 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)
  30660. * * 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)
  30661. * @returns the VertexData of the IcoSphere
  30662. */
  30663. static CreateIcoSphere(options: {
  30664. radius?: number;
  30665. radiusX?: number;
  30666. radiusY?: number;
  30667. radiusZ?: number;
  30668. flat?: boolean;
  30669. subdivisions?: number;
  30670. sideOrientation?: number;
  30671. frontUVs?: Vector4;
  30672. backUVs?: Vector4;
  30673. }): VertexData;
  30674. /**
  30675. * Creates the VertexData for a Polyhedron
  30676. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  30677. * * type provided types are:
  30678. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  30679. * * 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)
  30680. * * size the size of the IcoSphere, optional default 1
  30681. * * sizeX allows stretching in the x direction, optional, default size
  30682. * * sizeY allows stretching in the y direction, optional, default size
  30683. * * sizeZ allows stretching in the z direction, optional, default size
  30684. * * 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
  30685. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  30686. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  30687. * * flat when true creates a flat shaded mesh, optional, default true
  30688. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  30689. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30690. * * 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)
  30691. * * 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)
  30692. * @returns the VertexData of the Polyhedron
  30693. */
  30694. static CreatePolyhedron(options: {
  30695. type?: number;
  30696. size?: number;
  30697. sizeX?: number;
  30698. sizeY?: number;
  30699. sizeZ?: number;
  30700. custom?: any;
  30701. faceUV?: Vector4[];
  30702. faceColors?: Color4[];
  30703. flat?: boolean;
  30704. sideOrientation?: number;
  30705. frontUVs?: Vector4;
  30706. backUVs?: Vector4;
  30707. }): VertexData;
  30708. /**
  30709. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  30710. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  30711. * @returns the VertexData of the Capsule
  30712. */
  30713. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  30714. /**
  30715. * Creates the VertexData for a TorusKnot
  30716. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  30717. * * radius the radius of the torus knot, optional, default 2
  30718. * * tube the thickness of the tube, optional, default 0.5
  30719. * * radialSegments the number of sides on each tube segments, optional, default 32
  30720. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  30721. * * p the number of windings around the z axis, optional, default 2
  30722. * * q the number of windings around the x axis, optional, default 3
  30723. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30724. * * 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)
  30725. * * 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)
  30726. * @returns the VertexData of the Torus Knot
  30727. */
  30728. static CreateTorusKnot(options: {
  30729. radius?: number;
  30730. tube?: number;
  30731. radialSegments?: number;
  30732. tubularSegments?: number;
  30733. p?: number;
  30734. q?: number;
  30735. sideOrientation?: number;
  30736. frontUVs?: Vector4;
  30737. backUVs?: Vector4;
  30738. }): VertexData;
  30739. /**
  30740. * Compute normals for given positions and indices
  30741. * @param positions an array of vertex positions, [...., x, y, z, ......]
  30742. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  30743. * @param normals an array of vertex normals, [...., x, y, z, ......]
  30744. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  30745. * * facetNormals : optional array of facet normals (vector3)
  30746. * * facetPositions : optional array of facet positions (vector3)
  30747. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  30748. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  30749. * * bInfo : optional bounding info, required for facetPartitioning computation
  30750. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  30751. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  30752. * * useRightHandedSystem: optional boolean to for right handed system computation
  30753. * * depthSort : optional boolean to enable the facet depth sort computation
  30754. * * distanceTo : optional Vector3 to compute the facet depth from this location
  30755. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  30756. */
  30757. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  30758. facetNormals?: any;
  30759. facetPositions?: any;
  30760. facetPartitioning?: any;
  30761. ratio?: number;
  30762. bInfo?: any;
  30763. bbSize?: Vector3;
  30764. subDiv?: any;
  30765. useRightHandedSystem?: boolean;
  30766. depthSort?: boolean;
  30767. distanceTo?: Vector3;
  30768. depthSortedFacets?: any;
  30769. }): void;
  30770. /** @hidden */
  30771. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  30772. /**
  30773. * Applies VertexData created from the imported parameters to the geometry
  30774. * @param parsedVertexData the parsed data from an imported file
  30775. * @param geometry the geometry to apply the VertexData to
  30776. */
  30777. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  30778. }
  30779. }
  30780. declare module BABYLON {
  30781. /**
  30782. * Defines a target to use with MorphTargetManager
  30783. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  30784. */
  30785. export class MorphTarget implements IAnimatable {
  30786. /** defines the name of the target */
  30787. name: string;
  30788. /**
  30789. * Gets or sets the list of animations
  30790. */
  30791. animations: Animation[];
  30792. private _scene;
  30793. private _positions;
  30794. private _normals;
  30795. private _tangents;
  30796. private _uvs;
  30797. private _influence;
  30798. private _uniqueId;
  30799. /**
  30800. * Observable raised when the influence changes
  30801. */
  30802. onInfluenceChanged: Observable<boolean>;
  30803. /** @hidden */
  30804. _onDataLayoutChanged: Observable<void>;
  30805. /**
  30806. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  30807. */
  30808. get influence(): number;
  30809. set influence(influence: number);
  30810. /**
  30811. * Gets or sets the id of the morph Target
  30812. */
  30813. id: string;
  30814. private _animationPropertiesOverride;
  30815. /**
  30816. * Gets or sets the animation properties override
  30817. */
  30818. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  30819. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  30820. /**
  30821. * Creates a new MorphTarget
  30822. * @param name defines the name of the target
  30823. * @param influence defines the influence to use
  30824. * @param scene defines the scene the morphtarget belongs to
  30825. */
  30826. constructor(
  30827. /** defines the name of the target */
  30828. name: string, influence?: number, scene?: Nullable<Scene>);
  30829. /**
  30830. * Gets the unique ID of this manager
  30831. */
  30832. get uniqueId(): number;
  30833. /**
  30834. * Gets a boolean defining if the target contains position data
  30835. */
  30836. get hasPositions(): boolean;
  30837. /**
  30838. * Gets a boolean defining if the target contains normal data
  30839. */
  30840. get hasNormals(): boolean;
  30841. /**
  30842. * Gets a boolean defining if the target contains tangent data
  30843. */
  30844. get hasTangents(): boolean;
  30845. /**
  30846. * Gets a boolean defining if the target contains texture coordinates data
  30847. */
  30848. get hasUVs(): boolean;
  30849. /**
  30850. * Affects position data to this target
  30851. * @param data defines the position data to use
  30852. */
  30853. setPositions(data: Nullable<FloatArray>): void;
  30854. /**
  30855. * Gets the position data stored in this target
  30856. * @returns a FloatArray containing the position data (or null if not present)
  30857. */
  30858. getPositions(): Nullable<FloatArray>;
  30859. /**
  30860. * Affects normal data to this target
  30861. * @param data defines the normal data to use
  30862. */
  30863. setNormals(data: Nullable<FloatArray>): void;
  30864. /**
  30865. * Gets the normal data stored in this target
  30866. * @returns a FloatArray containing the normal data (or null if not present)
  30867. */
  30868. getNormals(): Nullable<FloatArray>;
  30869. /**
  30870. * Affects tangent data to this target
  30871. * @param data defines the tangent data to use
  30872. */
  30873. setTangents(data: Nullable<FloatArray>): void;
  30874. /**
  30875. * Gets the tangent data stored in this target
  30876. * @returns a FloatArray containing the tangent data (or null if not present)
  30877. */
  30878. getTangents(): Nullable<FloatArray>;
  30879. /**
  30880. * Affects texture coordinates data to this target
  30881. * @param data defines the texture coordinates data to use
  30882. */
  30883. setUVs(data: Nullable<FloatArray>): void;
  30884. /**
  30885. * Gets the texture coordinates data stored in this target
  30886. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  30887. */
  30888. getUVs(): Nullable<FloatArray>;
  30889. /**
  30890. * Clone the current target
  30891. * @returns a new MorphTarget
  30892. */
  30893. clone(): MorphTarget;
  30894. /**
  30895. * Serializes the current target into a Serialization object
  30896. * @returns the serialized object
  30897. */
  30898. serialize(): any;
  30899. /**
  30900. * Returns the string "MorphTarget"
  30901. * @returns "MorphTarget"
  30902. */
  30903. getClassName(): string;
  30904. /**
  30905. * Creates a new target from serialized data
  30906. * @param serializationObject defines the serialized data to use
  30907. * @returns a new MorphTarget
  30908. */
  30909. static Parse(serializationObject: any): MorphTarget;
  30910. /**
  30911. * Creates a MorphTarget from mesh data
  30912. * @param mesh defines the source mesh
  30913. * @param name defines the name to use for the new target
  30914. * @param influence defines the influence to attach to the target
  30915. * @returns a new MorphTarget
  30916. */
  30917. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  30918. }
  30919. }
  30920. declare module BABYLON {
  30921. /**
  30922. * This class is used to deform meshes using morphing between different targets
  30923. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  30924. */
  30925. export class MorphTargetManager {
  30926. private _targets;
  30927. private _targetInfluenceChangedObservers;
  30928. private _targetDataLayoutChangedObservers;
  30929. private _activeTargets;
  30930. private _scene;
  30931. private _influences;
  30932. private _supportsNormals;
  30933. private _supportsTangents;
  30934. private _supportsUVs;
  30935. private _vertexCount;
  30936. private _uniqueId;
  30937. private _tempInfluences;
  30938. /**
  30939. * Gets or sets a boolean indicating if normals must be morphed
  30940. */
  30941. enableNormalMorphing: boolean;
  30942. /**
  30943. * Gets or sets a boolean indicating if tangents must be morphed
  30944. */
  30945. enableTangentMorphing: boolean;
  30946. /**
  30947. * Gets or sets a boolean indicating if UV must be morphed
  30948. */
  30949. enableUVMorphing: boolean;
  30950. /**
  30951. * Creates a new MorphTargetManager
  30952. * @param scene defines the current scene
  30953. */
  30954. constructor(scene?: Nullable<Scene>);
  30955. /**
  30956. * Gets the unique ID of this manager
  30957. */
  30958. get uniqueId(): number;
  30959. /**
  30960. * Gets the number of vertices handled by this manager
  30961. */
  30962. get vertexCount(): number;
  30963. /**
  30964. * Gets a boolean indicating if this manager supports morphing of normals
  30965. */
  30966. get supportsNormals(): boolean;
  30967. /**
  30968. * Gets a boolean indicating if this manager supports morphing of tangents
  30969. */
  30970. get supportsTangents(): boolean;
  30971. /**
  30972. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  30973. */
  30974. get supportsUVs(): boolean;
  30975. /**
  30976. * Gets the number of targets stored in this manager
  30977. */
  30978. get numTargets(): number;
  30979. /**
  30980. * Gets the number of influencers (ie. the number of targets with influences > 0)
  30981. */
  30982. get numInfluencers(): number;
  30983. /**
  30984. * Gets the list of influences (one per target)
  30985. */
  30986. get influences(): Float32Array;
  30987. /**
  30988. * Gets the active target at specified index. An active target is a target with an influence > 0
  30989. * @param index defines the index to check
  30990. * @returns the requested target
  30991. */
  30992. getActiveTarget(index: number): MorphTarget;
  30993. /**
  30994. * Gets the target at specified index
  30995. * @param index defines the index to check
  30996. * @returns the requested target
  30997. */
  30998. getTarget(index: number): MorphTarget;
  30999. /**
  31000. * Add a new target to this manager
  31001. * @param target defines the target to add
  31002. */
  31003. addTarget(target: MorphTarget): void;
  31004. /**
  31005. * Removes a target from the manager
  31006. * @param target defines the target to remove
  31007. */
  31008. removeTarget(target: MorphTarget): void;
  31009. /**
  31010. * Clone the current manager
  31011. * @returns a new MorphTargetManager
  31012. */
  31013. clone(): MorphTargetManager;
  31014. /**
  31015. * Serializes the current manager into a Serialization object
  31016. * @returns the serialized object
  31017. */
  31018. serialize(): any;
  31019. private _syncActiveTargets;
  31020. /**
  31021. * Syncrhonize the targets with all the meshes using this morph target manager
  31022. */
  31023. synchronize(): void;
  31024. /**
  31025. * Creates a new MorphTargetManager from serialized data
  31026. * @param serializationObject defines the serialized data
  31027. * @param scene defines the hosting scene
  31028. * @returns the new MorphTargetManager
  31029. */
  31030. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  31031. }
  31032. }
  31033. declare module BABYLON {
  31034. /**
  31035. * Class used to represent a specific level of detail of a mesh
  31036. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  31037. */
  31038. export class MeshLODLevel {
  31039. /** Defines the distance where this level should start being displayed */
  31040. distance: number;
  31041. /** Defines the mesh to use to render this level */
  31042. mesh: Nullable<Mesh>;
  31043. /**
  31044. * Creates a new LOD level
  31045. * @param distance defines the distance where this level should star being displayed
  31046. * @param mesh defines the mesh to use to render this level
  31047. */
  31048. constructor(
  31049. /** Defines the distance where this level should start being displayed */
  31050. distance: number,
  31051. /** Defines the mesh to use to render this level */
  31052. mesh: Nullable<Mesh>);
  31053. }
  31054. }
  31055. declare module BABYLON {
  31056. /**
  31057. * Helper class used to generate a canvas to manipulate images
  31058. */
  31059. export class CanvasGenerator {
  31060. /**
  31061. * Create a new canvas (or offscreen canvas depending on the context)
  31062. * @param width defines the expected width
  31063. * @param height defines the expected height
  31064. * @return a new canvas or offscreen canvas
  31065. */
  31066. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  31067. }
  31068. }
  31069. declare module BABYLON {
  31070. /**
  31071. * Mesh representing the gorund
  31072. */
  31073. export class GroundMesh extends Mesh {
  31074. /** If octree should be generated */
  31075. generateOctree: boolean;
  31076. private _heightQuads;
  31077. /** @hidden */
  31078. _subdivisionsX: number;
  31079. /** @hidden */
  31080. _subdivisionsY: number;
  31081. /** @hidden */
  31082. _width: number;
  31083. /** @hidden */
  31084. _height: number;
  31085. /** @hidden */
  31086. _minX: number;
  31087. /** @hidden */
  31088. _maxX: number;
  31089. /** @hidden */
  31090. _minZ: number;
  31091. /** @hidden */
  31092. _maxZ: number;
  31093. constructor(name: string, scene: Scene);
  31094. /**
  31095. * "GroundMesh"
  31096. * @returns "GroundMesh"
  31097. */
  31098. getClassName(): string;
  31099. /**
  31100. * The minimum of x and y subdivisions
  31101. */
  31102. get subdivisions(): number;
  31103. /**
  31104. * X subdivisions
  31105. */
  31106. get subdivisionsX(): number;
  31107. /**
  31108. * Y subdivisions
  31109. */
  31110. get subdivisionsY(): number;
  31111. /**
  31112. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  31113. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  31114. * @param chunksCount the number of subdivisions for x and y
  31115. * @param octreeBlocksSize (Default: 32)
  31116. */
  31117. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  31118. /**
  31119. * Returns a height (y) value in the Worl system :
  31120. * the ground altitude at the coordinates (x, z) expressed in the World system.
  31121. * @param x x coordinate
  31122. * @param z z coordinate
  31123. * @returns the ground y position if (x, z) are outside the ground surface.
  31124. */
  31125. getHeightAtCoordinates(x: number, z: number): number;
  31126. /**
  31127. * Returns a normalized vector (Vector3) orthogonal to the ground
  31128. * at the ground coordinates (x, z) expressed in the World system.
  31129. * @param x x coordinate
  31130. * @param z z coordinate
  31131. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  31132. */
  31133. getNormalAtCoordinates(x: number, z: number): Vector3;
  31134. /**
  31135. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  31136. * at the ground coordinates (x, z) expressed in the World system.
  31137. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  31138. * @param x x coordinate
  31139. * @param z z coordinate
  31140. * @param ref vector to store the result
  31141. * @returns the GroundMesh.
  31142. */
  31143. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  31144. /**
  31145. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  31146. * if the ground has been updated.
  31147. * This can be used in the render loop.
  31148. * @returns the GroundMesh.
  31149. */
  31150. updateCoordinateHeights(): GroundMesh;
  31151. private _getFacetAt;
  31152. private _initHeightQuads;
  31153. private _computeHeightQuads;
  31154. /**
  31155. * Serializes this ground mesh
  31156. * @param serializationObject object to write serialization to
  31157. */
  31158. serialize(serializationObject: any): void;
  31159. /**
  31160. * Parses a serialized ground mesh
  31161. * @param parsedMesh the serialized mesh
  31162. * @param scene the scene to create the ground mesh in
  31163. * @returns the created ground mesh
  31164. */
  31165. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  31166. }
  31167. }
  31168. declare module BABYLON {
  31169. /**
  31170. * Interface for Physics-Joint data
  31171. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31172. */
  31173. export interface PhysicsJointData {
  31174. /**
  31175. * The main pivot of the joint
  31176. */
  31177. mainPivot?: Vector3;
  31178. /**
  31179. * The connected pivot of the joint
  31180. */
  31181. connectedPivot?: Vector3;
  31182. /**
  31183. * The main axis of the joint
  31184. */
  31185. mainAxis?: Vector3;
  31186. /**
  31187. * The connected axis of the joint
  31188. */
  31189. connectedAxis?: Vector3;
  31190. /**
  31191. * The collision of the joint
  31192. */
  31193. collision?: boolean;
  31194. /**
  31195. * Native Oimo/Cannon/Energy data
  31196. */
  31197. nativeParams?: any;
  31198. }
  31199. /**
  31200. * This is a holder class for the physics joint created by the physics plugin
  31201. * It holds a set of functions to control the underlying joint
  31202. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31203. */
  31204. export class PhysicsJoint {
  31205. /**
  31206. * The type of the physics joint
  31207. */
  31208. type: number;
  31209. /**
  31210. * The data for the physics joint
  31211. */
  31212. jointData: PhysicsJointData;
  31213. private _physicsJoint;
  31214. protected _physicsPlugin: IPhysicsEnginePlugin;
  31215. /**
  31216. * Initializes the physics joint
  31217. * @param type The type of the physics joint
  31218. * @param jointData The data for the physics joint
  31219. */
  31220. constructor(
  31221. /**
  31222. * The type of the physics joint
  31223. */
  31224. type: number,
  31225. /**
  31226. * The data for the physics joint
  31227. */
  31228. jointData: PhysicsJointData);
  31229. /**
  31230. * Gets the physics joint
  31231. */
  31232. get physicsJoint(): any;
  31233. /**
  31234. * Sets the physics joint
  31235. */
  31236. set physicsJoint(newJoint: any);
  31237. /**
  31238. * Sets the physics plugin
  31239. */
  31240. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  31241. /**
  31242. * Execute a function that is physics-plugin specific.
  31243. * @param {Function} func the function that will be executed.
  31244. * It accepts two parameters: the physics world and the physics joint
  31245. */
  31246. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  31247. /**
  31248. * Distance-Joint type
  31249. */
  31250. static DistanceJoint: number;
  31251. /**
  31252. * Hinge-Joint type
  31253. */
  31254. static HingeJoint: number;
  31255. /**
  31256. * Ball-and-Socket joint type
  31257. */
  31258. static BallAndSocketJoint: number;
  31259. /**
  31260. * Wheel-Joint type
  31261. */
  31262. static WheelJoint: number;
  31263. /**
  31264. * Slider-Joint type
  31265. */
  31266. static SliderJoint: number;
  31267. /**
  31268. * Prismatic-Joint type
  31269. */
  31270. static PrismaticJoint: number;
  31271. /**
  31272. * Universal-Joint type
  31273. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  31274. */
  31275. static UniversalJoint: number;
  31276. /**
  31277. * Hinge-Joint 2 type
  31278. */
  31279. static Hinge2Joint: number;
  31280. /**
  31281. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  31282. */
  31283. static PointToPointJoint: number;
  31284. /**
  31285. * Spring-Joint type
  31286. */
  31287. static SpringJoint: number;
  31288. /**
  31289. * Lock-Joint type
  31290. */
  31291. static LockJoint: number;
  31292. }
  31293. /**
  31294. * A class representing a physics distance joint
  31295. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31296. */
  31297. export class DistanceJoint extends PhysicsJoint {
  31298. /**
  31299. *
  31300. * @param jointData The data for the Distance-Joint
  31301. */
  31302. constructor(jointData: DistanceJointData);
  31303. /**
  31304. * Update the predefined distance.
  31305. * @param maxDistance The maximum preferred distance
  31306. * @param minDistance The minimum preferred distance
  31307. */
  31308. updateDistance(maxDistance: number, minDistance?: number): void;
  31309. }
  31310. /**
  31311. * Represents a Motor-Enabled Joint
  31312. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31313. */
  31314. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  31315. /**
  31316. * Initializes the Motor-Enabled Joint
  31317. * @param type The type of the joint
  31318. * @param jointData The physica joint data for the joint
  31319. */
  31320. constructor(type: number, jointData: PhysicsJointData);
  31321. /**
  31322. * Set the motor values.
  31323. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31324. * @param force the force to apply
  31325. * @param maxForce max force for this motor.
  31326. */
  31327. setMotor(force?: number, maxForce?: number): void;
  31328. /**
  31329. * Set the motor's limits.
  31330. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31331. * @param upperLimit The upper limit of the motor
  31332. * @param lowerLimit The lower limit of the motor
  31333. */
  31334. setLimit(upperLimit: number, lowerLimit?: number): void;
  31335. }
  31336. /**
  31337. * This class represents a single physics Hinge-Joint
  31338. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31339. */
  31340. export class HingeJoint extends MotorEnabledJoint {
  31341. /**
  31342. * Initializes the Hinge-Joint
  31343. * @param jointData The joint data for the Hinge-Joint
  31344. */
  31345. constructor(jointData: PhysicsJointData);
  31346. /**
  31347. * Set the motor values.
  31348. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31349. * @param {number} force the force to apply
  31350. * @param {number} maxForce max force for this motor.
  31351. */
  31352. setMotor(force?: number, maxForce?: number): void;
  31353. /**
  31354. * Set the motor's limits.
  31355. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31356. * @param upperLimit The upper limit of the motor
  31357. * @param lowerLimit The lower limit of the motor
  31358. */
  31359. setLimit(upperLimit: number, lowerLimit?: number): void;
  31360. }
  31361. /**
  31362. * This class represents a dual hinge physics joint (same as wheel joint)
  31363. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31364. */
  31365. export class Hinge2Joint extends MotorEnabledJoint {
  31366. /**
  31367. * Initializes the Hinge2-Joint
  31368. * @param jointData The joint data for the Hinge2-Joint
  31369. */
  31370. constructor(jointData: PhysicsJointData);
  31371. /**
  31372. * Set the motor values.
  31373. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31374. * @param {number} targetSpeed the speed the motor is to reach
  31375. * @param {number} maxForce max force for this motor.
  31376. * @param {motorIndex} the motor's index, 0 or 1.
  31377. */
  31378. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  31379. /**
  31380. * Set the motor limits.
  31381. * Attention, this function is plugin specific. Engines won't react 100% the same.
  31382. * @param {number} upperLimit the upper limit
  31383. * @param {number} lowerLimit lower limit
  31384. * @param {motorIndex} the motor's index, 0 or 1.
  31385. */
  31386. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  31387. }
  31388. /**
  31389. * Interface for a motor enabled joint
  31390. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31391. */
  31392. export interface IMotorEnabledJoint {
  31393. /**
  31394. * Physics joint
  31395. */
  31396. physicsJoint: any;
  31397. /**
  31398. * Sets the motor of the motor-enabled joint
  31399. * @param force The force of the motor
  31400. * @param maxForce The maximum force of the motor
  31401. * @param motorIndex The index of the motor
  31402. */
  31403. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  31404. /**
  31405. * Sets the limit of the motor
  31406. * @param upperLimit The upper limit of the motor
  31407. * @param lowerLimit The lower limit of the motor
  31408. * @param motorIndex The index of the motor
  31409. */
  31410. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  31411. }
  31412. /**
  31413. * Joint data for a Distance-Joint
  31414. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31415. */
  31416. export interface DistanceJointData extends PhysicsJointData {
  31417. /**
  31418. * Max distance the 2 joint objects can be apart
  31419. */
  31420. maxDistance: number;
  31421. }
  31422. /**
  31423. * Joint data from a spring joint
  31424. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31425. */
  31426. export interface SpringJointData extends PhysicsJointData {
  31427. /**
  31428. * Length of the spring
  31429. */
  31430. length: number;
  31431. /**
  31432. * Stiffness of the spring
  31433. */
  31434. stiffness: number;
  31435. /**
  31436. * Damping of the spring
  31437. */
  31438. damping: number;
  31439. /** this callback will be called when applying the force to the impostors. */
  31440. forceApplicationCallback: () => void;
  31441. }
  31442. }
  31443. declare module BABYLON {
  31444. /**
  31445. * Holds the data for the raycast result
  31446. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31447. */
  31448. export class PhysicsRaycastResult {
  31449. private _hasHit;
  31450. private _hitDistance;
  31451. private _hitNormalWorld;
  31452. private _hitPointWorld;
  31453. private _rayFromWorld;
  31454. private _rayToWorld;
  31455. /**
  31456. * Gets if there was a hit
  31457. */
  31458. get hasHit(): boolean;
  31459. /**
  31460. * Gets the distance from the hit
  31461. */
  31462. get hitDistance(): number;
  31463. /**
  31464. * Gets the hit normal/direction in the world
  31465. */
  31466. get hitNormalWorld(): Vector3;
  31467. /**
  31468. * Gets the hit point in the world
  31469. */
  31470. get hitPointWorld(): Vector3;
  31471. /**
  31472. * Gets the ray "start point" of the ray in the world
  31473. */
  31474. get rayFromWorld(): Vector3;
  31475. /**
  31476. * Gets the ray "end point" of the ray in the world
  31477. */
  31478. get rayToWorld(): Vector3;
  31479. /**
  31480. * Sets the hit data (normal & point in world space)
  31481. * @param hitNormalWorld defines the normal in world space
  31482. * @param hitPointWorld defines the point in world space
  31483. */
  31484. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  31485. /**
  31486. * Sets the distance from the start point to the hit point
  31487. * @param distance
  31488. */
  31489. setHitDistance(distance: number): void;
  31490. /**
  31491. * Calculates the distance manually
  31492. */
  31493. calculateHitDistance(): void;
  31494. /**
  31495. * Resets all the values to default
  31496. * @param from The from point on world space
  31497. * @param to The to point on world space
  31498. */
  31499. reset(from?: Vector3, to?: Vector3): void;
  31500. }
  31501. /**
  31502. * Interface for the size containing width and height
  31503. */
  31504. interface IXYZ {
  31505. /**
  31506. * X
  31507. */
  31508. x: number;
  31509. /**
  31510. * Y
  31511. */
  31512. y: number;
  31513. /**
  31514. * Z
  31515. */
  31516. z: number;
  31517. }
  31518. }
  31519. declare module BABYLON {
  31520. /**
  31521. * Interface used to describe a physics joint
  31522. */
  31523. export interface PhysicsImpostorJoint {
  31524. /** Defines the main impostor to which the joint is linked */
  31525. mainImpostor: PhysicsImpostor;
  31526. /** Defines the impostor that is connected to the main impostor using this joint */
  31527. connectedImpostor: PhysicsImpostor;
  31528. /** Defines the joint itself */
  31529. joint: PhysicsJoint;
  31530. }
  31531. /** @hidden */
  31532. export interface IPhysicsEnginePlugin {
  31533. world: any;
  31534. name: string;
  31535. setGravity(gravity: Vector3): void;
  31536. setTimeStep(timeStep: number): void;
  31537. getTimeStep(): number;
  31538. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  31539. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  31540. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  31541. generatePhysicsBody(impostor: PhysicsImpostor): void;
  31542. removePhysicsBody(impostor: PhysicsImpostor): void;
  31543. generateJoint(joint: PhysicsImpostorJoint): void;
  31544. removeJoint(joint: PhysicsImpostorJoint): void;
  31545. isSupported(): boolean;
  31546. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  31547. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  31548. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  31549. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  31550. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  31551. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  31552. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  31553. getBodyMass(impostor: PhysicsImpostor): number;
  31554. getBodyFriction(impostor: PhysicsImpostor): number;
  31555. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  31556. getBodyRestitution(impostor: PhysicsImpostor): number;
  31557. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  31558. getBodyPressure?(impostor: PhysicsImpostor): number;
  31559. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  31560. getBodyStiffness?(impostor: PhysicsImpostor): number;
  31561. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  31562. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  31563. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  31564. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  31565. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  31566. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  31567. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  31568. sleepBody(impostor: PhysicsImpostor): void;
  31569. wakeUpBody(impostor: PhysicsImpostor): void;
  31570. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  31571. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  31572. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  31573. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  31574. getRadius(impostor: PhysicsImpostor): number;
  31575. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  31576. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  31577. dispose(): void;
  31578. }
  31579. /**
  31580. * Interface used to define a physics engine
  31581. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31582. */
  31583. export interface IPhysicsEngine {
  31584. /**
  31585. * Gets the gravity vector used by the simulation
  31586. */
  31587. gravity: Vector3;
  31588. /**
  31589. * Sets the gravity vector used by the simulation
  31590. * @param gravity defines the gravity vector to use
  31591. */
  31592. setGravity(gravity: Vector3): void;
  31593. /**
  31594. * Set the time step of the physics engine.
  31595. * Default is 1/60.
  31596. * To slow it down, enter 1/600 for example.
  31597. * To speed it up, 1/30
  31598. * @param newTimeStep the new timestep to apply to this world.
  31599. */
  31600. setTimeStep(newTimeStep: number): void;
  31601. /**
  31602. * Get the time step of the physics engine.
  31603. * @returns the current time step
  31604. */
  31605. getTimeStep(): number;
  31606. /**
  31607. * Set the sub time step of the physics engine.
  31608. * Default is 0 meaning there is no sub steps
  31609. * To increase physics resolution precision, set a small value (like 1 ms)
  31610. * @param subTimeStep defines the new sub timestep used for physics resolution.
  31611. */
  31612. setSubTimeStep(subTimeStep: number): void;
  31613. /**
  31614. * Get the sub time step of the physics engine.
  31615. * @returns the current sub time step
  31616. */
  31617. getSubTimeStep(): number;
  31618. /**
  31619. * Release all resources
  31620. */
  31621. dispose(): void;
  31622. /**
  31623. * Gets the name of the current physics plugin
  31624. * @returns the name of the plugin
  31625. */
  31626. getPhysicsPluginName(): string;
  31627. /**
  31628. * Adding a new impostor for the impostor tracking.
  31629. * This will be done by the impostor itself.
  31630. * @param impostor the impostor to add
  31631. */
  31632. addImpostor(impostor: PhysicsImpostor): void;
  31633. /**
  31634. * Remove an impostor from the engine.
  31635. * This impostor and its mesh will not longer be updated by the physics engine.
  31636. * @param impostor the impostor to remove
  31637. */
  31638. removeImpostor(impostor: PhysicsImpostor): void;
  31639. /**
  31640. * Add a joint to the physics engine
  31641. * @param mainImpostor defines the main impostor to which the joint is added.
  31642. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  31643. * @param joint defines the joint that will connect both impostors.
  31644. */
  31645. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  31646. /**
  31647. * Removes a joint from the simulation
  31648. * @param mainImpostor defines the impostor used with the joint
  31649. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  31650. * @param joint defines the joint to remove
  31651. */
  31652. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  31653. /**
  31654. * Gets the current plugin used to run the simulation
  31655. * @returns current plugin
  31656. */
  31657. getPhysicsPlugin(): IPhysicsEnginePlugin;
  31658. /**
  31659. * Gets the list of physic impostors
  31660. * @returns an array of PhysicsImpostor
  31661. */
  31662. getImpostors(): Array<PhysicsImpostor>;
  31663. /**
  31664. * Gets the impostor for a physics enabled object
  31665. * @param object defines the object impersonated by the impostor
  31666. * @returns the PhysicsImpostor or null if not found
  31667. */
  31668. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  31669. /**
  31670. * Gets the impostor for a physics body object
  31671. * @param body defines physics body used by the impostor
  31672. * @returns the PhysicsImpostor or null if not found
  31673. */
  31674. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  31675. /**
  31676. * Does a raycast in the physics world
  31677. * @param from when should the ray start?
  31678. * @param to when should the ray end?
  31679. * @returns PhysicsRaycastResult
  31680. */
  31681. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  31682. /**
  31683. * Called by the scene. No need to call it.
  31684. * @param delta defines the timespam between frames
  31685. */
  31686. _step(delta: number): void;
  31687. }
  31688. }
  31689. declare module BABYLON {
  31690. /**
  31691. * The interface for the physics imposter parameters
  31692. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31693. */
  31694. export interface PhysicsImpostorParameters {
  31695. /**
  31696. * The mass of the physics imposter
  31697. */
  31698. mass: number;
  31699. /**
  31700. * The friction of the physics imposter
  31701. */
  31702. friction?: number;
  31703. /**
  31704. * The coefficient of restitution of the physics imposter
  31705. */
  31706. restitution?: number;
  31707. /**
  31708. * The native options of the physics imposter
  31709. */
  31710. nativeOptions?: any;
  31711. /**
  31712. * Specifies if the parent should be ignored
  31713. */
  31714. ignoreParent?: boolean;
  31715. /**
  31716. * Specifies if bi-directional transformations should be disabled
  31717. */
  31718. disableBidirectionalTransformation?: boolean;
  31719. /**
  31720. * The pressure inside the physics imposter, soft object only
  31721. */
  31722. pressure?: number;
  31723. /**
  31724. * The stiffness the physics imposter, soft object only
  31725. */
  31726. stiffness?: number;
  31727. /**
  31728. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  31729. */
  31730. velocityIterations?: number;
  31731. /**
  31732. * The number of iterations used in maintaining consistent vertex positions, soft object only
  31733. */
  31734. positionIterations?: number;
  31735. /**
  31736. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  31737. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  31738. * Add to fix multiple points
  31739. */
  31740. fixedPoints?: number;
  31741. /**
  31742. * The collision margin around a soft object
  31743. */
  31744. margin?: number;
  31745. /**
  31746. * The collision margin around a soft object
  31747. */
  31748. damping?: number;
  31749. /**
  31750. * The path for a rope based on an extrusion
  31751. */
  31752. path?: any;
  31753. /**
  31754. * The shape of an extrusion used for a rope based on an extrusion
  31755. */
  31756. shape?: any;
  31757. }
  31758. /**
  31759. * Interface for a physics-enabled object
  31760. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31761. */
  31762. export interface IPhysicsEnabledObject {
  31763. /**
  31764. * The position of the physics-enabled object
  31765. */
  31766. position: Vector3;
  31767. /**
  31768. * The rotation of the physics-enabled object
  31769. */
  31770. rotationQuaternion: Nullable<Quaternion>;
  31771. /**
  31772. * The scale of the physics-enabled object
  31773. */
  31774. scaling: Vector3;
  31775. /**
  31776. * The rotation of the physics-enabled object
  31777. */
  31778. rotation?: Vector3;
  31779. /**
  31780. * The parent of the physics-enabled object
  31781. */
  31782. parent?: any;
  31783. /**
  31784. * The bounding info of the physics-enabled object
  31785. * @returns The bounding info of the physics-enabled object
  31786. */
  31787. getBoundingInfo(): BoundingInfo;
  31788. /**
  31789. * Computes the world matrix
  31790. * @param force Specifies if the world matrix should be computed by force
  31791. * @returns A world matrix
  31792. */
  31793. computeWorldMatrix(force: boolean): Matrix;
  31794. /**
  31795. * Gets the world matrix
  31796. * @returns A world matrix
  31797. */
  31798. getWorldMatrix?(): Matrix;
  31799. /**
  31800. * Gets the child meshes
  31801. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  31802. * @returns An array of abstract meshes
  31803. */
  31804. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  31805. /**
  31806. * Gets the vertex data
  31807. * @param kind The type of vertex data
  31808. * @returns A nullable array of numbers, or a float32 array
  31809. */
  31810. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  31811. /**
  31812. * Gets the indices from the mesh
  31813. * @returns A nullable array of index arrays
  31814. */
  31815. getIndices?(): Nullable<IndicesArray>;
  31816. /**
  31817. * Gets the scene from the mesh
  31818. * @returns the indices array or null
  31819. */
  31820. getScene?(): Scene;
  31821. /**
  31822. * Gets the absolute position from the mesh
  31823. * @returns the absolute position
  31824. */
  31825. getAbsolutePosition(): Vector3;
  31826. /**
  31827. * Gets the absolute pivot point from the mesh
  31828. * @returns the absolute pivot point
  31829. */
  31830. getAbsolutePivotPoint(): Vector3;
  31831. /**
  31832. * Rotates the mesh
  31833. * @param axis The axis of rotation
  31834. * @param amount The amount of rotation
  31835. * @param space The space of the rotation
  31836. * @returns The rotation transform node
  31837. */
  31838. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  31839. /**
  31840. * Translates the mesh
  31841. * @param axis The axis of translation
  31842. * @param distance The distance of translation
  31843. * @param space The space of the translation
  31844. * @returns The transform node
  31845. */
  31846. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  31847. /**
  31848. * Sets the absolute position of the mesh
  31849. * @param absolutePosition The absolute position of the mesh
  31850. * @returns The transform node
  31851. */
  31852. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  31853. /**
  31854. * Gets the class name of the mesh
  31855. * @returns The class name
  31856. */
  31857. getClassName(): string;
  31858. }
  31859. /**
  31860. * Represents a physics imposter
  31861. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  31862. */
  31863. export class PhysicsImpostor {
  31864. /**
  31865. * The physics-enabled object used as the physics imposter
  31866. */
  31867. object: IPhysicsEnabledObject;
  31868. /**
  31869. * The type of the physics imposter
  31870. */
  31871. type: number;
  31872. private _options;
  31873. private _scene?;
  31874. /**
  31875. * The default object size of the imposter
  31876. */
  31877. static DEFAULT_OBJECT_SIZE: Vector3;
  31878. /**
  31879. * The identity quaternion of the imposter
  31880. */
  31881. static IDENTITY_QUATERNION: Quaternion;
  31882. /** @hidden */
  31883. _pluginData: any;
  31884. private _physicsEngine;
  31885. private _physicsBody;
  31886. private _bodyUpdateRequired;
  31887. private _onBeforePhysicsStepCallbacks;
  31888. private _onAfterPhysicsStepCallbacks;
  31889. /** @hidden */
  31890. _onPhysicsCollideCallbacks: Array<{
  31891. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  31892. otherImpostors: Array<PhysicsImpostor>;
  31893. }>;
  31894. private _deltaPosition;
  31895. private _deltaRotation;
  31896. private _deltaRotationConjugated;
  31897. /** @hidden */
  31898. _isFromLine: boolean;
  31899. private _parent;
  31900. private _isDisposed;
  31901. private static _tmpVecs;
  31902. private static _tmpQuat;
  31903. /**
  31904. * Specifies if the physics imposter is disposed
  31905. */
  31906. get isDisposed(): boolean;
  31907. /**
  31908. * Gets the mass of the physics imposter
  31909. */
  31910. get mass(): number;
  31911. set mass(value: number);
  31912. /**
  31913. * Gets the coefficient of friction
  31914. */
  31915. get friction(): number;
  31916. /**
  31917. * Sets the coefficient of friction
  31918. */
  31919. set friction(value: number);
  31920. /**
  31921. * Gets the coefficient of restitution
  31922. */
  31923. get restitution(): number;
  31924. /**
  31925. * Sets the coefficient of restitution
  31926. */
  31927. set restitution(value: number);
  31928. /**
  31929. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  31930. */
  31931. get pressure(): number;
  31932. /**
  31933. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  31934. */
  31935. set pressure(value: number);
  31936. /**
  31937. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  31938. */
  31939. get stiffness(): number;
  31940. /**
  31941. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  31942. */
  31943. set stiffness(value: number);
  31944. /**
  31945. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  31946. */
  31947. get velocityIterations(): number;
  31948. /**
  31949. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  31950. */
  31951. set velocityIterations(value: number);
  31952. /**
  31953. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  31954. */
  31955. get positionIterations(): number;
  31956. /**
  31957. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  31958. */
  31959. set positionIterations(value: number);
  31960. /**
  31961. * The unique id of the physics imposter
  31962. * set by the physics engine when adding this impostor to the array
  31963. */
  31964. uniqueId: number;
  31965. /**
  31966. * @hidden
  31967. */
  31968. soft: boolean;
  31969. /**
  31970. * @hidden
  31971. */
  31972. segments: number;
  31973. private _joints;
  31974. /**
  31975. * Initializes the physics imposter
  31976. * @param object The physics-enabled object used as the physics imposter
  31977. * @param type The type of the physics imposter
  31978. * @param _options The options for the physics imposter
  31979. * @param _scene The Babylon scene
  31980. */
  31981. constructor(
  31982. /**
  31983. * The physics-enabled object used as the physics imposter
  31984. */
  31985. object: IPhysicsEnabledObject,
  31986. /**
  31987. * The type of the physics imposter
  31988. */
  31989. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  31990. /**
  31991. * This function will completly initialize this impostor.
  31992. * It will create a new body - but only if this mesh has no parent.
  31993. * If it has, this impostor will not be used other than to define the impostor
  31994. * of the child mesh.
  31995. * @hidden
  31996. */
  31997. _init(): void;
  31998. private _getPhysicsParent;
  31999. /**
  32000. * Should a new body be generated.
  32001. * @returns boolean specifying if body initialization is required
  32002. */
  32003. isBodyInitRequired(): boolean;
  32004. /**
  32005. * Sets the updated scaling
  32006. * @param updated Specifies if the scaling is updated
  32007. */
  32008. setScalingUpdated(): void;
  32009. /**
  32010. * Force a regeneration of this or the parent's impostor's body.
  32011. * Use under cautious - This will remove all joints already implemented.
  32012. */
  32013. forceUpdate(): void;
  32014. /**
  32015. * Gets the body that holds this impostor. Either its own, or its parent.
  32016. */
  32017. get physicsBody(): any;
  32018. /**
  32019. * Get the parent of the physics imposter
  32020. * @returns Physics imposter or null
  32021. */
  32022. get parent(): Nullable<PhysicsImpostor>;
  32023. /**
  32024. * Sets the parent of the physics imposter
  32025. */
  32026. set parent(value: Nullable<PhysicsImpostor>);
  32027. /**
  32028. * Set the physics body. Used mainly by the physics engine/plugin
  32029. */
  32030. set physicsBody(physicsBody: any);
  32031. /**
  32032. * Resets the update flags
  32033. */
  32034. resetUpdateFlags(): void;
  32035. /**
  32036. * Gets the object extend size
  32037. * @returns the object extend size
  32038. */
  32039. getObjectExtendSize(): Vector3;
  32040. /**
  32041. * Gets the object center
  32042. * @returns The object center
  32043. */
  32044. getObjectCenter(): Vector3;
  32045. /**
  32046. * Get a specific parameter from the options parameters
  32047. * @param paramName The object parameter name
  32048. * @returns The object parameter
  32049. */
  32050. getParam(paramName: string): any;
  32051. /**
  32052. * Sets a specific parameter in the options given to the physics plugin
  32053. * @param paramName The parameter name
  32054. * @param value The value of the parameter
  32055. */
  32056. setParam(paramName: string, value: number): void;
  32057. /**
  32058. * Specifically change the body's mass option. Won't recreate the physics body object
  32059. * @param mass The mass of the physics imposter
  32060. */
  32061. setMass(mass: number): void;
  32062. /**
  32063. * Gets the linear velocity
  32064. * @returns linear velocity or null
  32065. */
  32066. getLinearVelocity(): Nullable<Vector3>;
  32067. /**
  32068. * Sets the linear velocity
  32069. * @param velocity linear velocity or null
  32070. */
  32071. setLinearVelocity(velocity: Nullable<Vector3>): void;
  32072. /**
  32073. * Gets the angular velocity
  32074. * @returns angular velocity or null
  32075. */
  32076. getAngularVelocity(): Nullable<Vector3>;
  32077. /**
  32078. * Sets the angular velocity
  32079. * @param velocity The velocity or null
  32080. */
  32081. setAngularVelocity(velocity: Nullable<Vector3>): void;
  32082. /**
  32083. * Execute a function with the physics plugin native code
  32084. * Provide a function the will have two variables - the world object and the physics body object
  32085. * @param func The function to execute with the physics plugin native code
  32086. */
  32087. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  32088. /**
  32089. * Register a function that will be executed before the physics world is stepping forward
  32090. * @param func The function to execute before the physics world is stepped forward
  32091. */
  32092. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  32093. /**
  32094. * Unregister a function that will be executed before the physics world is stepping forward
  32095. * @param func The function to execute before the physics world is stepped forward
  32096. */
  32097. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  32098. /**
  32099. * Register a function that will be executed after the physics step
  32100. * @param func The function to execute after physics step
  32101. */
  32102. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  32103. /**
  32104. * Unregisters a function that will be executed after the physics step
  32105. * @param func The function to execute after physics step
  32106. */
  32107. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  32108. /**
  32109. * register a function that will be executed when this impostor collides against a different body
  32110. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  32111. * @param func Callback that is executed on collision
  32112. */
  32113. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  32114. /**
  32115. * Unregisters the physics imposter on contact
  32116. * @param collideAgainst The physics object to collide against
  32117. * @param func Callback to execute on collision
  32118. */
  32119. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  32120. private _tmpQuat;
  32121. private _tmpQuat2;
  32122. /**
  32123. * Get the parent rotation
  32124. * @returns The parent rotation
  32125. */
  32126. getParentsRotation(): Quaternion;
  32127. /**
  32128. * this function is executed by the physics engine.
  32129. */
  32130. beforeStep: () => void;
  32131. /**
  32132. * this function is executed by the physics engine
  32133. */
  32134. afterStep: () => void;
  32135. /**
  32136. * Legacy collision detection event support
  32137. */
  32138. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  32139. /**
  32140. * event and body object due to cannon's event-based architecture.
  32141. */
  32142. onCollide: (e: {
  32143. body: any;
  32144. }) => void;
  32145. /**
  32146. * Apply a force
  32147. * @param force The force to apply
  32148. * @param contactPoint The contact point for the force
  32149. * @returns The physics imposter
  32150. */
  32151. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  32152. /**
  32153. * Apply an impulse
  32154. * @param force The impulse force
  32155. * @param contactPoint The contact point for the impulse force
  32156. * @returns The physics imposter
  32157. */
  32158. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  32159. /**
  32160. * A help function to create a joint
  32161. * @param otherImpostor A physics imposter used to create a joint
  32162. * @param jointType The type of joint
  32163. * @param jointData The data for the joint
  32164. * @returns The physics imposter
  32165. */
  32166. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  32167. /**
  32168. * Add a joint to this impostor with a different impostor
  32169. * @param otherImpostor A physics imposter used to add a joint
  32170. * @param joint The joint to add
  32171. * @returns The physics imposter
  32172. */
  32173. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  32174. /**
  32175. * Add an anchor to a cloth impostor
  32176. * @param otherImpostor rigid impostor to anchor to
  32177. * @param width ratio across width from 0 to 1
  32178. * @param height ratio up height from 0 to 1
  32179. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  32180. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  32181. * @returns impostor the soft imposter
  32182. */
  32183. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  32184. /**
  32185. * Add a hook to a rope impostor
  32186. * @param otherImpostor rigid impostor to anchor to
  32187. * @param length ratio across rope from 0 to 1
  32188. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  32189. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  32190. * @returns impostor the rope imposter
  32191. */
  32192. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  32193. /**
  32194. * Will keep this body still, in a sleep mode.
  32195. * @returns the physics imposter
  32196. */
  32197. sleep(): PhysicsImpostor;
  32198. /**
  32199. * Wake the body up.
  32200. * @returns The physics imposter
  32201. */
  32202. wakeUp(): PhysicsImpostor;
  32203. /**
  32204. * Clones the physics imposter
  32205. * @param newObject The physics imposter clones to this physics-enabled object
  32206. * @returns A nullable physics imposter
  32207. */
  32208. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  32209. /**
  32210. * Disposes the physics imposter
  32211. */
  32212. dispose(): void;
  32213. /**
  32214. * Sets the delta position
  32215. * @param position The delta position amount
  32216. */
  32217. setDeltaPosition(position: Vector3): void;
  32218. /**
  32219. * Sets the delta rotation
  32220. * @param rotation The delta rotation amount
  32221. */
  32222. setDeltaRotation(rotation: Quaternion): void;
  32223. /**
  32224. * Gets the box size of the physics imposter and stores the result in the input parameter
  32225. * @param result Stores the box size
  32226. * @returns The physics imposter
  32227. */
  32228. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  32229. /**
  32230. * Gets the radius of the physics imposter
  32231. * @returns Radius of the physics imposter
  32232. */
  32233. getRadius(): number;
  32234. /**
  32235. * Sync a bone with this impostor
  32236. * @param bone The bone to sync to the impostor.
  32237. * @param boneMesh The mesh that the bone is influencing.
  32238. * @param jointPivot The pivot of the joint / bone in local space.
  32239. * @param distToJoint Optional distance from the impostor to the joint.
  32240. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  32241. */
  32242. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  32243. /**
  32244. * Sync impostor to a bone
  32245. * @param bone The bone that the impostor will be synced to.
  32246. * @param boneMesh The mesh that the bone is influencing.
  32247. * @param jointPivot The pivot of the joint / bone in local space.
  32248. * @param distToJoint Optional distance from the impostor to the joint.
  32249. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  32250. * @param boneAxis Optional vector3 axis the bone is aligned with
  32251. */
  32252. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  32253. /**
  32254. * No-Imposter type
  32255. */
  32256. static NoImpostor: number;
  32257. /**
  32258. * Sphere-Imposter type
  32259. */
  32260. static SphereImpostor: number;
  32261. /**
  32262. * Box-Imposter type
  32263. */
  32264. static BoxImpostor: number;
  32265. /**
  32266. * Plane-Imposter type
  32267. */
  32268. static PlaneImpostor: number;
  32269. /**
  32270. * Mesh-imposter type
  32271. */
  32272. static MeshImpostor: number;
  32273. /**
  32274. * Capsule-Impostor type (Ammo.js plugin only)
  32275. */
  32276. static CapsuleImpostor: number;
  32277. /**
  32278. * Cylinder-Imposter type
  32279. */
  32280. static CylinderImpostor: number;
  32281. /**
  32282. * Particle-Imposter type
  32283. */
  32284. static ParticleImpostor: number;
  32285. /**
  32286. * Heightmap-Imposter type
  32287. */
  32288. static HeightmapImpostor: number;
  32289. /**
  32290. * ConvexHull-Impostor type (Ammo.js plugin only)
  32291. */
  32292. static ConvexHullImpostor: number;
  32293. /**
  32294. * Custom-Imposter type (Ammo.js plugin only)
  32295. */
  32296. static CustomImpostor: number;
  32297. /**
  32298. * Rope-Imposter type
  32299. */
  32300. static RopeImpostor: number;
  32301. /**
  32302. * Cloth-Imposter type
  32303. */
  32304. static ClothImpostor: number;
  32305. /**
  32306. * Softbody-Imposter type
  32307. */
  32308. static SoftbodyImpostor: number;
  32309. }
  32310. }
  32311. declare module BABYLON {
  32312. /**
  32313. * @hidden
  32314. **/
  32315. export class _CreationDataStorage {
  32316. closePath?: boolean;
  32317. closeArray?: boolean;
  32318. idx: number[];
  32319. dashSize: number;
  32320. gapSize: number;
  32321. path3D: Path3D;
  32322. pathArray: Vector3[][];
  32323. arc: number;
  32324. radius: number;
  32325. cap: number;
  32326. tessellation: number;
  32327. }
  32328. /**
  32329. * @hidden
  32330. **/
  32331. class _InstanceDataStorage {
  32332. visibleInstances: any;
  32333. batchCache: _InstancesBatch;
  32334. instancesBufferSize: number;
  32335. instancesBuffer: Nullable<Buffer>;
  32336. instancesData: Float32Array;
  32337. overridenInstanceCount: number;
  32338. isFrozen: boolean;
  32339. previousBatch: Nullable<_InstancesBatch>;
  32340. hardwareInstancedRendering: boolean;
  32341. sideOrientation: number;
  32342. manualUpdate: boolean;
  32343. previousRenderId: number;
  32344. }
  32345. /**
  32346. * @hidden
  32347. **/
  32348. export class _InstancesBatch {
  32349. mustReturn: boolean;
  32350. visibleInstances: Nullable<InstancedMesh[]>[];
  32351. renderSelf: boolean[];
  32352. hardwareInstancedRendering: boolean[];
  32353. }
  32354. /**
  32355. * @hidden
  32356. **/
  32357. class _ThinInstanceDataStorage {
  32358. instancesCount: number;
  32359. matrixBuffer: Nullable<Buffer>;
  32360. matrixBufferSize: number;
  32361. matrixData: Nullable<Float32Array>;
  32362. boundingVectors: Array<Vector3>;
  32363. worldMatrices: Nullable<Matrix[]>;
  32364. }
  32365. /**
  32366. * Class used to represent renderable models
  32367. */
  32368. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  32369. /**
  32370. * Mesh side orientation : usually the external or front surface
  32371. */
  32372. static readonly FRONTSIDE: number;
  32373. /**
  32374. * Mesh side orientation : usually the internal or back surface
  32375. */
  32376. static readonly BACKSIDE: number;
  32377. /**
  32378. * Mesh side orientation : both internal and external or front and back surfaces
  32379. */
  32380. static readonly DOUBLESIDE: number;
  32381. /**
  32382. * Mesh side orientation : by default, `FRONTSIDE`
  32383. */
  32384. static readonly DEFAULTSIDE: number;
  32385. /**
  32386. * Mesh cap setting : no cap
  32387. */
  32388. static readonly NO_CAP: number;
  32389. /**
  32390. * Mesh cap setting : one cap at the beginning of the mesh
  32391. */
  32392. static readonly CAP_START: number;
  32393. /**
  32394. * Mesh cap setting : one cap at the end of the mesh
  32395. */
  32396. static readonly CAP_END: number;
  32397. /**
  32398. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  32399. */
  32400. static readonly CAP_ALL: number;
  32401. /**
  32402. * Mesh pattern setting : no flip or rotate
  32403. */
  32404. static readonly NO_FLIP: number;
  32405. /**
  32406. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  32407. */
  32408. static readonly FLIP_TILE: number;
  32409. /**
  32410. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  32411. */
  32412. static readonly ROTATE_TILE: number;
  32413. /**
  32414. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  32415. */
  32416. static readonly FLIP_ROW: number;
  32417. /**
  32418. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  32419. */
  32420. static readonly ROTATE_ROW: number;
  32421. /**
  32422. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  32423. */
  32424. static readonly FLIP_N_ROTATE_TILE: number;
  32425. /**
  32426. * Mesh pattern setting : rotate pattern and rotate
  32427. */
  32428. static readonly FLIP_N_ROTATE_ROW: number;
  32429. /**
  32430. * Mesh tile positioning : part tiles same on left/right or top/bottom
  32431. */
  32432. static readonly CENTER: number;
  32433. /**
  32434. * Mesh tile positioning : part tiles on left
  32435. */
  32436. static readonly LEFT: number;
  32437. /**
  32438. * Mesh tile positioning : part tiles on right
  32439. */
  32440. static readonly RIGHT: number;
  32441. /**
  32442. * Mesh tile positioning : part tiles on top
  32443. */
  32444. static readonly TOP: number;
  32445. /**
  32446. * Mesh tile positioning : part tiles on bottom
  32447. */
  32448. static readonly BOTTOM: number;
  32449. /**
  32450. * Gets the default side orientation.
  32451. * @param orientation the orientation to value to attempt to get
  32452. * @returns the default orientation
  32453. * @hidden
  32454. */
  32455. static _GetDefaultSideOrientation(orientation?: number): number;
  32456. private _internalMeshDataInfo;
  32457. get computeBonesUsingShaders(): boolean;
  32458. set computeBonesUsingShaders(value: boolean);
  32459. /**
  32460. * An event triggered before rendering the mesh
  32461. */
  32462. get onBeforeRenderObservable(): Observable<Mesh>;
  32463. /**
  32464. * An event triggered before binding the mesh
  32465. */
  32466. get onBeforeBindObservable(): Observable<Mesh>;
  32467. /**
  32468. * An event triggered after rendering the mesh
  32469. */
  32470. get onAfterRenderObservable(): Observable<Mesh>;
  32471. /**
  32472. * An event triggered before drawing the mesh
  32473. */
  32474. get onBeforeDrawObservable(): Observable<Mesh>;
  32475. private _onBeforeDrawObserver;
  32476. /**
  32477. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  32478. */
  32479. set onBeforeDraw(callback: () => void);
  32480. get hasInstances(): boolean;
  32481. get hasThinInstances(): boolean;
  32482. /**
  32483. * Gets the delay loading state of the mesh (when delay loading is turned on)
  32484. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  32485. */
  32486. delayLoadState: number;
  32487. /**
  32488. * Gets the list of instances created from this mesh
  32489. * it is not supposed to be modified manually.
  32490. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  32491. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  32492. */
  32493. instances: InstancedMesh[];
  32494. /**
  32495. * Gets the file containing delay loading data for this mesh
  32496. */
  32497. delayLoadingFile: string;
  32498. /** @hidden */
  32499. _binaryInfo: any;
  32500. /**
  32501. * User defined function used to change how LOD level selection is done
  32502. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32503. */
  32504. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  32505. /**
  32506. * Gets or sets the morph target manager
  32507. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  32508. */
  32509. get morphTargetManager(): Nullable<MorphTargetManager>;
  32510. set morphTargetManager(value: Nullable<MorphTargetManager>);
  32511. /** @hidden */
  32512. _creationDataStorage: Nullable<_CreationDataStorage>;
  32513. /** @hidden */
  32514. _geometry: Nullable<Geometry>;
  32515. /** @hidden */
  32516. _delayInfo: Array<string>;
  32517. /** @hidden */
  32518. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  32519. /** @hidden */
  32520. _instanceDataStorage: _InstanceDataStorage;
  32521. /** @hidden */
  32522. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  32523. private _effectiveMaterial;
  32524. /** @hidden */
  32525. _shouldGenerateFlatShading: boolean;
  32526. /** @hidden */
  32527. _originalBuilderSideOrientation: number;
  32528. /**
  32529. * Use this property to change the original side orientation defined at construction time
  32530. */
  32531. overrideMaterialSideOrientation: Nullable<number>;
  32532. /**
  32533. * Gets the source mesh (the one used to clone this one from)
  32534. */
  32535. get source(): Nullable<Mesh>;
  32536. /**
  32537. * Gets the list of clones of this mesh
  32538. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  32539. * Note that useClonedMeshMap=true is the default setting
  32540. */
  32541. get cloneMeshMap(): Nullable<{
  32542. [id: string]: Mesh | undefined;
  32543. }>;
  32544. /**
  32545. * Gets or sets a boolean indicating that this mesh does not use index buffer
  32546. */
  32547. get isUnIndexed(): boolean;
  32548. set isUnIndexed(value: boolean);
  32549. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  32550. get worldMatrixInstancedBuffer(): Float32Array;
  32551. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  32552. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  32553. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  32554. /**
  32555. * @constructor
  32556. * @param name The value used by scene.getMeshByName() to do a lookup.
  32557. * @param scene The scene to add this mesh to.
  32558. * @param parent The parent of this mesh, if it has one
  32559. * @param source An optional Mesh from which geometry is shared, cloned.
  32560. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  32561. * When false, achieved by calling a clone(), also passing False.
  32562. * This will make creation of children, recursive.
  32563. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  32564. */
  32565. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  32566. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  32567. doNotInstantiate: boolean;
  32568. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  32569. /**
  32570. * Gets the class name
  32571. * @returns the string "Mesh".
  32572. */
  32573. getClassName(): string;
  32574. /** @hidden */
  32575. get _isMesh(): boolean;
  32576. /**
  32577. * Returns a description of this mesh
  32578. * @param fullDetails define if full details about this mesh must be used
  32579. * @returns a descriptive string representing this mesh
  32580. */
  32581. toString(fullDetails?: boolean): string;
  32582. /** @hidden */
  32583. _unBindEffect(): void;
  32584. /**
  32585. * Gets a boolean indicating if this mesh has LOD
  32586. */
  32587. get hasLODLevels(): boolean;
  32588. /**
  32589. * Gets the list of MeshLODLevel associated with the current mesh
  32590. * @returns an array of MeshLODLevel
  32591. */
  32592. getLODLevels(): MeshLODLevel[];
  32593. private _sortLODLevels;
  32594. /**
  32595. * Add a mesh as LOD level triggered at the given distance.
  32596. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32597. * @param distance The distance from the center of the object to show this level
  32598. * @param mesh The mesh to be added as LOD level (can be null)
  32599. * @return This mesh (for chaining)
  32600. */
  32601. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  32602. /**
  32603. * Returns the LOD level mesh at the passed distance or null if not found.
  32604. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32605. * @param distance The distance from the center of the object to show this level
  32606. * @returns a Mesh or `null`
  32607. */
  32608. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  32609. /**
  32610. * Remove a mesh from the LOD array
  32611. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32612. * @param mesh defines the mesh to be removed
  32613. * @return This mesh (for chaining)
  32614. */
  32615. removeLODLevel(mesh: Mesh): Mesh;
  32616. /**
  32617. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  32618. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  32619. * @param camera defines the camera to use to compute distance
  32620. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  32621. * @return This mesh (for chaining)
  32622. */
  32623. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  32624. /**
  32625. * Gets the mesh internal Geometry object
  32626. */
  32627. get geometry(): Nullable<Geometry>;
  32628. /**
  32629. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  32630. * @returns the total number of vertices
  32631. */
  32632. getTotalVertices(): number;
  32633. /**
  32634. * Returns the content of an associated vertex buffer
  32635. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  32636. * - VertexBuffer.PositionKind
  32637. * - VertexBuffer.UVKind
  32638. * - VertexBuffer.UV2Kind
  32639. * - VertexBuffer.UV3Kind
  32640. * - VertexBuffer.UV4Kind
  32641. * - VertexBuffer.UV5Kind
  32642. * - VertexBuffer.UV6Kind
  32643. * - VertexBuffer.ColorKind
  32644. * - VertexBuffer.MatricesIndicesKind
  32645. * - VertexBuffer.MatricesIndicesExtraKind
  32646. * - VertexBuffer.MatricesWeightsKind
  32647. * - VertexBuffer.MatricesWeightsExtraKind
  32648. * @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
  32649. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  32650. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  32651. */
  32652. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  32653. /**
  32654. * Returns the mesh VertexBuffer object from the requested `kind`
  32655. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  32656. * - VertexBuffer.PositionKind
  32657. * - VertexBuffer.NormalKind
  32658. * - VertexBuffer.UVKind
  32659. * - VertexBuffer.UV2Kind
  32660. * - VertexBuffer.UV3Kind
  32661. * - VertexBuffer.UV4Kind
  32662. * - VertexBuffer.UV5Kind
  32663. * - VertexBuffer.UV6Kind
  32664. * - VertexBuffer.ColorKind
  32665. * - VertexBuffer.MatricesIndicesKind
  32666. * - VertexBuffer.MatricesIndicesExtraKind
  32667. * - VertexBuffer.MatricesWeightsKind
  32668. * - VertexBuffer.MatricesWeightsExtraKind
  32669. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  32670. */
  32671. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  32672. /**
  32673. * Tests if a specific vertex buffer is associated with this mesh
  32674. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  32675. * - VertexBuffer.PositionKind
  32676. * - VertexBuffer.NormalKind
  32677. * - VertexBuffer.UVKind
  32678. * - VertexBuffer.UV2Kind
  32679. * - VertexBuffer.UV3Kind
  32680. * - VertexBuffer.UV4Kind
  32681. * - VertexBuffer.UV5Kind
  32682. * - VertexBuffer.UV6Kind
  32683. * - VertexBuffer.ColorKind
  32684. * - VertexBuffer.MatricesIndicesKind
  32685. * - VertexBuffer.MatricesIndicesExtraKind
  32686. * - VertexBuffer.MatricesWeightsKind
  32687. * - VertexBuffer.MatricesWeightsExtraKind
  32688. * @returns a boolean
  32689. */
  32690. isVerticesDataPresent(kind: string): boolean;
  32691. /**
  32692. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  32693. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  32694. * - VertexBuffer.PositionKind
  32695. * - VertexBuffer.UVKind
  32696. * - VertexBuffer.UV2Kind
  32697. * - VertexBuffer.UV3Kind
  32698. * - VertexBuffer.UV4Kind
  32699. * - VertexBuffer.UV5Kind
  32700. * - VertexBuffer.UV6Kind
  32701. * - VertexBuffer.ColorKind
  32702. * - VertexBuffer.MatricesIndicesKind
  32703. * - VertexBuffer.MatricesIndicesExtraKind
  32704. * - VertexBuffer.MatricesWeightsKind
  32705. * - VertexBuffer.MatricesWeightsExtraKind
  32706. * @returns a boolean
  32707. */
  32708. isVertexBufferUpdatable(kind: string): boolean;
  32709. /**
  32710. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  32711. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  32712. * - VertexBuffer.PositionKind
  32713. * - VertexBuffer.NormalKind
  32714. * - VertexBuffer.UVKind
  32715. * - VertexBuffer.UV2Kind
  32716. * - VertexBuffer.UV3Kind
  32717. * - VertexBuffer.UV4Kind
  32718. * - VertexBuffer.UV5Kind
  32719. * - VertexBuffer.UV6Kind
  32720. * - VertexBuffer.ColorKind
  32721. * - VertexBuffer.MatricesIndicesKind
  32722. * - VertexBuffer.MatricesIndicesExtraKind
  32723. * - VertexBuffer.MatricesWeightsKind
  32724. * - VertexBuffer.MatricesWeightsExtraKind
  32725. * @returns an array of strings
  32726. */
  32727. getVerticesDataKinds(): string[];
  32728. /**
  32729. * Returns a positive integer : the total number of indices in this mesh geometry.
  32730. * @returns the numner of indices or zero if the mesh has no geometry.
  32731. */
  32732. getTotalIndices(): number;
  32733. /**
  32734. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  32735. * @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.
  32736. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  32737. * @returns the indices array or an empty array if the mesh has no geometry
  32738. */
  32739. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  32740. get isBlocked(): boolean;
  32741. /**
  32742. * Determine if the current mesh is ready to be rendered
  32743. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  32744. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  32745. * @returns true if all associated assets are ready (material, textures, shaders)
  32746. */
  32747. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  32748. /**
  32749. * 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.
  32750. */
  32751. get areNormalsFrozen(): boolean;
  32752. /**
  32753. * 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.
  32754. * @returns the current mesh
  32755. */
  32756. freezeNormals(): Mesh;
  32757. /**
  32758. * 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
  32759. * @returns the current mesh
  32760. */
  32761. unfreezeNormals(): Mesh;
  32762. /**
  32763. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  32764. */
  32765. set overridenInstanceCount(count: number);
  32766. /** @hidden */
  32767. _preActivate(): Mesh;
  32768. /** @hidden */
  32769. _preActivateForIntermediateRendering(renderId: number): Mesh;
  32770. /** @hidden */
  32771. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  32772. protected _afterComputeWorldMatrix(): void;
  32773. /** @hidden */
  32774. _postActivate(): void;
  32775. /**
  32776. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  32777. * This means the mesh underlying bounding box and sphere are recomputed.
  32778. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  32779. * @returns the current mesh
  32780. */
  32781. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  32782. /** @hidden */
  32783. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  32784. /**
  32785. * This function will subdivide the mesh into multiple submeshes
  32786. * @param count defines the expected number of submeshes
  32787. */
  32788. subdivide(count: number): void;
  32789. /**
  32790. * Copy a FloatArray into a specific associated vertex buffer
  32791. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  32792. * - VertexBuffer.PositionKind
  32793. * - VertexBuffer.UVKind
  32794. * - VertexBuffer.UV2Kind
  32795. * - VertexBuffer.UV3Kind
  32796. * - VertexBuffer.UV4Kind
  32797. * - VertexBuffer.UV5Kind
  32798. * - VertexBuffer.UV6Kind
  32799. * - VertexBuffer.ColorKind
  32800. * - VertexBuffer.MatricesIndicesKind
  32801. * - VertexBuffer.MatricesIndicesExtraKind
  32802. * - VertexBuffer.MatricesWeightsKind
  32803. * - VertexBuffer.MatricesWeightsExtraKind
  32804. * @param data defines the data source
  32805. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  32806. * @param stride defines the data stride size (can be null)
  32807. * @returns the current mesh
  32808. */
  32809. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  32810. /**
  32811. * Delete a vertex buffer associated with this mesh
  32812. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  32813. * - VertexBuffer.PositionKind
  32814. * - VertexBuffer.UVKind
  32815. * - VertexBuffer.UV2Kind
  32816. * - VertexBuffer.UV3Kind
  32817. * - VertexBuffer.UV4Kind
  32818. * - VertexBuffer.UV5Kind
  32819. * - VertexBuffer.UV6Kind
  32820. * - VertexBuffer.ColorKind
  32821. * - VertexBuffer.MatricesIndicesKind
  32822. * - VertexBuffer.MatricesIndicesExtraKind
  32823. * - VertexBuffer.MatricesWeightsKind
  32824. * - VertexBuffer.MatricesWeightsExtraKind
  32825. */
  32826. removeVerticesData(kind: string): void;
  32827. /**
  32828. * Flags an associated vertex buffer as updatable
  32829. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  32830. * - VertexBuffer.PositionKind
  32831. * - VertexBuffer.UVKind
  32832. * - VertexBuffer.UV2Kind
  32833. * - VertexBuffer.UV3Kind
  32834. * - VertexBuffer.UV4Kind
  32835. * - VertexBuffer.UV5Kind
  32836. * - VertexBuffer.UV6Kind
  32837. * - VertexBuffer.ColorKind
  32838. * - VertexBuffer.MatricesIndicesKind
  32839. * - VertexBuffer.MatricesIndicesExtraKind
  32840. * - VertexBuffer.MatricesWeightsKind
  32841. * - VertexBuffer.MatricesWeightsExtraKind
  32842. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  32843. */
  32844. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  32845. /**
  32846. * Sets the mesh global Vertex Buffer
  32847. * @param buffer defines the buffer to use
  32848. * @returns the current mesh
  32849. */
  32850. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  32851. /**
  32852. * Update a specific associated vertex buffer
  32853. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  32854. * - VertexBuffer.PositionKind
  32855. * - VertexBuffer.UVKind
  32856. * - VertexBuffer.UV2Kind
  32857. * - VertexBuffer.UV3Kind
  32858. * - VertexBuffer.UV4Kind
  32859. * - VertexBuffer.UV5Kind
  32860. * - VertexBuffer.UV6Kind
  32861. * - VertexBuffer.ColorKind
  32862. * - VertexBuffer.MatricesIndicesKind
  32863. * - VertexBuffer.MatricesIndicesExtraKind
  32864. * - VertexBuffer.MatricesWeightsKind
  32865. * - VertexBuffer.MatricesWeightsExtraKind
  32866. * @param data defines the data source
  32867. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  32868. * @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)
  32869. * @returns the current mesh
  32870. */
  32871. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  32872. /**
  32873. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  32874. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  32875. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  32876. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  32877. * @returns the current mesh
  32878. */
  32879. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  32880. /**
  32881. * Creates a un-shared specific occurence of the geometry for the mesh.
  32882. * @returns the current mesh
  32883. */
  32884. makeGeometryUnique(): Mesh;
  32885. /**
  32886. * Set the index buffer of this mesh
  32887. * @param indices defines the source data
  32888. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  32889. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  32890. * @returns the current mesh
  32891. */
  32892. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  32893. /**
  32894. * Update the current index buffer
  32895. * @param indices defines the source data
  32896. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  32897. * @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)
  32898. * @returns the current mesh
  32899. */
  32900. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  32901. /**
  32902. * Invert the geometry to move from a right handed system to a left handed one.
  32903. * @returns the current mesh
  32904. */
  32905. toLeftHanded(): Mesh;
  32906. /** @hidden */
  32907. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  32908. /** @hidden */
  32909. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  32910. /**
  32911. * Registers for this mesh a javascript function called just before the rendering process
  32912. * @param func defines the function to call before rendering this mesh
  32913. * @returns the current mesh
  32914. */
  32915. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  32916. /**
  32917. * Disposes a previously registered javascript function called before the rendering
  32918. * @param func defines the function to remove
  32919. * @returns the current mesh
  32920. */
  32921. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  32922. /**
  32923. * Registers for this mesh a javascript function called just after the rendering is complete
  32924. * @param func defines the function to call after rendering this mesh
  32925. * @returns the current mesh
  32926. */
  32927. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  32928. /**
  32929. * Disposes a previously registered javascript function called after the rendering.
  32930. * @param func defines the function to remove
  32931. * @returns the current mesh
  32932. */
  32933. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  32934. /** @hidden */
  32935. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  32936. /** @hidden */
  32937. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  32938. /** @hidden */
  32939. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  32940. /** @hidden */
  32941. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  32942. /** @hidden */
  32943. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  32944. /** @hidden */
  32945. _rebuild(): void;
  32946. /** @hidden */
  32947. _freeze(): void;
  32948. /** @hidden */
  32949. _unFreeze(): void;
  32950. /**
  32951. * 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
  32952. * @param subMesh defines the subMesh to render
  32953. * @param enableAlphaMode defines if alpha mode can be changed
  32954. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  32955. * @returns the current mesh
  32956. */
  32957. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  32958. private _onBeforeDraw;
  32959. /**
  32960. * Renormalize the mesh and patch it up if there are no weights
  32961. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  32962. * However in the case of zero weights then we set just a single influence to 1.
  32963. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  32964. */
  32965. cleanMatrixWeights(): void;
  32966. private normalizeSkinFourWeights;
  32967. private normalizeSkinWeightsAndExtra;
  32968. /**
  32969. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  32970. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  32971. * the user know there was an issue with importing the mesh
  32972. * @returns a validation object with skinned, valid and report string
  32973. */
  32974. validateSkinning(): {
  32975. skinned: boolean;
  32976. valid: boolean;
  32977. report: string;
  32978. };
  32979. /** @hidden */
  32980. _checkDelayState(): Mesh;
  32981. private _queueLoad;
  32982. /**
  32983. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  32984. * A mesh is in the frustum if its bounding box intersects the frustum
  32985. * @param frustumPlanes defines the frustum to test
  32986. * @returns true if the mesh is in the frustum planes
  32987. */
  32988. isInFrustum(frustumPlanes: Plane[]): boolean;
  32989. /**
  32990. * Sets the mesh material by the material or multiMaterial `id` property
  32991. * @param id is a string identifying the material or the multiMaterial
  32992. * @returns the current mesh
  32993. */
  32994. setMaterialByID(id: string): Mesh;
  32995. /**
  32996. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  32997. * @returns an array of IAnimatable
  32998. */
  32999. getAnimatables(): IAnimatable[];
  33000. /**
  33001. * Modifies the mesh geometry according to the passed transformation matrix.
  33002. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  33003. * The mesh normals are modified using the same transformation.
  33004. * Note that, under the hood, this method sets a new VertexBuffer each call.
  33005. * @param transform defines the transform matrix to use
  33006. * @see https://doc.babylonjs.com/resources/baking_transformations
  33007. * @returns the current mesh
  33008. */
  33009. bakeTransformIntoVertices(transform: Matrix): Mesh;
  33010. /**
  33011. * Modifies the mesh geometry according to its own current World Matrix.
  33012. * The mesh World Matrix is then reset.
  33013. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  33014. * Note that, under the hood, this method sets a new VertexBuffer each call.
  33015. * @see https://doc.babylonjs.com/resources/baking_transformations
  33016. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  33017. * @returns the current mesh
  33018. */
  33019. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  33020. /** @hidden */
  33021. get _positions(): Nullable<Vector3[]>;
  33022. /** @hidden */
  33023. _resetPointsArrayCache(): Mesh;
  33024. /** @hidden */
  33025. _generatePointsArray(): boolean;
  33026. /**
  33027. * Returns a new Mesh object generated from the current mesh properties.
  33028. * This method must not get confused with createInstance()
  33029. * @param name is a string, the name given to the new mesh
  33030. * @param newParent can be any Node object (default `null`)
  33031. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  33032. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  33033. * @returns a new mesh
  33034. */
  33035. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  33036. /**
  33037. * Releases resources associated with this mesh.
  33038. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  33039. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  33040. */
  33041. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  33042. /** @hidden */
  33043. _disposeInstanceSpecificData(): void;
  33044. /** @hidden */
  33045. _disposeThinInstanceSpecificData(): void;
  33046. /**
  33047. * Modifies the mesh geometry according to a displacement map.
  33048. * 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.
  33049. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  33050. * @param url is a string, the URL from the image file is to be downloaded.
  33051. * @param minHeight is the lower limit of the displacement.
  33052. * @param maxHeight is the upper limit of the displacement.
  33053. * @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.
  33054. * @param uvOffset is an optional vector2 used to offset UV.
  33055. * @param uvScale is an optional vector2 used to scale UV.
  33056. * @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.
  33057. * @returns the Mesh.
  33058. */
  33059. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  33060. /**
  33061. * Modifies the mesh geometry according to a displacementMap buffer.
  33062. * 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.
  33063. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  33064. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  33065. * @param heightMapWidth is the width of the buffer image.
  33066. * @param heightMapHeight is the height of the buffer image.
  33067. * @param minHeight is the lower limit of the displacement.
  33068. * @param maxHeight is the upper limit of the displacement.
  33069. * @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.
  33070. * @param uvOffset is an optional vector2 used to offset UV.
  33071. * @param uvScale is an optional vector2 used to scale UV.
  33072. * @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.
  33073. * @returns the Mesh.
  33074. */
  33075. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  33076. /**
  33077. * Modify the mesh to get a flat shading rendering.
  33078. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  33079. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  33080. * @returns current mesh
  33081. */
  33082. convertToFlatShadedMesh(): Mesh;
  33083. /**
  33084. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  33085. * In other words, more vertices, no more indices and a single bigger VBO.
  33086. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  33087. * @returns current mesh
  33088. */
  33089. convertToUnIndexedMesh(): Mesh;
  33090. /**
  33091. * Inverses facet orientations.
  33092. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  33093. * @param flipNormals will also inverts the normals
  33094. * @returns current mesh
  33095. */
  33096. flipFaces(flipNormals?: boolean): Mesh;
  33097. /**
  33098. * Increase the number of facets and hence vertices in a mesh
  33099. * Vertex normals are interpolated from existing vertex normals
  33100. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  33101. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  33102. */
  33103. increaseVertices(numberPerEdge: number): void;
  33104. /**
  33105. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  33106. * This will undo any application of covertToFlatShadedMesh
  33107. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  33108. */
  33109. forceSharedVertices(): void;
  33110. /** @hidden */
  33111. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  33112. /** @hidden */
  33113. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  33114. /**
  33115. * Creates a new InstancedMesh object from the mesh model.
  33116. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  33117. * @param name defines the name of the new instance
  33118. * @returns a new InstancedMesh
  33119. */
  33120. createInstance(name: string): InstancedMesh;
  33121. /**
  33122. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  33123. * After this call, all the mesh instances have the same submeshes than the current mesh.
  33124. * @returns the current mesh
  33125. */
  33126. synchronizeInstances(): Mesh;
  33127. /**
  33128. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  33129. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  33130. * This should be used together with the simplification to avoid disappearing triangles.
  33131. * @param successCallback an optional success callback to be called after the optimization finished.
  33132. * @returns the current mesh
  33133. */
  33134. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  33135. /**
  33136. * Serialize current mesh
  33137. * @param serializationObject defines the object which will receive the serialization data
  33138. */
  33139. serialize(serializationObject: any): void;
  33140. /** @hidden */
  33141. _syncGeometryWithMorphTargetManager(): void;
  33142. /** @hidden */
  33143. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  33144. /**
  33145. * Returns a new Mesh object parsed from the source provided.
  33146. * @param parsedMesh is the source
  33147. * @param scene defines the hosting scene
  33148. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  33149. * @returns a new Mesh
  33150. */
  33151. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  33152. /**
  33153. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  33154. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  33155. * @param name defines the name of the mesh to create
  33156. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  33157. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  33158. * @param closePath creates a seam between the first and the last points of each path of the path array
  33159. * @param offset is taken in account only if the `pathArray` is containing a single path
  33160. * @param scene defines the hosting scene
  33161. * @param updatable defines if the mesh must be flagged as updatable
  33162. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33163. * @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)
  33164. * @returns a new Mesh
  33165. */
  33166. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  33167. /**
  33168. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  33169. * @param name defines the name of the mesh to create
  33170. * @param radius sets the radius size (float) of the polygon (default 0.5)
  33171. * @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
  33172. * @param scene defines the hosting scene
  33173. * @param updatable defines if the mesh must be flagged as updatable
  33174. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33175. * @returns a new Mesh
  33176. */
  33177. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  33178. /**
  33179. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  33180. * @param name defines the name of the mesh to create
  33181. * @param size sets the size (float) of each box side (default 1)
  33182. * @param scene defines the hosting scene
  33183. * @param updatable defines if the mesh must be flagged as updatable
  33184. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33185. * @returns a new Mesh
  33186. */
  33187. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  33188. /**
  33189. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  33190. * @param name defines the name of the mesh to create
  33191. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  33192. * @param diameter sets the diameter size (float) of the sphere (default 1)
  33193. * @param scene defines the hosting scene
  33194. * @param updatable defines if the mesh must be flagged as updatable
  33195. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33196. * @returns a new Mesh
  33197. */
  33198. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33199. /**
  33200. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  33201. * @param name defines the name of the mesh to create
  33202. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  33203. * @param diameter sets the diameter size (float) of the sphere (default 1)
  33204. * @param scene defines the hosting scene
  33205. * @returns a new Mesh
  33206. */
  33207. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  33208. /**
  33209. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  33210. * @param name defines the name of the mesh to create
  33211. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  33212. * @param diameterTop set the top cap diameter (floats, default 1)
  33213. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  33214. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  33215. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  33216. * @param scene defines the hosting scene
  33217. * @param updatable defines if the mesh must be flagged as updatable
  33218. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33219. * @returns a new Mesh
  33220. */
  33221. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  33222. /**
  33223. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  33224. * @param name defines the name of the mesh to create
  33225. * @param diameter sets the diameter size (float) of the torus (default 1)
  33226. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  33227. * @param tessellation sets the number of torus sides (postive integer, default 16)
  33228. * @param scene defines the hosting scene
  33229. * @param updatable defines if the mesh must be flagged as updatable
  33230. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33231. * @returns a new Mesh
  33232. */
  33233. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33234. /**
  33235. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  33236. * @param name defines the name of the mesh to create
  33237. * @param radius sets the global radius size (float) of the torus knot (default 2)
  33238. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  33239. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  33240. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  33241. * @param p the number of windings on X axis (positive integers, default 2)
  33242. * @param q the number of windings on Y axis (positive integers, default 3)
  33243. * @param scene defines the hosting scene
  33244. * @param updatable defines if the mesh must be flagged as updatable
  33245. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33246. * @returns a new Mesh
  33247. */
  33248. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33249. /**
  33250. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  33251. * @param name defines the name of the mesh to create
  33252. * @param points is an array successive Vector3
  33253. * @param scene defines the hosting scene
  33254. * @param updatable defines if the mesh must be flagged as updatable
  33255. * @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).
  33256. * @returns a new Mesh
  33257. */
  33258. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  33259. /**
  33260. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  33261. * @param name defines the name of the mesh to create
  33262. * @param points is an array successive Vector3
  33263. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  33264. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  33265. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  33266. * @param scene defines the hosting scene
  33267. * @param updatable defines if the mesh must be flagged as updatable
  33268. * @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)
  33269. * @returns a new Mesh
  33270. */
  33271. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  33272. /**
  33273. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  33274. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  33275. * 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.
  33276. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33277. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  33278. * Remember you can only change the shape positions, not their number when updating a polygon.
  33279. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  33280. * @param name defines the name of the mesh to create
  33281. * @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
  33282. * @param scene defines the hosting scene
  33283. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  33284. * @param updatable defines if the mesh must be flagged as updatable
  33285. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33286. * @param earcutInjection can be used to inject your own earcut reference
  33287. * @returns a new Mesh
  33288. */
  33289. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  33290. /**
  33291. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  33292. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  33293. * @param name defines the name of the mesh to create
  33294. * @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
  33295. * @param depth defines the height of extrusion
  33296. * @param scene defines the hosting scene
  33297. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  33298. * @param updatable defines if the mesh must be flagged as updatable
  33299. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33300. * @param earcutInjection can be used to inject your own earcut reference
  33301. * @returns a new Mesh
  33302. */
  33303. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  33304. /**
  33305. * Creates an extruded shape mesh.
  33306. * 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
  33307. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  33308. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  33309. * @param name defines the name of the mesh to create
  33310. * @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
  33311. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  33312. * @param scale is the value to scale the shape
  33313. * @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
  33314. * @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
  33315. * @param scene defines the hosting scene
  33316. * @param updatable defines if the mesh must be flagged as updatable
  33317. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33318. * @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)
  33319. * @returns a new Mesh
  33320. */
  33321. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  33322. /**
  33323. * Creates an custom extruded shape mesh.
  33324. * The custom extrusion is a parametric shape.
  33325. * It has no predefined shape. Its final shape will depend on the input parameters.
  33326. * Please consider using the same method from the MeshBuilder class instead
  33327. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  33328. * @param name defines the name of the mesh to create
  33329. * @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
  33330. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  33331. * @param scaleFunction is a custom Javascript function called on each path point
  33332. * @param rotationFunction is a custom Javascript function called on each path point
  33333. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  33334. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  33335. * @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
  33336. * @param scene defines the hosting scene
  33337. * @param updatable defines if the mesh must be flagged as updatable
  33338. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33339. * @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)
  33340. * @returns a new Mesh
  33341. */
  33342. 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;
  33343. /**
  33344. * Creates lathe mesh.
  33345. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  33346. * Please consider using the same method from the MeshBuilder class instead
  33347. * @param name defines the name of the mesh to create
  33348. * @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
  33349. * @param radius is the radius value of the lathe
  33350. * @param tessellation is the side number of the lathe.
  33351. * @param scene defines the hosting scene
  33352. * @param updatable defines if the mesh must be flagged as updatable
  33353. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33354. * @returns a new Mesh
  33355. */
  33356. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33357. /**
  33358. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  33359. * @param name defines the name of the mesh to create
  33360. * @param size sets the size (float) of both sides of the plane at once (default 1)
  33361. * @param scene defines the hosting scene
  33362. * @param updatable defines if the mesh must be flagged as updatable
  33363. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33364. * @returns a new Mesh
  33365. */
  33366. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  33367. /**
  33368. * Creates a ground mesh.
  33369. * Please consider using the same method from the MeshBuilder class instead
  33370. * @param name defines the name of the mesh to create
  33371. * @param width set the width of the ground
  33372. * @param height set the height of the ground
  33373. * @param subdivisions sets the number of subdivisions per side
  33374. * @param scene defines the hosting scene
  33375. * @param updatable defines if the mesh must be flagged as updatable
  33376. * @returns a new Mesh
  33377. */
  33378. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  33379. /**
  33380. * Creates a tiled ground mesh.
  33381. * Please consider using the same method from the MeshBuilder class instead
  33382. * @param name defines the name of the mesh to create
  33383. * @param xmin set the ground minimum X coordinate
  33384. * @param zmin set the ground minimum Y coordinate
  33385. * @param xmax set the ground maximum X coordinate
  33386. * @param zmax set the ground maximum Z coordinate
  33387. * @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
  33388. * @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
  33389. * @param scene defines the hosting scene
  33390. * @param updatable defines if the mesh must be flagged as updatable
  33391. * @returns a new Mesh
  33392. */
  33393. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  33394. w: number;
  33395. h: number;
  33396. }, precision: {
  33397. w: number;
  33398. h: number;
  33399. }, scene: Scene, updatable?: boolean): Mesh;
  33400. /**
  33401. * Creates a ground mesh from a height map.
  33402. * Please consider using the same method from the MeshBuilder class instead
  33403. * @see https://doc.babylonjs.com/babylon101/height_map
  33404. * @param name defines the name of the mesh to create
  33405. * @param url sets the URL of the height map image resource
  33406. * @param width set the ground width size
  33407. * @param height set the ground height size
  33408. * @param subdivisions sets the number of subdivision per side
  33409. * @param minHeight is the minimum altitude on the ground
  33410. * @param maxHeight is the maximum altitude on the ground
  33411. * @param scene defines the hosting scene
  33412. * @param updatable defines if the mesh must be flagged as updatable
  33413. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  33414. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  33415. * @returns a new Mesh
  33416. */
  33417. 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;
  33418. /**
  33419. * Creates a tube mesh.
  33420. * The tube is a parametric shape.
  33421. * It has no predefined shape. Its final shape will depend on the input parameters.
  33422. * Please consider using the same method from the MeshBuilder class instead
  33423. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  33424. * @param name defines the name of the mesh to create
  33425. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  33426. * @param radius sets the tube radius size
  33427. * @param tessellation is the number of sides on the tubular surface
  33428. * @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
  33429. * @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
  33430. * @param scene defines the hosting scene
  33431. * @param updatable defines if the mesh must be flagged as updatable
  33432. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  33433. * @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)
  33434. * @returns a new Mesh
  33435. */
  33436. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  33437. (i: number, distance: number): number;
  33438. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  33439. /**
  33440. * Creates a polyhedron mesh.
  33441. * Please consider using the same method from the MeshBuilder class instead.
  33442. * * 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
  33443. * * The parameter `size` (positive float, default 1) sets the polygon size
  33444. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  33445. * * 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`
  33446. * * 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
  33447. * * 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)`)
  33448. * * 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
  33449. * * 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
  33450. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33451. * * 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
  33452. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  33453. * @param name defines the name of the mesh to create
  33454. * @param options defines the options used to create the mesh
  33455. * @param scene defines the hosting scene
  33456. * @returns a new Mesh
  33457. */
  33458. static CreatePolyhedron(name: string, options: {
  33459. type?: number;
  33460. size?: number;
  33461. sizeX?: number;
  33462. sizeY?: number;
  33463. sizeZ?: number;
  33464. custom?: any;
  33465. faceUV?: Vector4[];
  33466. faceColors?: Color4[];
  33467. updatable?: boolean;
  33468. sideOrientation?: number;
  33469. }, scene: Scene): Mesh;
  33470. /**
  33471. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  33472. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  33473. * * 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`)
  33474. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  33475. * * 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
  33476. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  33477. * * 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
  33478. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  33479. * @param name defines the name of the mesh
  33480. * @param options defines the options used to create the mesh
  33481. * @param scene defines the hosting scene
  33482. * @returns a new Mesh
  33483. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  33484. */
  33485. static CreateIcoSphere(name: string, options: {
  33486. radius?: number;
  33487. flat?: boolean;
  33488. subdivisions?: number;
  33489. sideOrientation?: number;
  33490. updatable?: boolean;
  33491. }, scene: Scene): Mesh;
  33492. /**
  33493. * Creates a decal mesh.
  33494. * Please consider using the same method from the MeshBuilder class instead.
  33495. * A decal is a mesh usually applied as a model onto the surface of another mesh
  33496. * @param name defines the name of the mesh
  33497. * @param sourceMesh defines the mesh receiving the decal
  33498. * @param position sets the position of the decal in world coordinates
  33499. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  33500. * @param size sets the decal scaling
  33501. * @param angle sets the angle to rotate the decal
  33502. * @returns a new Mesh
  33503. */
  33504. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  33505. /** Creates a Capsule Mesh
  33506. * @param name defines the name of the mesh.
  33507. * @param options the constructors options used to shape the mesh.
  33508. * @param scene defines the scene the mesh is scoped to.
  33509. * @returns the capsule mesh
  33510. * @see https://doc.babylonjs.com/how_to/capsule_shape
  33511. */
  33512. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  33513. /**
  33514. * Prepare internal position array for software CPU skinning
  33515. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  33516. */
  33517. setPositionsForCPUSkinning(): Float32Array;
  33518. /**
  33519. * Prepare internal normal array for software CPU skinning
  33520. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  33521. */
  33522. setNormalsForCPUSkinning(): Float32Array;
  33523. /**
  33524. * Updates the vertex buffer by applying transformation from the bones
  33525. * @param skeleton defines the skeleton to apply to current mesh
  33526. * @returns the current mesh
  33527. */
  33528. applySkeleton(skeleton: Skeleton): Mesh;
  33529. /**
  33530. * 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
  33531. * @param meshes defines the list of meshes to scan
  33532. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  33533. */
  33534. static MinMax(meshes: AbstractMesh[]): {
  33535. min: Vector3;
  33536. max: Vector3;
  33537. };
  33538. /**
  33539. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  33540. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  33541. * @returns a vector3
  33542. */
  33543. static Center(meshesOrMinMaxVector: {
  33544. min: Vector3;
  33545. max: Vector3;
  33546. } | AbstractMesh[]): Vector3;
  33547. /**
  33548. * Merge the array of meshes into a single mesh for performance reasons.
  33549. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  33550. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  33551. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  33552. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  33553. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  33554. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  33555. * @returns a new mesh
  33556. */
  33557. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  33558. /** @hidden */
  33559. addInstance(instance: InstancedMesh): void;
  33560. /** @hidden */
  33561. removeInstance(instance: InstancedMesh): void;
  33562. }
  33563. }
  33564. declare module BABYLON {
  33565. /**
  33566. * This is the base class of all the camera used in the application.
  33567. * @see https://doc.babylonjs.com/features/cameras
  33568. */
  33569. export class Camera extends Node {
  33570. /** @hidden */
  33571. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  33572. /**
  33573. * This is the default projection mode used by the cameras.
  33574. * It helps recreating a feeling of perspective and better appreciate depth.
  33575. * This is the best way to simulate real life cameras.
  33576. */
  33577. static readonly PERSPECTIVE_CAMERA: number;
  33578. /**
  33579. * This helps creating camera with an orthographic mode.
  33580. * 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.
  33581. */
  33582. static readonly ORTHOGRAPHIC_CAMERA: number;
  33583. /**
  33584. * This is the default FOV mode for perspective cameras.
  33585. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  33586. */
  33587. static readonly FOVMODE_VERTICAL_FIXED: number;
  33588. /**
  33589. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  33590. */
  33591. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  33592. /**
  33593. * This specifies ther is no need for a camera rig.
  33594. * Basically only one eye is rendered corresponding to the camera.
  33595. */
  33596. static readonly RIG_MODE_NONE: number;
  33597. /**
  33598. * Simulates a camera Rig with one blue eye and one red eye.
  33599. * This can be use with 3d blue and red glasses.
  33600. */
  33601. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  33602. /**
  33603. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  33604. */
  33605. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  33606. /**
  33607. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  33608. */
  33609. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  33610. /**
  33611. * Defines that both eyes of the camera will be rendered over under each other.
  33612. */
  33613. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  33614. /**
  33615. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  33616. */
  33617. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  33618. /**
  33619. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  33620. */
  33621. static readonly RIG_MODE_VR: number;
  33622. /**
  33623. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  33624. */
  33625. static readonly RIG_MODE_WEBVR: number;
  33626. /**
  33627. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  33628. */
  33629. static readonly RIG_MODE_CUSTOM: number;
  33630. /**
  33631. * Defines if by default attaching controls should prevent the default javascript event to continue.
  33632. */
  33633. static ForceAttachControlToAlwaysPreventDefault: boolean;
  33634. /**
  33635. * Define the input manager associated with the camera.
  33636. */
  33637. inputs: CameraInputsManager<Camera>;
  33638. /** @hidden */
  33639. _position: Vector3;
  33640. /**
  33641. * Define the current local position of the camera in the scene
  33642. */
  33643. get position(): Vector3;
  33644. set position(newPosition: Vector3);
  33645. protected _upVector: Vector3;
  33646. /**
  33647. * The vector the camera should consider as up.
  33648. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  33649. */
  33650. set upVector(vec: Vector3);
  33651. get upVector(): Vector3;
  33652. /**
  33653. * Define the current limit on the left side for an orthographic camera
  33654. * In scene unit
  33655. */
  33656. orthoLeft: Nullable<number>;
  33657. /**
  33658. * Define the current limit on the right side for an orthographic camera
  33659. * In scene unit
  33660. */
  33661. orthoRight: Nullable<number>;
  33662. /**
  33663. * Define the current limit on the bottom side for an orthographic camera
  33664. * In scene unit
  33665. */
  33666. orthoBottom: Nullable<number>;
  33667. /**
  33668. * Define the current limit on the top side for an orthographic camera
  33669. * In scene unit
  33670. */
  33671. orthoTop: Nullable<number>;
  33672. /**
  33673. * Field Of View is set in Radians. (default is 0.8)
  33674. */
  33675. fov: number;
  33676. /**
  33677. * Define the minimum distance the camera can see from.
  33678. * This is important to note that the depth buffer are not infinite and the closer it starts
  33679. * the more your scene might encounter depth fighting issue.
  33680. */
  33681. minZ: number;
  33682. /**
  33683. * Define the maximum distance the camera can see to.
  33684. * This is important to note that the depth buffer are not infinite and the further it end
  33685. * the more your scene might encounter depth fighting issue.
  33686. */
  33687. maxZ: number;
  33688. /**
  33689. * Define the default inertia of the camera.
  33690. * This helps giving a smooth feeling to the camera movement.
  33691. */
  33692. inertia: number;
  33693. /**
  33694. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  33695. */
  33696. mode: number;
  33697. /**
  33698. * Define whether the camera is intermediate.
  33699. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  33700. */
  33701. isIntermediate: boolean;
  33702. /**
  33703. * Define the viewport of the camera.
  33704. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  33705. */
  33706. viewport: Viewport;
  33707. /**
  33708. * Restricts the camera to viewing objects with the same layerMask.
  33709. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  33710. */
  33711. layerMask: number;
  33712. /**
  33713. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  33714. */
  33715. fovMode: number;
  33716. /**
  33717. * Rig mode of the camera.
  33718. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  33719. * This is normally controlled byt the camera themselves as internal use.
  33720. */
  33721. cameraRigMode: number;
  33722. /**
  33723. * Defines the distance between both "eyes" in case of a RIG
  33724. */
  33725. interaxialDistance: number;
  33726. /**
  33727. * Defines if stereoscopic rendering is done side by side or over under.
  33728. */
  33729. isStereoscopicSideBySide: boolean;
  33730. /**
  33731. * 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
  33732. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  33733. * else in the scene. (Eg. security camera)
  33734. *
  33735. * 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)
  33736. */
  33737. customRenderTargets: RenderTargetTexture[];
  33738. /**
  33739. * When set, the camera will render to this render target instead of the default canvas
  33740. *
  33741. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  33742. */
  33743. outputRenderTarget: Nullable<RenderTargetTexture>;
  33744. /**
  33745. * Observable triggered when the camera view matrix has changed.
  33746. */
  33747. onViewMatrixChangedObservable: Observable<Camera>;
  33748. /**
  33749. * Observable triggered when the camera Projection matrix has changed.
  33750. */
  33751. onProjectionMatrixChangedObservable: Observable<Camera>;
  33752. /**
  33753. * Observable triggered when the inputs have been processed.
  33754. */
  33755. onAfterCheckInputsObservable: Observable<Camera>;
  33756. /**
  33757. * Observable triggered when reset has been called and applied to the camera.
  33758. */
  33759. onRestoreStateObservable: Observable<Camera>;
  33760. /**
  33761. * Is this camera a part of a rig system?
  33762. */
  33763. isRigCamera: boolean;
  33764. /**
  33765. * If isRigCamera set to true this will be set with the parent camera.
  33766. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  33767. */
  33768. rigParent?: Camera;
  33769. /** @hidden */
  33770. _cameraRigParams: any;
  33771. /** @hidden */
  33772. _rigCameras: Camera[];
  33773. /** @hidden */
  33774. _rigPostProcess: Nullable<PostProcess>;
  33775. protected _webvrViewMatrix: Matrix;
  33776. /** @hidden */
  33777. _skipRendering: boolean;
  33778. /** @hidden */
  33779. _projectionMatrix: Matrix;
  33780. /** @hidden */
  33781. _postProcesses: Nullable<PostProcess>[];
  33782. /** @hidden */
  33783. _activeMeshes: SmartArray<AbstractMesh>;
  33784. protected _globalPosition: Vector3;
  33785. /** @hidden */
  33786. _computedViewMatrix: Matrix;
  33787. private _doNotComputeProjectionMatrix;
  33788. private _transformMatrix;
  33789. private _frustumPlanes;
  33790. private _refreshFrustumPlanes;
  33791. private _storedFov;
  33792. private _stateStored;
  33793. /**
  33794. * Instantiates a new camera object.
  33795. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  33796. * @see https://doc.babylonjs.com/features/cameras
  33797. * @param name Defines the name of the camera in the scene
  33798. * @param position Defines the position of the camera
  33799. * @param scene Defines the scene the camera belongs too
  33800. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  33801. */
  33802. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  33803. /**
  33804. * Store current camera state (fov, position, etc..)
  33805. * @returns the camera
  33806. */
  33807. storeState(): Camera;
  33808. /**
  33809. * Restores the camera state values if it has been stored. You must call storeState() first
  33810. */
  33811. protected _restoreStateValues(): boolean;
  33812. /**
  33813. * Restored camera state. You must call storeState() first.
  33814. * @returns true if restored and false otherwise
  33815. */
  33816. restoreState(): boolean;
  33817. /**
  33818. * Gets the class name of the camera.
  33819. * @returns the class name
  33820. */
  33821. getClassName(): string;
  33822. /** @hidden */
  33823. readonly _isCamera: boolean;
  33824. /**
  33825. * Gets a string representation of the camera useful for debug purpose.
  33826. * @param fullDetails Defines that a more verboe level of logging is required
  33827. * @returns the string representation
  33828. */
  33829. toString(fullDetails?: boolean): string;
  33830. /**
  33831. * Gets the current world space position of the camera.
  33832. */
  33833. get globalPosition(): Vector3;
  33834. /**
  33835. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  33836. * @returns the active meshe list
  33837. */
  33838. getActiveMeshes(): SmartArray<AbstractMesh>;
  33839. /**
  33840. * Check whether a mesh is part of the current active mesh list of the camera
  33841. * @param mesh Defines the mesh to check
  33842. * @returns true if active, false otherwise
  33843. */
  33844. isActiveMesh(mesh: Mesh): boolean;
  33845. /**
  33846. * Is this camera ready to be used/rendered
  33847. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  33848. * @return true if the camera is ready
  33849. */
  33850. isReady(completeCheck?: boolean): boolean;
  33851. /** @hidden */
  33852. _initCache(): void;
  33853. /** @hidden */
  33854. _updateCache(ignoreParentClass?: boolean): void;
  33855. /** @hidden */
  33856. _isSynchronized(): boolean;
  33857. /** @hidden */
  33858. _isSynchronizedViewMatrix(): boolean;
  33859. /** @hidden */
  33860. _isSynchronizedProjectionMatrix(): boolean;
  33861. /**
  33862. * Attach the input controls to a specific dom element to get the input from.
  33863. * @param element Defines the element the controls should be listened from
  33864. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  33865. */
  33866. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  33867. /**
  33868. * Detach the current controls from the specified dom element.
  33869. * @param element Defines the element to stop listening the inputs from
  33870. */
  33871. detachControl(element: HTMLElement): void;
  33872. /**
  33873. * Update the camera state according to the different inputs gathered during the frame.
  33874. */
  33875. update(): void;
  33876. /** @hidden */
  33877. _checkInputs(): void;
  33878. /** @hidden */
  33879. get rigCameras(): Camera[];
  33880. /**
  33881. * Gets the post process used by the rig cameras
  33882. */
  33883. get rigPostProcess(): Nullable<PostProcess>;
  33884. /**
  33885. * Internal, gets the first post proces.
  33886. * @returns the first post process to be run on this camera.
  33887. */
  33888. _getFirstPostProcess(): Nullable<PostProcess>;
  33889. private _cascadePostProcessesToRigCams;
  33890. /**
  33891. * Attach a post process to the camera.
  33892. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  33893. * @param postProcess The post process to attach to the camera
  33894. * @param insertAt The position of the post process in case several of them are in use in the scene
  33895. * @returns the position the post process has been inserted at
  33896. */
  33897. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  33898. /**
  33899. * Detach a post process to the camera.
  33900. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  33901. * @param postProcess The post process to detach from the camera
  33902. */
  33903. detachPostProcess(postProcess: PostProcess): void;
  33904. /**
  33905. * Gets the current world matrix of the camera
  33906. */
  33907. getWorldMatrix(): Matrix;
  33908. /** @hidden */
  33909. _getViewMatrix(): Matrix;
  33910. /**
  33911. * Gets the current view matrix of the camera.
  33912. * @param force forces the camera to recompute the matrix without looking at the cached state
  33913. * @returns the view matrix
  33914. */
  33915. getViewMatrix(force?: boolean): Matrix;
  33916. /**
  33917. * Freeze the projection matrix.
  33918. * It will prevent the cache check of the camera projection compute and can speed up perf
  33919. * if no parameter of the camera are meant to change
  33920. * @param projection Defines manually a projection if necessary
  33921. */
  33922. freezeProjectionMatrix(projection?: Matrix): void;
  33923. /**
  33924. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  33925. */
  33926. unfreezeProjectionMatrix(): void;
  33927. /**
  33928. * Gets the current projection matrix of the camera.
  33929. * @param force forces the camera to recompute the matrix without looking at the cached state
  33930. * @returns the projection matrix
  33931. */
  33932. getProjectionMatrix(force?: boolean): Matrix;
  33933. /**
  33934. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  33935. * @returns a Matrix
  33936. */
  33937. getTransformationMatrix(): Matrix;
  33938. private _updateFrustumPlanes;
  33939. /**
  33940. * Checks if a cullable object (mesh...) is in the camera frustum
  33941. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  33942. * @param target The object to check
  33943. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  33944. * @returns true if the object is in frustum otherwise false
  33945. */
  33946. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  33947. /**
  33948. * Checks if a cullable object (mesh...) is in the camera frustum
  33949. * Unlike isInFrustum this cheks the full bounding box
  33950. * @param target The object to check
  33951. * @returns true if the object is in frustum otherwise false
  33952. */
  33953. isCompletelyInFrustum(target: ICullable): boolean;
  33954. /**
  33955. * Gets a ray in the forward direction from the camera.
  33956. * @param length Defines the length of the ray to create
  33957. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  33958. * @param origin Defines the start point of the ray which defaults to the camera position
  33959. * @returns the forward ray
  33960. */
  33961. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  33962. /**
  33963. * Gets a ray in the forward direction from the camera.
  33964. * @param refRay the ray to (re)use when setting the values
  33965. * @param length Defines the length of the ray to create
  33966. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  33967. * @param origin Defines the start point of the ray which defaults to the camera position
  33968. * @returns the forward ray
  33969. */
  33970. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  33971. /**
  33972. * Releases resources associated with this node.
  33973. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  33974. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  33975. */
  33976. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  33977. /** @hidden */
  33978. _isLeftCamera: boolean;
  33979. /**
  33980. * Gets the left camera of a rig setup in case of Rigged Camera
  33981. */
  33982. get isLeftCamera(): boolean;
  33983. /** @hidden */
  33984. _isRightCamera: boolean;
  33985. /**
  33986. * Gets the right camera of a rig setup in case of Rigged Camera
  33987. */
  33988. get isRightCamera(): boolean;
  33989. /**
  33990. * Gets the left camera of a rig setup in case of Rigged Camera
  33991. */
  33992. get leftCamera(): Nullable<FreeCamera>;
  33993. /**
  33994. * Gets the right camera of a rig setup in case of Rigged Camera
  33995. */
  33996. get rightCamera(): Nullable<FreeCamera>;
  33997. /**
  33998. * Gets the left camera target of a rig setup in case of Rigged Camera
  33999. * @returns the target position
  34000. */
  34001. getLeftTarget(): Nullable<Vector3>;
  34002. /**
  34003. * Gets the right camera target of a rig setup in case of Rigged Camera
  34004. * @returns the target position
  34005. */
  34006. getRightTarget(): Nullable<Vector3>;
  34007. /**
  34008. * @hidden
  34009. */
  34010. setCameraRigMode(mode: number, rigParams: any): void;
  34011. /** @hidden */
  34012. static _setStereoscopicRigMode(camera: Camera): void;
  34013. /** @hidden */
  34014. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  34015. /** @hidden */
  34016. static _setVRRigMode(camera: Camera, rigParams: any): void;
  34017. /** @hidden */
  34018. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  34019. /** @hidden */
  34020. _getVRProjectionMatrix(): Matrix;
  34021. protected _updateCameraRotationMatrix(): void;
  34022. protected _updateWebVRCameraRotationMatrix(): void;
  34023. /**
  34024. * This function MUST be overwritten by the different WebVR cameras available.
  34025. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  34026. * @hidden
  34027. */
  34028. _getWebVRProjectionMatrix(): Matrix;
  34029. /**
  34030. * This function MUST be overwritten by the different WebVR cameras available.
  34031. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  34032. * @hidden
  34033. */
  34034. _getWebVRViewMatrix(): Matrix;
  34035. /** @hidden */
  34036. setCameraRigParameter(name: string, value: any): void;
  34037. /**
  34038. * needs to be overridden by children so sub has required properties to be copied
  34039. * @hidden
  34040. */
  34041. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  34042. /**
  34043. * May need to be overridden by children
  34044. * @hidden
  34045. */
  34046. _updateRigCameras(): void;
  34047. /** @hidden */
  34048. _setupInputs(): void;
  34049. /**
  34050. * Serialiaze the camera setup to a json represention
  34051. * @returns the JSON representation
  34052. */
  34053. serialize(): any;
  34054. /**
  34055. * Clones the current camera.
  34056. * @param name The cloned camera name
  34057. * @returns the cloned camera
  34058. */
  34059. clone(name: string): Camera;
  34060. /**
  34061. * Gets the direction of the camera relative to a given local axis.
  34062. * @param localAxis Defines the reference axis to provide a relative direction.
  34063. * @return the direction
  34064. */
  34065. getDirection(localAxis: Vector3): Vector3;
  34066. /**
  34067. * Returns the current camera absolute rotation
  34068. */
  34069. get absoluteRotation(): Quaternion;
  34070. /**
  34071. * Gets the direction of the camera relative to a given local axis into a passed vector.
  34072. * @param localAxis Defines the reference axis to provide a relative direction.
  34073. * @param result Defines the vector to store the result in
  34074. */
  34075. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  34076. /**
  34077. * Gets a camera constructor for a given camera type
  34078. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  34079. * @param name The name of the camera the result will be able to instantiate
  34080. * @param scene The scene the result will construct the camera in
  34081. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  34082. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  34083. * @returns a factory method to construc the camera
  34084. */
  34085. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  34086. /**
  34087. * Compute the world matrix of the camera.
  34088. * @returns the camera world matrix
  34089. */
  34090. computeWorldMatrix(): Matrix;
  34091. /**
  34092. * Parse a JSON and creates the camera from the parsed information
  34093. * @param parsedCamera The JSON to parse
  34094. * @param scene The scene to instantiate the camera in
  34095. * @returns the newly constructed camera
  34096. */
  34097. static Parse(parsedCamera: any, scene: Scene): Camera;
  34098. }
  34099. }
  34100. declare module BABYLON {
  34101. /**
  34102. * Class containing static functions to help procedurally build meshes
  34103. */
  34104. export class DiscBuilder {
  34105. /**
  34106. * Creates a plane polygonal mesh. By default, this is a disc
  34107. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  34108. * * 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
  34109. * * 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
  34110. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  34111. * * 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
  34112. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  34113. * @param name defines the name of the mesh
  34114. * @param options defines the options used to create the mesh
  34115. * @param scene defines the hosting scene
  34116. * @returns the plane polygonal mesh
  34117. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  34118. */
  34119. static CreateDisc(name: string, options: {
  34120. radius?: number;
  34121. tessellation?: number;
  34122. arc?: number;
  34123. updatable?: boolean;
  34124. sideOrientation?: number;
  34125. frontUVs?: Vector4;
  34126. backUVs?: Vector4;
  34127. }, scene?: Nullable<Scene>): Mesh;
  34128. }
  34129. }
  34130. declare module BABYLON {
  34131. /**
  34132. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  34133. *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.
  34134. * The SPS is also a particle system. It provides some methods to manage the particles.
  34135. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  34136. *
  34137. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  34138. */
  34139. export class SolidParticleSystem implements IDisposable {
  34140. /**
  34141. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  34142. * Example : var p = SPS.particles[i];
  34143. */
  34144. particles: SolidParticle[];
  34145. /**
  34146. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  34147. */
  34148. nbParticles: number;
  34149. /**
  34150. * If the particles must ever face the camera (default false). Useful for planar particles.
  34151. */
  34152. billboard: boolean;
  34153. /**
  34154. * Recompute normals when adding a shape
  34155. */
  34156. recomputeNormals: boolean;
  34157. /**
  34158. * This a counter ofr your own usage. It's not set by any SPS functions.
  34159. */
  34160. counter: number;
  34161. /**
  34162. * The SPS name. This name is also given to the underlying mesh.
  34163. */
  34164. name: string;
  34165. /**
  34166. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  34167. */
  34168. mesh: Mesh;
  34169. /**
  34170. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  34171. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  34172. */
  34173. vars: any;
  34174. /**
  34175. * This array is populated when the SPS is set as 'pickable'.
  34176. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  34177. * Each element of this array is an object `{idx: int, faceId: int}`.
  34178. * `idx` is the picked particle index in the `SPS.particles` array
  34179. * `faceId` is the picked face index counted within this particle.
  34180. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  34181. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  34182. * Use the method SPS.pickedParticle(pickingInfo) instead.
  34183. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  34184. */
  34185. pickedParticles: {
  34186. idx: number;
  34187. faceId: number;
  34188. }[];
  34189. /**
  34190. * This array is populated when the SPS is set as 'pickable'
  34191. * Each key of this array is a submesh index.
  34192. * Each element of this array is a second array defined like this :
  34193. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  34194. * Each element of this second array is an object `{idx: int, faceId: int}`.
  34195. * `idx` is the picked particle index in the `SPS.particles` array
  34196. * `faceId` is the picked face index counted within this particle.
  34197. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  34198. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  34199. */
  34200. pickedBySubMesh: {
  34201. idx: number;
  34202. faceId: number;
  34203. }[][];
  34204. /**
  34205. * This array is populated when `enableDepthSort` is set to true.
  34206. * Each element of this array is an instance of the class DepthSortedParticle.
  34207. */
  34208. depthSortedParticles: DepthSortedParticle[];
  34209. /**
  34210. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  34211. * @hidden
  34212. */
  34213. _bSphereOnly: boolean;
  34214. /**
  34215. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  34216. * @hidden
  34217. */
  34218. _bSphereRadiusFactor: number;
  34219. private _scene;
  34220. private _positions;
  34221. private _indices;
  34222. private _normals;
  34223. private _colors;
  34224. private _uvs;
  34225. private _indices32;
  34226. private _positions32;
  34227. private _normals32;
  34228. private _fixedNormal32;
  34229. private _colors32;
  34230. private _uvs32;
  34231. private _index;
  34232. private _updatable;
  34233. private _pickable;
  34234. private _isVisibilityBoxLocked;
  34235. private _alwaysVisible;
  34236. private _depthSort;
  34237. private _expandable;
  34238. private _shapeCounter;
  34239. private _copy;
  34240. private _color;
  34241. private _computeParticleColor;
  34242. private _computeParticleTexture;
  34243. private _computeParticleRotation;
  34244. private _computeParticleVertex;
  34245. private _computeBoundingBox;
  34246. private _depthSortParticles;
  34247. private _camera;
  34248. private _mustUnrotateFixedNormals;
  34249. private _particlesIntersect;
  34250. private _needs32Bits;
  34251. private _isNotBuilt;
  34252. private _lastParticleId;
  34253. private _idxOfId;
  34254. private _multimaterialEnabled;
  34255. private _useModelMaterial;
  34256. private _indicesByMaterial;
  34257. private _materialIndexes;
  34258. private _depthSortFunction;
  34259. private _materialSortFunction;
  34260. private _materials;
  34261. private _multimaterial;
  34262. private _materialIndexesById;
  34263. private _defaultMaterial;
  34264. private _autoUpdateSubMeshes;
  34265. private _tmpVertex;
  34266. /**
  34267. * Creates a SPS (Solid Particle System) object.
  34268. * @param name (String) is the SPS name, this will be the underlying mesh name.
  34269. * @param scene (Scene) is the scene in which the SPS is added.
  34270. * @param options defines the options of the sps e.g.
  34271. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  34272. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  34273. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  34274. * * 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.
  34275. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  34276. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  34277. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  34278. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  34279. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  34280. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  34281. */
  34282. constructor(name: string, scene: Scene, options?: {
  34283. updatable?: boolean;
  34284. isPickable?: boolean;
  34285. enableDepthSort?: boolean;
  34286. particleIntersection?: boolean;
  34287. boundingSphereOnly?: boolean;
  34288. bSphereRadiusFactor?: number;
  34289. expandable?: boolean;
  34290. useModelMaterial?: boolean;
  34291. enableMultiMaterial?: boolean;
  34292. });
  34293. /**
  34294. * Builds the SPS underlying mesh. Returns a standard Mesh.
  34295. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  34296. * @returns the created mesh
  34297. */
  34298. buildMesh(): Mesh;
  34299. /**
  34300. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  34301. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  34302. * Thus the particles generated from `digest()` have their property `position` set yet.
  34303. * @param mesh ( Mesh ) is the mesh to be digested
  34304. * @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
  34305. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  34306. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  34307. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  34308. * @returns the current SPS
  34309. */
  34310. digest(mesh: Mesh, options?: {
  34311. facetNb?: number;
  34312. number?: number;
  34313. delta?: number;
  34314. storage?: [];
  34315. }): SolidParticleSystem;
  34316. /**
  34317. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  34318. * @hidden
  34319. */
  34320. private _unrotateFixedNormals;
  34321. /**
  34322. * Resets the temporary working copy particle
  34323. * @hidden
  34324. */
  34325. private _resetCopy;
  34326. /**
  34327. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  34328. * @param p the current index in the positions array to be updated
  34329. * @param ind the current index in the indices array
  34330. * @param shape a Vector3 array, the shape geometry
  34331. * @param positions the positions array to be updated
  34332. * @param meshInd the shape indices array
  34333. * @param indices the indices array to be updated
  34334. * @param meshUV the shape uv array
  34335. * @param uvs the uv array to be updated
  34336. * @param meshCol the shape color array
  34337. * @param colors the color array to be updated
  34338. * @param meshNor the shape normals array
  34339. * @param normals the normals array to be updated
  34340. * @param idx the particle index
  34341. * @param idxInShape the particle index in its shape
  34342. * @param options the addShape() method passed options
  34343. * @model the particle model
  34344. * @hidden
  34345. */
  34346. private _meshBuilder;
  34347. /**
  34348. * Returns a shape Vector3 array from positions float array
  34349. * @param positions float array
  34350. * @returns a vector3 array
  34351. * @hidden
  34352. */
  34353. private _posToShape;
  34354. /**
  34355. * Returns a shapeUV array from a float uvs (array deep copy)
  34356. * @param uvs as a float array
  34357. * @returns a shapeUV array
  34358. * @hidden
  34359. */
  34360. private _uvsToShapeUV;
  34361. /**
  34362. * Adds a new particle object in the particles array
  34363. * @param idx particle index in particles array
  34364. * @param id particle id
  34365. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  34366. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  34367. * @param model particle ModelShape object
  34368. * @param shapeId model shape identifier
  34369. * @param idxInShape index of the particle in the current model
  34370. * @param bInfo model bounding info object
  34371. * @param storage target storage array, if any
  34372. * @hidden
  34373. */
  34374. private _addParticle;
  34375. /**
  34376. * Adds some particles to the SPS from the model shape. Returns the shape id.
  34377. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  34378. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  34379. * @param nb (positive integer) the number of particles to be created from this model
  34380. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  34381. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  34382. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  34383. * @returns the number of shapes in the system
  34384. */
  34385. addShape(mesh: Mesh, nb: number, options?: {
  34386. positionFunction?: any;
  34387. vertexFunction?: any;
  34388. storage?: [];
  34389. }): number;
  34390. /**
  34391. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  34392. * @hidden
  34393. */
  34394. private _rebuildParticle;
  34395. /**
  34396. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  34397. * @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.
  34398. * @returns the SPS.
  34399. */
  34400. rebuildMesh(reset?: boolean): SolidParticleSystem;
  34401. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  34402. * Returns an array with the removed particles.
  34403. * 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.
  34404. * The SPS can't be empty so at least one particle needs to remain in place.
  34405. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  34406. * @param start index of the first particle to remove
  34407. * @param end index of the last particle to remove (included)
  34408. * @returns an array populated with the removed particles
  34409. */
  34410. removeParticles(start: number, end: number): SolidParticle[];
  34411. /**
  34412. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  34413. * @param solidParticleArray an array populated with Solid Particles objects
  34414. * @returns the SPS
  34415. */
  34416. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  34417. /**
  34418. * Creates a new particle and modifies the SPS mesh geometry :
  34419. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  34420. * - calls _addParticle() to populate the particle array
  34421. * factorized code from addShape() and insertParticlesFromArray()
  34422. * @param idx particle index in the particles array
  34423. * @param i particle index in its shape
  34424. * @param modelShape particle ModelShape object
  34425. * @param shape shape vertex array
  34426. * @param meshInd shape indices array
  34427. * @param meshUV shape uv array
  34428. * @param meshCol shape color array
  34429. * @param meshNor shape normals array
  34430. * @param bbInfo shape bounding info
  34431. * @param storage target particle storage
  34432. * @options addShape() passed options
  34433. * @hidden
  34434. */
  34435. private _insertNewParticle;
  34436. /**
  34437. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  34438. * This method calls `updateParticle()` for each particle of the SPS.
  34439. * For an animated SPS, it is usually called within the render loop.
  34440. * 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.
  34441. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  34442. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  34443. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  34444. * @returns the SPS.
  34445. */
  34446. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  34447. /**
  34448. * Disposes the SPS.
  34449. */
  34450. dispose(): void;
  34451. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  34452. * idx is the particle index in the SPS
  34453. * faceId is the picked face index counted within this particle.
  34454. * Returns null if the pickInfo can't identify a picked particle.
  34455. * @param pickingInfo (PickingInfo object)
  34456. * @returns {idx: number, faceId: number} or null
  34457. */
  34458. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  34459. idx: number;
  34460. faceId: number;
  34461. }>;
  34462. /**
  34463. * Returns a SolidParticle object from its identifier : particle.id
  34464. * @param id (integer) the particle Id
  34465. * @returns the searched particle or null if not found in the SPS.
  34466. */
  34467. getParticleById(id: number): Nullable<SolidParticle>;
  34468. /**
  34469. * Returns a new array populated with the particles having the passed shapeId.
  34470. * @param shapeId (integer) the shape identifier
  34471. * @returns a new solid particle array
  34472. */
  34473. getParticlesByShapeId(shapeId: number): SolidParticle[];
  34474. /**
  34475. * Populates the passed array "ref" with the particles having the passed shapeId.
  34476. * @param shapeId the shape identifier
  34477. * @returns the SPS
  34478. * @param ref
  34479. */
  34480. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  34481. /**
  34482. * Computes the required SubMeshes according the materials assigned to the particles.
  34483. * @returns the solid particle system.
  34484. * Does nothing if called before the SPS mesh is built.
  34485. */
  34486. computeSubMeshes(): SolidParticleSystem;
  34487. /**
  34488. * Sorts the solid particles by material when MultiMaterial is enabled.
  34489. * Updates the indices32 array.
  34490. * Updates the indicesByMaterial array.
  34491. * Updates the mesh indices array.
  34492. * @returns the SPS
  34493. * @hidden
  34494. */
  34495. private _sortParticlesByMaterial;
  34496. /**
  34497. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  34498. * @hidden
  34499. */
  34500. private _setMaterialIndexesById;
  34501. /**
  34502. * Returns an array with unique values of Materials from the passed array
  34503. * @param array the material array to be checked and filtered
  34504. * @hidden
  34505. */
  34506. private _filterUniqueMaterialId;
  34507. /**
  34508. * Sets a new Standard Material as _defaultMaterial if not already set.
  34509. * @hidden
  34510. */
  34511. private _setDefaultMaterial;
  34512. /**
  34513. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  34514. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34515. * @returns the SPS.
  34516. */
  34517. refreshVisibleSize(): SolidParticleSystem;
  34518. /**
  34519. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  34520. * @param size the size (float) of the visibility box
  34521. * note : this doesn't lock the SPS mesh bounding box.
  34522. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34523. */
  34524. setVisibilityBox(size: number): void;
  34525. /**
  34526. * Gets whether the SPS as always visible or not
  34527. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34528. */
  34529. get isAlwaysVisible(): boolean;
  34530. /**
  34531. * Sets the SPS as always visible or not
  34532. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34533. */
  34534. set isAlwaysVisible(val: boolean);
  34535. /**
  34536. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  34537. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34538. */
  34539. set isVisibilityBoxLocked(val: boolean);
  34540. /**
  34541. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  34542. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  34543. */
  34544. get isVisibilityBoxLocked(): boolean;
  34545. /**
  34546. * Tells to `setParticles()` to compute the particle rotations or not.
  34547. * Default value : true. The SPS is faster when it's set to false.
  34548. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  34549. */
  34550. set computeParticleRotation(val: boolean);
  34551. /**
  34552. * Tells to `setParticles()` to compute the particle colors or not.
  34553. * Default value : true. The SPS is faster when it's set to false.
  34554. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  34555. */
  34556. set computeParticleColor(val: boolean);
  34557. set computeParticleTexture(val: boolean);
  34558. /**
  34559. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  34560. * Default value : false. The SPS is faster when it's set to false.
  34561. * Note : the particle custom vertex positions aren't stored values.
  34562. */
  34563. set computeParticleVertex(val: boolean);
  34564. /**
  34565. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  34566. */
  34567. set computeBoundingBox(val: boolean);
  34568. /**
  34569. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  34570. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  34571. * Default : `true`
  34572. */
  34573. set depthSortParticles(val: boolean);
  34574. /**
  34575. * Gets if `setParticles()` computes the particle rotations or not.
  34576. * Default value : true. The SPS is faster when it's set to false.
  34577. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  34578. */
  34579. get computeParticleRotation(): boolean;
  34580. /**
  34581. * Gets if `setParticles()` computes the particle colors or not.
  34582. * Default value : true. The SPS is faster when it's set to false.
  34583. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  34584. */
  34585. get computeParticleColor(): boolean;
  34586. /**
  34587. * Gets if `setParticles()` computes the particle textures or not.
  34588. * Default value : true. The SPS is faster when it's set to false.
  34589. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  34590. */
  34591. get computeParticleTexture(): boolean;
  34592. /**
  34593. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  34594. * Default value : false. The SPS is faster when it's set to false.
  34595. * Note : the particle custom vertex positions aren't stored values.
  34596. */
  34597. get computeParticleVertex(): boolean;
  34598. /**
  34599. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  34600. */
  34601. get computeBoundingBox(): boolean;
  34602. /**
  34603. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  34604. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  34605. * Default : `true`
  34606. */
  34607. get depthSortParticles(): boolean;
  34608. /**
  34609. * Gets if the SPS is created as expandable at construction time.
  34610. * Default : `false`
  34611. */
  34612. get expandable(): boolean;
  34613. /**
  34614. * Gets if the SPS supports the Multi Materials
  34615. */
  34616. get multimaterialEnabled(): boolean;
  34617. /**
  34618. * Gets if the SPS uses the model materials for its own multimaterial.
  34619. */
  34620. get useModelMaterial(): boolean;
  34621. /**
  34622. * The SPS used material array.
  34623. */
  34624. get materials(): Material[];
  34625. /**
  34626. * Sets the SPS MultiMaterial from the passed materials.
  34627. * Note : the passed array is internally copied and not used then by reference.
  34628. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  34629. */
  34630. setMultiMaterial(materials: Material[]): void;
  34631. /**
  34632. * The SPS computed multimaterial object
  34633. */
  34634. get multimaterial(): MultiMaterial;
  34635. set multimaterial(mm: MultiMaterial);
  34636. /**
  34637. * If the subMeshes must be updated on the next call to setParticles()
  34638. */
  34639. get autoUpdateSubMeshes(): boolean;
  34640. set autoUpdateSubMeshes(val: boolean);
  34641. /**
  34642. * This function does nothing. It may be overwritten to set all the particle first values.
  34643. * The SPS doesn't call this function, you may have to call it by your own.
  34644. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  34645. */
  34646. initParticles(): void;
  34647. /**
  34648. * This function does nothing. It may be overwritten to recycle a particle.
  34649. * The SPS doesn't call this function, you may have to call it by your own.
  34650. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  34651. * @param particle The particle to recycle
  34652. * @returns the recycled particle
  34653. */
  34654. recycleParticle(particle: SolidParticle): SolidParticle;
  34655. /**
  34656. * Updates a particle : this function should be overwritten by the user.
  34657. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  34658. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  34659. * @example : just set a particle position or velocity and recycle conditions
  34660. * @param particle The particle to update
  34661. * @returns the updated particle
  34662. */
  34663. updateParticle(particle: SolidParticle): SolidParticle;
  34664. /**
  34665. * Updates a vertex of a particle : it can be overwritten by the user.
  34666. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  34667. * @param particle the current particle
  34668. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  34669. * @param pt the index of the current vertex in the particle shape
  34670. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  34671. * @example : just set a vertex particle position or color
  34672. * @returns the sps
  34673. */
  34674. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  34675. /**
  34676. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  34677. * This does nothing and may be overwritten by the user.
  34678. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  34679. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  34680. * @param update the boolean update value actually passed to setParticles()
  34681. */
  34682. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  34683. /**
  34684. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  34685. * This will be passed three parameters.
  34686. * This does nothing and may be overwritten by the user.
  34687. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  34688. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  34689. * @param update the boolean update value actually passed to setParticles()
  34690. */
  34691. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  34692. }
  34693. }
  34694. declare module BABYLON {
  34695. /**
  34696. * Represents one particle of a solid particle system.
  34697. */
  34698. export class SolidParticle {
  34699. /**
  34700. * particle global index
  34701. */
  34702. idx: number;
  34703. /**
  34704. * particle identifier
  34705. */
  34706. id: number;
  34707. /**
  34708. * The color of the particle
  34709. */
  34710. color: Nullable<Color4>;
  34711. /**
  34712. * The world space position of the particle.
  34713. */
  34714. position: Vector3;
  34715. /**
  34716. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  34717. */
  34718. rotation: Vector3;
  34719. /**
  34720. * The world space rotation quaternion of the particle.
  34721. */
  34722. rotationQuaternion: Nullable<Quaternion>;
  34723. /**
  34724. * The scaling of the particle.
  34725. */
  34726. scaling: Vector3;
  34727. /**
  34728. * The uvs of the particle.
  34729. */
  34730. uvs: Vector4;
  34731. /**
  34732. * The current speed of the particle.
  34733. */
  34734. velocity: Vector3;
  34735. /**
  34736. * The pivot point in the particle local space.
  34737. */
  34738. pivot: Vector3;
  34739. /**
  34740. * Must the particle be translated from its pivot point in its local space ?
  34741. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  34742. * Default : false
  34743. */
  34744. translateFromPivot: boolean;
  34745. /**
  34746. * Is the particle active or not ?
  34747. */
  34748. alive: boolean;
  34749. /**
  34750. * Is the particle visible or not ?
  34751. */
  34752. isVisible: boolean;
  34753. /**
  34754. * Index of this particle in the global "positions" array (Internal use)
  34755. * @hidden
  34756. */
  34757. _pos: number;
  34758. /**
  34759. * @hidden Index of this particle in the global "indices" array (Internal use)
  34760. */
  34761. _ind: number;
  34762. /**
  34763. * @hidden ModelShape of this particle (Internal use)
  34764. */
  34765. _model: ModelShape;
  34766. /**
  34767. * ModelShape id of this particle
  34768. */
  34769. shapeId: number;
  34770. /**
  34771. * Index of the particle in its shape id
  34772. */
  34773. idxInShape: number;
  34774. /**
  34775. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  34776. */
  34777. _modelBoundingInfo: BoundingInfo;
  34778. /**
  34779. * @hidden Particle BoundingInfo object (Internal use)
  34780. */
  34781. _boundingInfo: BoundingInfo;
  34782. /**
  34783. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  34784. */
  34785. _sps: SolidParticleSystem;
  34786. /**
  34787. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  34788. */
  34789. _stillInvisible: boolean;
  34790. /**
  34791. * @hidden Last computed particle rotation matrix
  34792. */
  34793. _rotationMatrix: number[];
  34794. /**
  34795. * Parent particle Id, if any.
  34796. * Default null.
  34797. */
  34798. parentId: Nullable<number>;
  34799. /**
  34800. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  34801. */
  34802. materialIndex: Nullable<number>;
  34803. /**
  34804. * Custom object or properties.
  34805. */
  34806. props: Nullable<any>;
  34807. /**
  34808. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  34809. * The possible values are :
  34810. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  34811. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  34812. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  34813. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  34814. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  34815. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  34816. * */
  34817. cullingStrategy: number;
  34818. /**
  34819. * @hidden Internal global position in the SPS.
  34820. */
  34821. _globalPosition: Vector3;
  34822. /**
  34823. * Creates a Solid Particle object.
  34824. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  34825. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  34826. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  34827. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  34828. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  34829. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  34830. * @param shapeId (integer) is the model shape identifier in the SPS.
  34831. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  34832. * @param sps defines the sps it is associated to
  34833. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  34834. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  34835. */
  34836. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  34837. /**
  34838. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  34839. * @param target the particle target
  34840. * @returns the current particle
  34841. */
  34842. copyToRef(target: SolidParticle): SolidParticle;
  34843. /**
  34844. * Legacy support, changed scale to scaling
  34845. */
  34846. get scale(): Vector3;
  34847. /**
  34848. * Legacy support, changed scale to scaling
  34849. */
  34850. set scale(scale: Vector3);
  34851. /**
  34852. * Legacy support, changed quaternion to rotationQuaternion
  34853. */
  34854. get quaternion(): Nullable<Quaternion>;
  34855. /**
  34856. * Legacy support, changed quaternion to rotationQuaternion
  34857. */
  34858. set quaternion(q: Nullable<Quaternion>);
  34859. /**
  34860. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  34861. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  34862. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  34863. * @returns true if it intersects
  34864. */
  34865. intersectsMesh(target: Mesh | SolidParticle): boolean;
  34866. /**
  34867. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  34868. * A particle is in the frustum if its bounding box intersects the frustum
  34869. * @param frustumPlanes defines the frustum to test
  34870. * @returns true if the particle is in the frustum planes
  34871. */
  34872. isInFrustum(frustumPlanes: Plane[]): boolean;
  34873. /**
  34874. * get the rotation matrix of the particle
  34875. * @hidden
  34876. */
  34877. getRotationMatrix(m: Matrix): void;
  34878. }
  34879. /**
  34880. * Represents the shape of the model used by one particle of a solid particle system.
  34881. * SPS internal tool, don't use it manually.
  34882. */
  34883. export class ModelShape {
  34884. /**
  34885. * The shape id
  34886. * @hidden
  34887. */
  34888. shapeID: number;
  34889. /**
  34890. * flat array of model positions (internal use)
  34891. * @hidden
  34892. */
  34893. _shape: Vector3[];
  34894. /**
  34895. * flat array of model UVs (internal use)
  34896. * @hidden
  34897. */
  34898. _shapeUV: number[];
  34899. /**
  34900. * color array of the model
  34901. * @hidden
  34902. */
  34903. _shapeColors: number[];
  34904. /**
  34905. * indices array of the model
  34906. * @hidden
  34907. */
  34908. _indices: number[];
  34909. /**
  34910. * normals array of the model
  34911. * @hidden
  34912. */
  34913. _normals: number[];
  34914. /**
  34915. * length of the shape in the model indices array (internal use)
  34916. * @hidden
  34917. */
  34918. _indicesLength: number;
  34919. /**
  34920. * Custom position function (internal use)
  34921. * @hidden
  34922. */
  34923. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  34924. /**
  34925. * Custom vertex function (internal use)
  34926. * @hidden
  34927. */
  34928. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  34929. /**
  34930. * Model material (internal use)
  34931. * @hidden
  34932. */
  34933. _material: Nullable<Material>;
  34934. /**
  34935. * 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.
  34936. * SPS internal tool, don't use it manually.
  34937. * @hidden
  34938. */
  34939. 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>);
  34940. }
  34941. /**
  34942. * Represents a Depth Sorted Particle in the solid particle system.
  34943. * @hidden
  34944. */
  34945. export class DepthSortedParticle {
  34946. /**
  34947. * Particle index
  34948. */
  34949. idx: number;
  34950. /**
  34951. * Index of the particle in the "indices" array
  34952. */
  34953. ind: number;
  34954. /**
  34955. * Length of the particle shape in the "indices" array
  34956. */
  34957. indicesLength: number;
  34958. /**
  34959. * Squared distance from the particle to the camera
  34960. */
  34961. sqDistance: number;
  34962. /**
  34963. * Material index when used with MultiMaterials
  34964. */
  34965. materialIndex: number;
  34966. /**
  34967. * Creates a new sorted particle
  34968. * @param materialIndex
  34969. */
  34970. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  34971. }
  34972. /**
  34973. * Represents a solid particle vertex
  34974. */
  34975. export class SolidParticleVertex {
  34976. /**
  34977. * Vertex position
  34978. */
  34979. position: Vector3;
  34980. /**
  34981. * Vertex color
  34982. */
  34983. color: Color4;
  34984. /**
  34985. * Vertex UV
  34986. */
  34987. uv: Vector2;
  34988. /**
  34989. * Creates a new solid particle vertex
  34990. */
  34991. constructor();
  34992. /** Vertex x coordinate */
  34993. get x(): number;
  34994. set x(val: number);
  34995. /** Vertex y coordinate */
  34996. get y(): number;
  34997. set y(val: number);
  34998. /** Vertex z coordinate */
  34999. get z(): number;
  35000. set z(val: number);
  35001. }
  35002. }
  35003. declare module BABYLON {
  35004. /**
  35005. * @hidden
  35006. */
  35007. export class _MeshCollisionData {
  35008. _checkCollisions: boolean;
  35009. _collisionMask: number;
  35010. _collisionGroup: number;
  35011. _surroundingMeshes: Nullable<AbstractMesh[]>;
  35012. _collider: Nullable<Collider>;
  35013. _oldPositionForCollisions: Vector3;
  35014. _diffPositionForCollisions: Vector3;
  35015. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  35016. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  35017. _collisionResponse: boolean;
  35018. }
  35019. }
  35020. declare module BABYLON {
  35021. /** @hidden */
  35022. class _FacetDataStorage {
  35023. facetPositions: Vector3[];
  35024. facetNormals: Vector3[];
  35025. facetPartitioning: number[][];
  35026. facetNb: number;
  35027. partitioningSubdivisions: number;
  35028. partitioningBBoxRatio: number;
  35029. facetDataEnabled: boolean;
  35030. facetParameters: any;
  35031. bbSize: Vector3;
  35032. subDiv: {
  35033. max: number;
  35034. X: number;
  35035. Y: number;
  35036. Z: number;
  35037. };
  35038. facetDepthSort: boolean;
  35039. facetDepthSortEnabled: boolean;
  35040. depthSortedIndices: IndicesArray;
  35041. depthSortedFacets: {
  35042. ind: number;
  35043. sqDistance: number;
  35044. }[];
  35045. facetDepthSortFunction: (f1: {
  35046. ind: number;
  35047. sqDistance: number;
  35048. }, f2: {
  35049. ind: number;
  35050. sqDistance: number;
  35051. }) => number;
  35052. facetDepthSortFrom: Vector3;
  35053. facetDepthSortOrigin: Vector3;
  35054. invertedMatrix: Matrix;
  35055. }
  35056. /**
  35057. * @hidden
  35058. **/
  35059. class _InternalAbstractMeshDataInfo {
  35060. _hasVertexAlpha: boolean;
  35061. _useVertexColors: boolean;
  35062. _numBoneInfluencers: number;
  35063. _applyFog: boolean;
  35064. _receiveShadows: boolean;
  35065. _facetData: _FacetDataStorage;
  35066. _visibility: number;
  35067. _skeleton: Nullable<Skeleton>;
  35068. _layerMask: number;
  35069. _computeBonesUsingShaders: boolean;
  35070. _isActive: boolean;
  35071. _onlyForInstances: boolean;
  35072. _isActiveIntermediate: boolean;
  35073. _onlyForInstancesIntermediate: boolean;
  35074. _actAsRegularMesh: boolean;
  35075. }
  35076. /**
  35077. * Class used to store all common mesh properties
  35078. */
  35079. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  35080. /** No occlusion */
  35081. static OCCLUSION_TYPE_NONE: number;
  35082. /** Occlusion set to optimisitic */
  35083. static OCCLUSION_TYPE_OPTIMISTIC: number;
  35084. /** Occlusion set to strict */
  35085. static OCCLUSION_TYPE_STRICT: number;
  35086. /** Use an accurante occlusion algorithm */
  35087. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  35088. /** Use a conservative occlusion algorithm */
  35089. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  35090. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  35091. * Test order :
  35092. * Is the bounding sphere outside the frustum ?
  35093. * If not, are the bounding box vertices outside the frustum ?
  35094. * It not, then the cullable object is in the frustum.
  35095. */
  35096. static readonly CULLINGSTRATEGY_STANDARD: number;
  35097. /** Culling strategy : Bounding Sphere Only.
  35098. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  35099. * It's also less accurate than the standard because some not visible objects can still be selected.
  35100. * Test : is the bounding sphere outside the frustum ?
  35101. * If not, then the cullable object is in the frustum.
  35102. */
  35103. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  35104. /** Culling strategy : Optimistic Inclusion.
  35105. * This in an inclusion test first, then the standard exclusion test.
  35106. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  35107. * 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.
  35108. * Anyway, it's as accurate as the standard strategy.
  35109. * Test :
  35110. * Is the cullable object bounding sphere center in the frustum ?
  35111. * If not, apply the default culling strategy.
  35112. */
  35113. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  35114. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  35115. * This in an inclusion test first, then the bounding sphere only exclusion test.
  35116. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  35117. * 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.
  35118. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  35119. * Test :
  35120. * Is the cullable object bounding sphere center in the frustum ?
  35121. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  35122. */
  35123. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  35124. /**
  35125. * No billboard
  35126. */
  35127. static get BILLBOARDMODE_NONE(): number;
  35128. /** Billboard on X axis */
  35129. static get BILLBOARDMODE_X(): number;
  35130. /** Billboard on Y axis */
  35131. static get BILLBOARDMODE_Y(): number;
  35132. /** Billboard on Z axis */
  35133. static get BILLBOARDMODE_Z(): number;
  35134. /** Billboard on all axes */
  35135. static get BILLBOARDMODE_ALL(): number;
  35136. /** Billboard on using position instead of orientation */
  35137. static get BILLBOARDMODE_USE_POSITION(): number;
  35138. /** @hidden */
  35139. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  35140. /**
  35141. * The culling strategy to use to check whether the mesh must be rendered or not.
  35142. * This value can be changed at any time and will be used on the next render mesh selection.
  35143. * The possible values are :
  35144. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  35145. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  35146. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  35147. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  35148. * Please read each static variable documentation to get details about the culling process.
  35149. * */
  35150. cullingStrategy: number;
  35151. /**
  35152. * Gets the number of facets in the mesh
  35153. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  35154. */
  35155. get facetNb(): number;
  35156. /**
  35157. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  35158. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  35159. */
  35160. get partitioningSubdivisions(): number;
  35161. set partitioningSubdivisions(nb: number);
  35162. /**
  35163. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  35164. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  35165. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  35166. */
  35167. get partitioningBBoxRatio(): number;
  35168. set partitioningBBoxRatio(ratio: number);
  35169. /**
  35170. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  35171. * Works only for updatable meshes.
  35172. * Doesn't work with multi-materials
  35173. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  35174. */
  35175. get mustDepthSortFacets(): boolean;
  35176. set mustDepthSortFacets(sort: boolean);
  35177. /**
  35178. * The location (Vector3) where the facet depth sort must be computed from.
  35179. * By default, the active camera position.
  35180. * Used only when facet depth sort is enabled
  35181. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  35182. */
  35183. get facetDepthSortFrom(): Vector3;
  35184. set facetDepthSortFrom(location: Vector3);
  35185. /**
  35186. * gets a boolean indicating if facetData is enabled
  35187. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  35188. */
  35189. get isFacetDataEnabled(): boolean;
  35190. /** @hidden */
  35191. _updateNonUniformScalingState(value: boolean): boolean;
  35192. /**
  35193. * An event triggered when this mesh collides with another one
  35194. */
  35195. onCollideObservable: Observable<AbstractMesh>;
  35196. /** Set a function to call when this mesh collides with another one */
  35197. set onCollide(callback: () => void);
  35198. /**
  35199. * An event triggered when the collision's position changes
  35200. */
  35201. onCollisionPositionChangeObservable: Observable<Vector3>;
  35202. /** Set a function to call when the collision's position changes */
  35203. set onCollisionPositionChange(callback: () => void);
  35204. /**
  35205. * An event triggered when material is changed
  35206. */
  35207. onMaterialChangedObservable: Observable<AbstractMesh>;
  35208. /**
  35209. * Gets or sets the orientation for POV movement & rotation
  35210. */
  35211. definedFacingForward: boolean;
  35212. /** @hidden */
  35213. _occlusionQuery: Nullable<WebGLQuery>;
  35214. /** @hidden */
  35215. _renderingGroup: Nullable<RenderingGroup>;
  35216. /**
  35217. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  35218. */
  35219. get visibility(): number;
  35220. /**
  35221. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  35222. */
  35223. set visibility(value: number);
  35224. /** Gets or sets the alpha index used to sort transparent meshes
  35225. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  35226. */
  35227. alphaIndex: number;
  35228. /**
  35229. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  35230. */
  35231. isVisible: boolean;
  35232. /**
  35233. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  35234. */
  35235. isPickable: boolean;
  35236. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  35237. showSubMeshesBoundingBox: boolean;
  35238. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  35239. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  35240. */
  35241. isBlocker: boolean;
  35242. /**
  35243. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  35244. */
  35245. enablePointerMoveEvents: boolean;
  35246. private _renderingGroupId;
  35247. /**
  35248. * Specifies the rendering group id for this mesh (0 by default)
  35249. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  35250. */
  35251. get renderingGroupId(): number;
  35252. set renderingGroupId(value: number);
  35253. private _material;
  35254. /** Gets or sets current material */
  35255. get material(): Nullable<Material>;
  35256. set material(value: Nullable<Material>);
  35257. /**
  35258. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  35259. * @see https://doc.babylonjs.com/babylon101/shadows
  35260. */
  35261. get receiveShadows(): boolean;
  35262. set receiveShadows(value: boolean);
  35263. /** Defines color to use when rendering outline */
  35264. outlineColor: Color3;
  35265. /** Define width to use when rendering outline */
  35266. outlineWidth: number;
  35267. /** Defines color to use when rendering overlay */
  35268. overlayColor: Color3;
  35269. /** Defines alpha to use when rendering overlay */
  35270. overlayAlpha: number;
  35271. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  35272. get hasVertexAlpha(): boolean;
  35273. set hasVertexAlpha(value: boolean);
  35274. /** 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) */
  35275. get useVertexColors(): boolean;
  35276. set useVertexColors(value: boolean);
  35277. /**
  35278. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  35279. */
  35280. get computeBonesUsingShaders(): boolean;
  35281. set computeBonesUsingShaders(value: boolean);
  35282. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  35283. get numBoneInfluencers(): number;
  35284. set numBoneInfluencers(value: number);
  35285. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  35286. get applyFog(): boolean;
  35287. set applyFog(value: boolean);
  35288. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  35289. useOctreeForRenderingSelection: boolean;
  35290. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  35291. useOctreeForPicking: boolean;
  35292. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  35293. useOctreeForCollisions: boolean;
  35294. /**
  35295. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  35296. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  35297. */
  35298. get layerMask(): number;
  35299. set layerMask(value: number);
  35300. /**
  35301. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  35302. */
  35303. alwaysSelectAsActiveMesh: boolean;
  35304. /**
  35305. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  35306. */
  35307. doNotSyncBoundingInfo: boolean;
  35308. /**
  35309. * Gets or sets the current action manager
  35310. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  35311. */
  35312. actionManager: Nullable<AbstractActionManager>;
  35313. private _meshCollisionData;
  35314. /**
  35315. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  35316. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35317. */
  35318. ellipsoid: Vector3;
  35319. /**
  35320. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  35321. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35322. */
  35323. ellipsoidOffset: Vector3;
  35324. /**
  35325. * Gets or sets a collision mask used to mask collisions (default is -1).
  35326. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  35327. */
  35328. get collisionMask(): number;
  35329. set collisionMask(mask: number);
  35330. /**
  35331. * Gets or sets a collision response flag (default is true).
  35332. * when collisionResponse is false, events are still triggered but colliding entity has no response
  35333. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  35334. * to respond to the collision.
  35335. */
  35336. get collisionResponse(): boolean;
  35337. set collisionResponse(response: boolean);
  35338. /**
  35339. * Gets or sets the current collision group mask (-1 by default).
  35340. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  35341. */
  35342. get collisionGroup(): number;
  35343. set collisionGroup(mask: number);
  35344. /**
  35345. * Gets or sets current surrounding meshes (null by default).
  35346. *
  35347. * By default collision detection is tested against every mesh in the scene.
  35348. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  35349. * meshes will be tested for the collision.
  35350. *
  35351. * Note: if set to an empty array no collision will happen when this mesh is moved.
  35352. */
  35353. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  35354. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  35355. /**
  35356. * Defines edge width used when edgesRenderer is enabled
  35357. * @see https://www.babylonjs-playground.com/#10OJSG#13
  35358. */
  35359. edgesWidth: number;
  35360. /**
  35361. * Defines edge color used when edgesRenderer is enabled
  35362. * @see https://www.babylonjs-playground.com/#10OJSG#13
  35363. */
  35364. edgesColor: Color4;
  35365. /** @hidden */
  35366. _edgesRenderer: Nullable<IEdgesRenderer>;
  35367. /** @hidden */
  35368. _masterMesh: Nullable<AbstractMesh>;
  35369. /** @hidden */
  35370. _boundingInfo: Nullable<BoundingInfo>;
  35371. /** @hidden */
  35372. _renderId: number;
  35373. /**
  35374. * Gets or sets the list of subMeshes
  35375. * @see https://doc.babylonjs.com/how_to/multi_materials
  35376. */
  35377. subMeshes: SubMesh[];
  35378. /** @hidden */
  35379. _intersectionsInProgress: AbstractMesh[];
  35380. /** @hidden */
  35381. _unIndexed: boolean;
  35382. /** @hidden */
  35383. _lightSources: Light[];
  35384. /** Gets the list of lights affecting that mesh */
  35385. get lightSources(): Light[];
  35386. /** @hidden */
  35387. get _positions(): Nullable<Vector3[]>;
  35388. /** @hidden */
  35389. _waitingData: {
  35390. lods: Nullable<any>;
  35391. actions: Nullable<any>;
  35392. freezeWorldMatrix: Nullable<boolean>;
  35393. };
  35394. /** @hidden */
  35395. _bonesTransformMatrices: Nullable<Float32Array>;
  35396. /** @hidden */
  35397. _transformMatrixTexture: Nullable<RawTexture>;
  35398. /**
  35399. * Gets or sets a skeleton to apply skining transformations
  35400. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  35401. */
  35402. set skeleton(value: Nullable<Skeleton>);
  35403. get skeleton(): Nullable<Skeleton>;
  35404. /**
  35405. * An event triggered when the mesh is rebuilt.
  35406. */
  35407. onRebuildObservable: Observable<AbstractMesh>;
  35408. /**
  35409. * Creates a new AbstractMesh
  35410. * @param name defines the name of the mesh
  35411. * @param scene defines the hosting scene
  35412. */
  35413. constructor(name: string, scene?: Nullable<Scene>);
  35414. /**
  35415. * Returns the string "AbstractMesh"
  35416. * @returns "AbstractMesh"
  35417. */
  35418. getClassName(): string;
  35419. /**
  35420. * Gets a string representation of the current mesh
  35421. * @param fullDetails defines a boolean indicating if full details must be included
  35422. * @returns a string representation of the current mesh
  35423. */
  35424. toString(fullDetails?: boolean): string;
  35425. /**
  35426. * @hidden
  35427. */
  35428. protected _getEffectiveParent(): Nullable<Node>;
  35429. /** @hidden */
  35430. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  35431. /** @hidden */
  35432. _rebuild(): void;
  35433. /** @hidden */
  35434. _resyncLightSources(): void;
  35435. /** @hidden */
  35436. _resyncLightSource(light: Light): void;
  35437. /** @hidden */
  35438. _unBindEffect(): void;
  35439. /** @hidden */
  35440. _removeLightSource(light: Light, dispose: boolean): void;
  35441. private _markSubMeshesAsDirty;
  35442. /** @hidden */
  35443. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  35444. /** @hidden */
  35445. _markSubMeshesAsAttributesDirty(): void;
  35446. /** @hidden */
  35447. _markSubMeshesAsMiscDirty(): void;
  35448. /**
  35449. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  35450. */
  35451. get scaling(): Vector3;
  35452. set scaling(newScaling: Vector3);
  35453. /**
  35454. * Returns true if the mesh is blocked. Implemented by child classes
  35455. */
  35456. get isBlocked(): boolean;
  35457. /**
  35458. * Returns the mesh itself by default. Implemented by child classes
  35459. * @param camera defines the camera to use to pick the right LOD level
  35460. * @returns the currentAbstractMesh
  35461. */
  35462. getLOD(camera: Camera): Nullable<AbstractMesh>;
  35463. /**
  35464. * Returns 0 by default. Implemented by child classes
  35465. * @returns an integer
  35466. */
  35467. getTotalVertices(): number;
  35468. /**
  35469. * Returns a positive integer : the total number of indices in this mesh geometry.
  35470. * @returns the numner of indices or zero if the mesh has no geometry.
  35471. */
  35472. getTotalIndices(): number;
  35473. /**
  35474. * Returns null by default. Implemented by child classes
  35475. * @returns null
  35476. */
  35477. getIndices(): Nullable<IndicesArray>;
  35478. /**
  35479. * Returns the array of the requested vertex data kind. Implemented by child classes
  35480. * @param kind defines the vertex data kind to use
  35481. * @returns null
  35482. */
  35483. getVerticesData(kind: string): Nullable<FloatArray>;
  35484. /**
  35485. * Sets the vertex data of the mesh geometry for the requested `kind`.
  35486. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  35487. * Note that a new underlying VertexBuffer object is created each call.
  35488. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  35489. * @param kind defines vertex data kind:
  35490. * * VertexBuffer.PositionKind
  35491. * * VertexBuffer.UVKind
  35492. * * VertexBuffer.UV2Kind
  35493. * * VertexBuffer.UV3Kind
  35494. * * VertexBuffer.UV4Kind
  35495. * * VertexBuffer.UV5Kind
  35496. * * VertexBuffer.UV6Kind
  35497. * * VertexBuffer.ColorKind
  35498. * * VertexBuffer.MatricesIndicesKind
  35499. * * VertexBuffer.MatricesIndicesExtraKind
  35500. * * VertexBuffer.MatricesWeightsKind
  35501. * * VertexBuffer.MatricesWeightsExtraKind
  35502. * @param data defines the data source
  35503. * @param updatable defines if the data must be flagged as updatable (or static)
  35504. * @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
  35505. * @returns the current mesh
  35506. */
  35507. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  35508. /**
  35509. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  35510. * If the mesh has no geometry, it is simply returned as it is.
  35511. * @param kind defines vertex data kind:
  35512. * * VertexBuffer.PositionKind
  35513. * * VertexBuffer.UVKind
  35514. * * VertexBuffer.UV2Kind
  35515. * * VertexBuffer.UV3Kind
  35516. * * VertexBuffer.UV4Kind
  35517. * * VertexBuffer.UV5Kind
  35518. * * VertexBuffer.UV6Kind
  35519. * * VertexBuffer.ColorKind
  35520. * * VertexBuffer.MatricesIndicesKind
  35521. * * VertexBuffer.MatricesIndicesExtraKind
  35522. * * VertexBuffer.MatricesWeightsKind
  35523. * * VertexBuffer.MatricesWeightsExtraKind
  35524. * @param data defines the data source
  35525. * @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
  35526. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  35527. * @returns the current mesh
  35528. */
  35529. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  35530. /**
  35531. * Sets the mesh indices,
  35532. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  35533. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  35534. * @param totalVertices Defines the total number of vertices
  35535. * @returns the current mesh
  35536. */
  35537. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  35538. /**
  35539. * Gets a boolean indicating if specific vertex data is present
  35540. * @param kind defines the vertex data kind to use
  35541. * @returns true is data kind is present
  35542. */
  35543. isVerticesDataPresent(kind: string): boolean;
  35544. /**
  35545. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  35546. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  35547. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  35548. * @returns a BoundingInfo
  35549. */
  35550. getBoundingInfo(): BoundingInfo;
  35551. /**
  35552. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  35553. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  35554. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  35555. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  35556. * @returns the current mesh
  35557. */
  35558. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  35559. /**
  35560. * Overwrite the current bounding info
  35561. * @param boundingInfo defines the new bounding info
  35562. * @returns the current mesh
  35563. */
  35564. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  35565. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  35566. get useBones(): boolean;
  35567. /** @hidden */
  35568. _preActivate(): void;
  35569. /** @hidden */
  35570. _preActivateForIntermediateRendering(renderId: number): void;
  35571. /** @hidden */
  35572. _activate(renderId: number, intermediateRendering: boolean): boolean;
  35573. /** @hidden */
  35574. _postActivate(): void;
  35575. /** @hidden */
  35576. _freeze(): void;
  35577. /** @hidden */
  35578. _unFreeze(): void;
  35579. /**
  35580. * Gets the current world matrix
  35581. * @returns a Matrix
  35582. */
  35583. getWorldMatrix(): Matrix;
  35584. /** @hidden */
  35585. _getWorldMatrixDeterminant(): number;
  35586. /**
  35587. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  35588. */
  35589. get isAnInstance(): boolean;
  35590. /**
  35591. * Gets a boolean indicating if this mesh has instances
  35592. */
  35593. get hasInstances(): boolean;
  35594. /**
  35595. * Gets a boolean indicating if this mesh has thin instances
  35596. */
  35597. get hasThinInstances(): boolean;
  35598. /**
  35599. * Perform relative position change from the point of view of behind the front of the mesh.
  35600. * This is performed taking into account the meshes current rotation, so you do not have to care.
  35601. * Supports definition of mesh facing forward or backward
  35602. * @param amountRight defines the distance on the right axis
  35603. * @param amountUp defines the distance on the up axis
  35604. * @param amountForward defines the distance on the forward axis
  35605. * @returns the current mesh
  35606. */
  35607. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  35608. /**
  35609. * Calculate relative position change from the point of view of behind the front of the mesh.
  35610. * This is performed taking into account the meshes current rotation, so you do not have to care.
  35611. * Supports definition of mesh facing forward or backward
  35612. * @param amountRight defines the distance on the right axis
  35613. * @param amountUp defines the distance on the up axis
  35614. * @param amountForward defines the distance on the forward axis
  35615. * @returns the new displacement vector
  35616. */
  35617. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  35618. /**
  35619. * Perform relative rotation change from the point of view of behind the front of the mesh.
  35620. * Supports definition of mesh facing forward or backward
  35621. * @param flipBack defines the flip
  35622. * @param twirlClockwise defines the twirl
  35623. * @param tiltRight defines the tilt
  35624. * @returns the current mesh
  35625. */
  35626. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  35627. /**
  35628. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  35629. * Supports definition of mesh facing forward or backward.
  35630. * @param flipBack defines the flip
  35631. * @param twirlClockwise defines the twirl
  35632. * @param tiltRight defines the tilt
  35633. * @returns the new rotation vector
  35634. */
  35635. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  35636. /**
  35637. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  35638. * This means the mesh underlying bounding box and sphere are recomputed.
  35639. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  35640. * @returns the current mesh
  35641. */
  35642. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  35643. /** @hidden */
  35644. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  35645. /** @hidden */
  35646. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  35647. /** @hidden */
  35648. _updateBoundingInfo(): AbstractMesh;
  35649. /** @hidden */
  35650. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  35651. /** @hidden */
  35652. protected _afterComputeWorldMatrix(): void;
  35653. /** @hidden */
  35654. get _effectiveMesh(): AbstractMesh;
  35655. /**
  35656. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  35657. * A mesh is in the frustum if its bounding box intersects the frustum
  35658. * @param frustumPlanes defines the frustum to test
  35659. * @returns true if the mesh is in the frustum planes
  35660. */
  35661. isInFrustum(frustumPlanes: Plane[]): boolean;
  35662. /**
  35663. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  35664. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  35665. * @param frustumPlanes defines the frustum to test
  35666. * @returns true if the mesh is completely in the frustum planes
  35667. */
  35668. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  35669. /**
  35670. * True if the mesh intersects another mesh or a SolidParticle object
  35671. * @param mesh defines a target mesh or SolidParticle to test
  35672. * @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)
  35673. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  35674. * @returns true if there is an intersection
  35675. */
  35676. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  35677. /**
  35678. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  35679. * @param point defines the point to test
  35680. * @returns true if there is an intersection
  35681. */
  35682. intersectsPoint(point: Vector3): boolean;
  35683. /**
  35684. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  35685. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35686. */
  35687. get checkCollisions(): boolean;
  35688. set checkCollisions(collisionEnabled: boolean);
  35689. /**
  35690. * Gets Collider object used to compute collisions (not physics)
  35691. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35692. */
  35693. get collider(): Nullable<Collider>;
  35694. /**
  35695. * Move the mesh using collision engine
  35696. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  35697. * @param displacement defines the requested displacement vector
  35698. * @returns the current mesh
  35699. */
  35700. moveWithCollisions(displacement: Vector3): AbstractMesh;
  35701. private _onCollisionPositionChange;
  35702. /** @hidden */
  35703. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  35704. /** @hidden */
  35705. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  35706. /** @hidden */
  35707. _checkCollision(collider: Collider): AbstractMesh;
  35708. /** @hidden */
  35709. _generatePointsArray(): boolean;
  35710. /**
  35711. * Checks if the passed Ray intersects with the mesh
  35712. * @param ray defines the ray to use
  35713. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  35714. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35715. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  35716. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  35717. * @returns the picking info
  35718. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  35719. */
  35720. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix): PickingInfo;
  35721. /**
  35722. * Clones the current mesh
  35723. * @param name defines the mesh name
  35724. * @param newParent defines the new mesh parent
  35725. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  35726. * @returns the new mesh
  35727. */
  35728. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  35729. /**
  35730. * Disposes all the submeshes of the current meshnp
  35731. * @returns the current mesh
  35732. */
  35733. releaseSubMeshes(): AbstractMesh;
  35734. /**
  35735. * Releases resources associated with this abstract mesh.
  35736. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  35737. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  35738. */
  35739. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  35740. /**
  35741. * Adds the passed mesh as a child to the current mesh
  35742. * @param mesh defines the child mesh
  35743. * @returns the current mesh
  35744. */
  35745. addChild(mesh: AbstractMesh): AbstractMesh;
  35746. /**
  35747. * Removes the passed mesh from the current mesh children list
  35748. * @param mesh defines the child mesh
  35749. * @returns the current mesh
  35750. */
  35751. removeChild(mesh: AbstractMesh): AbstractMesh;
  35752. /** @hidden */
  35753. private _initFacetData;
  35754. /**
  35755. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  35756. * This method can be called within the render loop.
  35757. * 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
  35758. * @returns the current mesh
  35759. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35760. */
  35761. updateFacetData(): AbstractMesh;
  35762. /**
  35763. * Returns the facetLocalNormals array.
  35764. * The normals are expressed in the mesh local spac
  35765. * @returns an array of Vector3
  35766. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35767. */
  35768. getFacetLocalNormals(): Vector3[];
  35769. /**
  35770. * Returns the facetLocalPositions array.
  35771. * The facet positions are expressed in the mesh local space
  35772. * @returns an array of Vector3
  35773. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35774. */
  35775. getFacetLocalPositions(): Vector3[];
  35776. /**
  35777. * Returns the facetLocalPartioning array
  35778. * @returns an array of array of numbers
  35779. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35780. */
  35781. getFacetLocalPartitioning(): number[][];
  35782. /**
  35783. * Returns the i-th facet position in the world system.
  35784. * This method allocates a new Vector3 per call
  35785. * @param i defines the facet index
  35786. * @returns a new Vector3
  35787. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35788. */
  35789. getFacetPosition(i: number): Vector3;
  35790. /**
  35791. * Sets the reference Vector3 with the i-th facet position in the world system
  35792. * @param i defines the facet index
  35793. * @param ref defines the target vector
  35794. * @returns the current mesh
  35795. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35796. */
  35797. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  35798. /**
  35799. * Returns the i-th facet normal in the world system.
  35800. * This method allocates a new Vector3 per call
  35801. * @param i defines the facet index
  35802. * @returns a new Vector3
  35803. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35804. */
  35805. getFacetNormal(i: number): Vector3;
  35806. /**
  35807. * Sets the reference Vector3 with the i-th facet normal in the world system
  35808. * @param i defines the facet index
  35809. * @param ref defines the target vector
  35810. * @returns the current mesh
  35811. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35812. */
  35813. getFacetNormalToRef(i: number, ref: Vector3): this;
  35814. /**
  35815. * 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)
  35816. * @param x defines x coordinate
  35817. * @param y defines y coordinate
  35818. * @param z defines z coordinate
  35819. * @returns the array of facet indexes
  35820. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35821. */
  35822. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  35823. /**
  35824. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  35825. * @param projected sets as the (x,y,z) world projection on the facet
  35826. * @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
  35827. * @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
  35828. * @param x defines x coordinate
  35829. * @param y defines y coordinate
  35830. * @param z defines z coordinate
  35831. * @returns the face index if found (or null instead)
  35832. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35833. */
  35834. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  35835. /**
  35836. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  35837. * @param projected sets as the (x,y,z) local projection on the facet
  35838. * @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
  35839. * @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
  35840. * @param x defines x coordinate
  35841. * @param y defines y coordinate
  35842. * @param z defines z coordinate
  35843. * @returns the face index if found (or null instead)
  35844. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35845. */
  35846. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  35847. /**
  35848. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  35849. * @returns the parameters
  35850. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35851. */
  35852. getFacetDataParameters(): any;
  35853. /**
  35854. * Disables the feature FacetData and frees the related memory
  35855. * @returns the current mesh
  35856. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  35857. */
  35858. disableFacetData(): AbstractMesh;
  35859. /**
  35860. * Updates the AbstractMesh indices array
  35861. * @param indices defines the data source
  35862. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  35863. * @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)
  35864. * @returns the current mesh
  35865. */
  35866. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  35867. /**
  35868. * Creates new normals data for the mesh
  35869. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  35870. * @returns the current mesh
  35871. */
  35872. createNormals(updatable: boolean): AbstractMesh;
  35873. /**
  35874. * Align the mesh with a normal
  35875. * @param normal defines the normal to use
  35876. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  35877. * @returns the current mesh
  35878. */
  35879. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  35880. /** @hidden */
  35881. _checkOcclusionQuery(): boolean;
  35882. /**
  35883. * Disables the mesh edge rendering mode
  35884. * @returns the currentAbstractMesh
  35885. */
  35886. disableEdgesRendering(): AbstractMesh;
  35887. /**
  35888. * Enables the edge rendering mode on the mesh.
  35889. * This mode makes the mesh edges visible
  35890. * @param epsilon defines the maximal distance between two angles to detect a face
  35891. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  35892. * @returns the currentAbstractMesh
  35893. * @see https://www.babylonjs-playground.com/#19O9TU#0
  35894. */
  35895. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  35896. /**
  35897. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  35898. * @returns an array of particle systems in the scene that use the mesh as an emitter
  35899. */
  35900. getConnectedParticleSystems(): IParticleSystem[];
  35901. }
  35902. }
  35903. declare module BABYLON {
  35904. /**
  35905. * Interface used to define ActionEvent
  35906. */
  35907. export interface IActionEvent {
  35908. /** The mesh or sprite that triggered the action */
  35909. source: any;
  35910. /** The X mouse cursor position at the time of the event */
  35911. pointerX: number;
  35912. /** The Y mouse cursor position at the time of the event */
  35913. pointerY: number;
  35914. /** The mesh that is currently pointed at (can be null) */
  35915. meshUnderPointer: Nullable<AbstractMesh>;
  35916. /** the original (browser) event that triggered the ActionEvent */
  35917. sourceEvent?: any;
  35918. /** additional data for the event */
  35919. additionalData?: any;
  35920. }
  35921. /**
  35922. * ActionEvent is the event being sent when an action is triggered.
  35923. */
  35924. export class ActionEvent implements IActionEvent {
  35925. /** The mesh or sprite that triggered the action */
  35926. source: any;
  35927. /** The X mouse cursor position at the time of the event */
  35928. pointerX: number;
  35929. /** The Y mouse cursor position at the time of the event */
  35930. pointerY: number;
  35931. /** The mesh that is currently pointed at (can be null) */
  35932. meshUnderPointer: Nullable<AbstractMesh>;
  35933. /** the original (browser) event that triggered the ActionEvent */
  35934. sourceEvent?: any;
  35935. /** additional data for the event */
  35936. additionalData?: any;
  35937. /**
  35938. * Creates a new ActionEvent
  35939. * @param source The mesh or sprite that triggered the action
  35940. * @param pointerX The X mouse cursor position at the time of the event
  35941. * @param pointerY The Y mouse cursor position at the time of the event
  35942. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  35943. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  35944. * @param additionalData additional data for the event
  35945. */
  35946. constructor(
  35947. /** The mesh or sprite that triggered the action */
  35948. source: any,
  35949. /** The X mouse cursor position at the time of the event */
  35950. pointerX: number,
  35951. /** The Y mouse cursor position at the time of the event */
  35952. pointerY: number,
  35953. /** The mesh that is currently pointed at (can be null) */
  35954. meshUnderPointer: Nullable<AbstractMesh>,
  35955. /** the original (browser) event that triggered the ActionEvent */
  35956. sourceEvent?: any,
  35957. /** additional data for the event */
  35958. additionalData?: any);
  35959. /**
  35960. * Helper function to auto-create an ActionEvent from a source mesh.
  35961. * @param source The source mesh that triggered the event
  35962. * @param evt The original (browser) event
  35963. * @param additionalData additional data for the event
  35964. * @returns the new ActionEvent
  35965. */
  35966. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  35967. /**
  35968. * Helper function to auto-create an ActionEvent from a source sprite
  35969. * @param source The source sprite that triggered the event
  35970. * @param scene Scene associated with the sprite
  35971. * @param evt The original (browser) event
  35972. * @param additionalData additional data for the event
  35973. * @returns the new ActionEvent
  35974. */
  35975. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  35976. /**
  35977. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  35978. * @param scene the scene where the event occurred
  35979. * @param evt The original (browser) event
  35980. * @returns the new ActionEvent
  35981. */
  35982. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  35983. /**
  35984. * Helper function to auto-create an ActionEvent from a primitive
  35985. * @param prim defines the target primitive
  35986. * @param pointerPos defines the pointer position
  35987. * @param evt The original (browser) event
  35988. * @param additionalData additional data for the event
  35989. * @returns the new ActionEvent
  35990. */
  35991. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  35992. }
  35993. }
  35994. declare module BABYLON {
  35995. /**
  35996. * Abstract class used to decouple action Manager from scene and meshes.
  35997. * Do not instantiate.
  35998. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  35999. */
  36000. export abstract class AbstractActionManager implements IDisposable {
  36001. /** Gets the list of active triggers */
  36002. static Triggers: {
  36003. [key: string]: number;
  36004. };
  36005. /** Gets the cursor to use when hovering items */
  36006. hoverCursor: string;
  36007. /** Gets the list of actions */
  36008. actions: IAction[];
  36009. /**
  36010. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  36011. */
  36012. isRecursive: boolean;
  36013. /**
  36014. * Releases all associated resources
  36015. */
  36016. abstract dispose(): void;
  36017. /**
  36018. * Does this action manager has pointer triggers
  36019. */
  36020. abstract get hasPointerTriggers(): boolean;
  36021. /**
  36022. * Does this action manager has pick triggers
  36023. */
  36024. abstract get hasPickTriggers(): boolean;
  36025. /**
  36026. * Process a specific trigger
  36027. * @param trigger defines the trigger to process
  36028. * @param evt defines the event details to be processed
  36029. */
  36030. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  36031. /**
  36032. * Does this action manager handles actions of any of the given triggers
  36033. * @param triggers defines the triggers to be tested
  36034. * @return a boolean indicating whether one (or more) of the triggers is handled
  36035. */
  36036. abstract hasSpecificTriggers(triggers: number[]): boolean;
  36037. /**
  36038. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  36039. * speed.
  36040. * @param triggerA defines the trigger to be tested
  36041. * @param triggerB defines the trigger to be tested
  36042. * @return a boolean indicating whether one (or more) of the triggers is handled
  36043. */
  36044. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  36045. /**
  36046. * Does this action manager handles actions of a given trigger
  36047. * @param trigger defines the trigger to be tested
  36048. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  36049. * @return whether the trigger is handled
  36050. */
  36051. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  36052. /**
  36053. * Serialize this manager to a JSON object
  36054. * @param name defines the property name to store this manager
  36055. * @returns a JSON representation of this manager
  36056. */
  36057. abstract serialize(name: string): any;
  36058. /**
  36059. * Registers an action to this action manager
  36060. * @param action defines the action to be registered
  36061. * @return the action amended (prepared) after registration
  36062. */
  36063. abstract registerAction(action: IAction): Nullable<IAction>;
  36064. /**
  36065. * Unregisters an action to this action manager
  36066. * @param action defines the action to be unregistered
  36067. * @return a boolean indicating whether the action has been unregistered
  36068. */
  36069. abstract unregisterAction(action: IAction): Boolean;
  36070. /**
  36071. * Does exist one action manager with at least one trigger
  36072. **/
  36073. static get HasTriggers(): boolean;
  36074. /**
  36075. * Does exist one action manager with at least one pick trigger
  36076. **/
  36077. static get HasPickTriggers(): boolean;
  36078. /**
  36079. * Does exist one action manager that handles actions of a given trigger
  36080. * @param trigger defines the trigger to be tested
  36081. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  36082. **/
  36083. static HasSpecificTrigger(trigger: number): boolean;
  36084. }
  36085. }
  36086. declare module BABYLON {
  36087. /**
  36088. * Defines how a node can be built from a string name.
  36089. */
  36090. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  36091. /**
  36092. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  36093. */
  36094. export class Node implements IBehaviorAware<Node> {
  36095. /** @hidden */
  36096. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  36097. private static _NodeConstructors;
  36098. /**
  36099. * Add a new node constructor
  36100. * @param type defines the type name of the node to construct
  36101. * @param constructorFunc defines the constructor function
  36102. */
  36103. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  36104. /**
  36105. * Returns a node constructor based on type name
  36106. * @param type defines the type name
  36107. * @param name defines the new node name
  36108. * @param scene defines the hosting scene
  36109. * @param options defines optional options to transmit to constructors
  36110. * @returns the new constructor or null
  36111. */
  36112. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  36113. /**
  36114. * Gets or sets the name of the node
  36115. */
  36116. name: string;
  36117. /**
  36118. * Gets or sets the id of the node
  36119. */
  36120. id: string;
  36121. /**
  36122. * Gets or sets the unique id of the node
  36123. */
  36124. uniqueId: number;
  36125. /**
  36126. * Gets or sets a string used to store user defined state for the node
  36127. */
  36128. state: string;
  36129. /**
  36130. * Gets or sets an object used to store user defined information for the node
  36131. */
  36132. metadata: any;
  36133. /**
  36134. * For internal use only. Please do not use.
  36135. */
  36136. reservedDataStore: any;
  36137. /**
  36138. * List of inspectable custom properties (used by the Inspector)
  36139. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  36140. */
  36141. inspectableCustomProperties: IInspectable[];
  36142. private _doNotSerialize;
  36143. /**
  36144. * Gets or sets a boolean used to define if the node must be serialized
  36145. */
  36146. get doNotSerialize(): boolean;
  36147. set doNotSerialize(value: boolean);
  36148. /** @hidden */
  36149. _isDisposed: boolean;
  36150. /**
  36151. * Gets a list of Animations associated with the node
  36152. */
  36153. animations: Animation[];
  36154. protected _ranges: {
  36155. [name: string]: Nullable<AnimationRange>;
  36156. };
  36157. /**
  36158. * Callback raised when the node is ready to be used
  36159. */
  36160. onReady: Nullable<(node: Node) => void>;
  36161. private _isEnabled;
  36162. private _isParentEnabled;
  36163. private _isReady;
  36164. /** @hidden */
  36165. _currentRenderId: number;
  36166. private _parentUpdateId;
  36167. /** @hidden */
  36168. _childUpdateId: number;
  36169. /** @hidden */
  36170. _waitingParentId: Nullable<string>;
  36171. /** @hidden */
  36172. _scene: Scene;
  36173. /** @hidden */
  36174. _cache: any;
  36175. private _parentNode;
  36176. private _children;
  36177. /** @hidden */
  36178. _worldMatrix: Matrix;
  36179. /** @hidden */
  36180. _worldMatrixDeterminant: number;
  36181. /** @hidden */
  36182. _worldMatrixDeterminantIsDirty: boolean;
  36183. /** @hidden */
  36184. private _sceneRootNodesIndex;
  36185. /**
  36186. * Gets a boolean indicating if the node has been disposed
  36187. * @returns true if the node was disposed
  36188. */
  36189. isDisposed(): boolean;
  36190. /**
  36191. * Gets or sets the parent of the node (without keeping the current position in the scene)
  36192. * @see https://doc.babylonjs.com/how_to/parenting
  36193. */
  36194. set parent(parent: Nullable<Node>);
  36195. get parent(): Nullable<Node>;
  36196. /** @hidden */
  36197. _addToSceneRootNodes(): void;
  36198. /** @hidden */
  36199. _removeFromSceneRootNodes(): void;
  36200. private _animationPropertiesOverride;
  36201. /**
  36202. * Gets or sets the animation properties override
  36203. */
  36204. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  36205. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  36206. /**
  36207. * Gets a string identifying the name of the class
  36208. * @returns "Node" string
  36209. */
  36210. getClassName(): string;
  36211. /** @hidden */
  36212. readonly _isNode: boolean;
  36213. /**
  36214. * An event triggered when the mesh is disposed
  36215. */
  36216. onDisposeObservable: Observable<Node>;
  36217. private _onDisposeObserver;
  36218. /**
  36219. * Sets a callback that will be raised when the node will be disposed
  36220. */
  36221. set onDispose(callback: () => void);
  36222. /**
  36223. * Creates a new Node
  36224. * @param name the name and id to be given to this node
  36225. * @param scene the scene this node will be added to
  36226. */
  36227. constructor(name: string, scene?: Nullable<Scene>);
  36228. /**
  36229. * Gets the scene of the node
  36230. * @returns a scene
  36231. */
  36232. getScene(): Scene;
  36233. /**
  36234. * Gets the engine of the node
  36235. * @returns a Engine
  36236. */
  36237. getEngine(): Engine;
  36238. private _behaviors;
  36239. /**
  36240. * Attach a behavior to the node
  36241. * @see https://doc.babylonjs.com/features/behaviour
  36242. * @param behavior defines the behavior to attach
  36243. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  36244. * @returns the current Node
  36245. */
  36246. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  36247. /**
  36248. * Remove an attached behavior
  36249. * @see https://doc.babylonjs.com/features/behaviour
  36250. * @param behavior defines the behavior to attach
  36251. * @returns the current Node
  36252. */
  36253. removeBehavior(behavior: Behavior<Node>): Node;
  36254. /**
  36255. * Gets the list of attached behaviors
  36256. * @see https://doc.babylonjs.com/features/behaviour
  36257. */
  36258. get behaviors(): Behavior<Node>[];
  36259. /**
  36260. * Gets an attached behavior by name
  36261. * @param name defines the name of the behavior to look for
  36262. * @see https://doc.babylonjs.com/features/behaviour
  36263. * @returns null if behavior was not found else the requested behavior
  36264. */
  36265. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  36266. /**
  36267. * Returns the latest update of the World matrix
  36268. * @returns a Matrix
  36269. */
  36270. getWorldMatrix(): Matrix;
  36271. /** @hidden */
  36272. _getWorldMatrixDeterminant(): number;
  36273. /**
  36274. * Returns directly the latest state of the mesh World matrix.
  36275. * A Matrix is returned.
  36276. */
  36277. get worldMatrixFromCache(): Matrix;
  36278. /** @hidden */
  36279. _initCache(): void;
  36280. /** @hidden */
  36281. updateCache(force?: boolean): void;
  36282. /** @hidden */
  36283. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  36284. /** @hidden */
  36285. _updateCache(ignoreParentClass?: boolean): void;
  36286. /** @hidden */
  36287. _isSynchronized(): boolean;
  36288. /** @hidden */
  36289. _markSyncedWithParent(): void;
  36290. /** @hidden */
  36291. isSynchronizedWithParent(): boolean;
  36292. /** @hidden */
  36293. isSynchronized(): boolean;
  36294. /**
  36295. * Is this node ready to be used/rendered
  36296. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  36297. * @return true if the node is ready
  36298. */
  36299. isReady(completeCheck?: boolean): boolean;
  36300. /**
  36301. * Is this node enabled?
  36302. * 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
  36303. * @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
  36304. * @return whether this node (and its parent) is enabled
  36305. */
  36306. isEnabled(checkAncestors?: boolean): boolean;
  36307. /** @hidden */
  36308. protected _syncParentEnabledState(): void;
  36309. /**
  36310. * Set the enabled state of this node
  36311. * @param value defines the new enabled state
  36312. */
  36313. setEnabled(value: boolean): void;
  36314. /**
  36315. * Is this node a descendant of the given node?
  36316. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  36317. * @param ancestor defines the parent node to inspect
  36318. * @returns a boolean indicating if this node is a descendant of the given node
  36319. */
  36320. isDescendantOf(ancestor: Node): boolean;
  36321. /** @hidden */
  36322. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  36323. /**
  36324. * Will return all nodes that have this node as ascendant
  36325. * @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
  36326. * @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
  36327. * @return all children nodes of all types
  36328. */
  36329. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  36330. /**
  36331. * Get all child-meshes of this node
  36332. * @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)
  36333. * @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
  36334. * @returns an array of AbstractMesh
  36335. */
  36336. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  36337. /**
  36338. * Get all direct children of this node
  36339. * @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
  36340. * @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)
  36341. * @returns an array of Node
  36342. */
  36343. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  36344. /** @hidden */
  36345. _setReady(state: boolean): void;
  36346. /**
  36347. * Get an animation by name
  36348. * @param name defines the name of the animation to look for
  36349. * @returns null if not found else the requested animation
  36350. */
  36351. getAnimationByName(name: string): Nullable<Animation>;
  36352. /**
  36353. * Creates an animation range for this node
  36354. * @param name defines the name of the range
  36355. * @param from defines the starting key
  36356. * @param to defines the end key
  36357. */
  36358. createAnimationRange(name: string, from: number, to: number): void;
  36359. /**
  36360. * Delete a specific animation range
  36361. * @param name defines the name of the range to delete
  36362. * @param deleteFrames defines if animation frames from the range must be deleted as well
  36363. */
  36364. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  36365. /**
  36366. * Get an animation range by name
  36367. * @param name defines the name of the animation range to look for
  36368. * @returns null if not found else the requested animation range
  36369. */
  36370. getAnimationRange(name: string): Nullable<AnimationRange>;
  36371. /**
  36372. * Gets the list of all animation ranges defined on this node
  36373. * @returns an array
  36374. */
  36375. getAnimationRanges(): Nullable<AnimationRange>[];
  36376. /**
  36377. * Will start the animation sequence
  36378. * @param name defines the range frames for animation sequence
  36379. * @param loop defines if the animation should loop (false by default)
  36380. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  36381. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  36382. * @returns the object created for this animation. If range does not exist, it will return null
  36383. */
  36384. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  36385. /**
  36386. * Serialize animation ranges into a JSON compatible object
  36387. * @returns serialization object
  36388. */
  36389. serializeAnimationRanges(): any;
  36390. /**
  36391. * Computes the world matrix of the node
  36392. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  36393. * @returns the world matrix
  36394. */
  36395. computeWorldMatrix(force?: boolean): Matrix;
  36396. /**
  36397. * Releases resources associated with this node.
  36398. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  36399. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  36400. */
  36401. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  36402. /**
  36403. * Parse animation range data from a serialization object and store them into a given node
  36404. * @param node defines where to store the animation ranges
  36405. * @param parsedNode defines the serialization object to read data from
  36406. * @param scene defines the hosting scene
  36407. */
  36408. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  36409. /**
  36410. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  36411. * @param includeDescendants Include bounding info from descendants as well (true by default)
  36412. * @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
  36413. * @returns the new bounding vectors
  36414. */
  36415. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  36416. min: Vector3;
  36417. max: Vector3;
  36418. };
  36419. }
  36420. }
  36421. declare module BABYLON {
  36422. /**
  36423. * @hidden
  36424. */
  36425. export class _IAnimationState {
  36426. key: number;
  36427. repeatCount: number;
  36428. workValue?: any;
  36429. loopMode?: number;
  36430. offsetValue?: any;
  36431. highLimitValue?: any;
  36432. }
  36433. /**
  36434. * Class used to store any kind of animation
  36435. */
  36436. export class Animation {
  36437. /**Name of the animation */
  36438. name: string;
  36439. /**Property to animate */
  36440. targetProperty: string;
  36441. /**The frames per second of the animation */
  36442. framePerSecond: number;
  36443. /**The data type of the animation */
  36444. dataType: number;
  36445. /**The loop mode of the animation */
  36446. loopMode?: number | undefined;
  36447. /**Specifies if blending should be enabled */
  36448. enableBlending?: boolean | undefined;
  36449. /**
  36450. * Use matrix interpolation instead of using direct key value when animating matrices
  36451. */
  36452. static AllowMatricesInterpolation: boolean;
  36453. /**
  36454. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  36455. */
  36456. static AllowMatrixDecomposeForInterpolation: boolean;
  36457. /** Define the Url to load snippets */
  36458. static SnippetUrl: string;
  36459. /** Snippet ID if the animation was created from the snippet server */
  36460. snippetId: string;
  36461. /**
  36462. * Stores the key frames of the animation
  36463. */
  36464. private _keys;
  36465. /**
  36466. * Stores the easing function of the animation
  36467. */
  36468. private _easingFunction;
  36469. /**
  36470. * @hidden Internal use only
  36471. */
  36472. _runtimeAnimations: RuntimeAnimation[];
  36473. /**
  36474. * The set of event that will be linked to this animation
  36475. */
  36476. private _events;
  36477. /**
  36478. * Stores an array of target property paths
  36479. */
  36480. targetPropertyPath: string[];
  36481. /**
  36482. * Stores the blending speed of the animation
  36483. */
  36484. blendingSpeed: number;
  36485. /**
  36486. * Stores the animation ranges for the animation
  36487. */
  36488. private _ranges;
  36489. /**
  36490. * @hidden Internal use
  36491. */
  36492. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  36493. /**
  36494. * Sets up an animation
  36495. * @param property The property to animate
  36496. * @param animationType The animation type to apply
  36497. * @param framePerSecond The frames per second of the animation
  36498. * @param easingFunction The easing function used in the animation
  36499. * @returns The created animation
  36500. */
  36501. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  36502. /**
  36503. * Create and start an animation on a node
  36504. * @param name defines the name of the global animation that will be run on all nodes
  36505. * @param node defines the root node where the animation will take place
  36506. * @param targetProperty defines property to animate
  36507. * @param framePerSecond defines the number of frame per second yo use
  36508. * @param totalFrame defines the number of frames in total
  36509. * @param from defines the initial value
  36510. * @param to defines the final value
  36511. * @param loopMode defines which loop mode you want to use (off by default)
  36512. * @param easingFunction defines the easing function to use (linear by default)
  36513. * @param onAnimationEnd defines the callback to call when animation end
  36514. * @returns the animatable created for this animation
  36515. */
  36516. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  36517. /**
  36518. * Create and start an animation on a node and its descendants
  36519. * @param name defines the name of the global animation that will be run on all nodes
  36520. * @param node defines the root node where the animation will take place
  36521. * @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
  36522. * @param targetProperty defines property to animate
  36523. * @param framePerSecond defines the number of frame per second to use
  36524. * @param totalFrame defines the number of frames in total
  36525. * @param from defines the initial value
  36526. * @param to defines the final value
  36527. * @param loopMode defines which loop mode you want to use (off by default)
  36528. * @param easingFunction defines the easing function to use (linear by default)
  36529. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  36530. * @returns the list of animatables created for all nodes
  36531. * @example https://www.babylonjs-playground.com/#MH0VLI
  36532. */
  36533. 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[]>;
  36534. /**
  36535. * Creates a new animation, merges it with the existing animations and starts it
  36536. * @param name Name of the animation
  36537. * @param node Node which contains the scene that begins the animations
  36538. * @param targetProperty Specifies which property to animate
  36539. * @param framePerSecond The frames per second of the animation
  36540. * @param totalFrame The total number of frames
  36541. * @param from The frame at the beginning of the animation
  36542. * @param to The frame at the end of the animation
  36543. * @param loopMode Specifies the loop mode of the animation
  36544. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  36545. * @param onAnimationEnd Callback to run once the animation is complete
  36546. * @returns Nullable animation
  36547. */
  36548. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  36549. /**
  36550. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  36551. * @param sourceAnimation defines the Animation containing keyframes to convert
  36552. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  36553. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  36554. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  36555. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  36556. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  36557. */
  36558. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  36559. /**
  36560. * Transition property of an host to the target Value
  36561. * @param property The property to transition
  36562. * @param targetValue The target Value of the property
  36563. * @param host The object where the property to animate belongs
  36564. * @param scene Scene used to run the animation
  36565. * @param frameRate Framerate (in frame/s) to use
  36566. * @param transition The transition type we want to use
  36567. * @param duration The duration of the animation, in milliseconds
  36568. * @param onAnimationEnd Callback trigger at the end of the animation
  36569. * @returns Nullable animation
  36570. */
  36571. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  36572. /**
  36573. * Return the array of runtime animations currently using this animation
  36574. */
  36575. get runtimeAnimations(): RuntimeAnimation[];
  36576. /**
  36577. * Specifies if any of the runtime animations are currently running
  36578. */
  36579. get hasRunningRuntimeAnimations(): boolean;
  36580. /**
  36581. * Initializes the animation
  36582. * @param name Name of the animation
  36583. * @param targetProperty Property to animate
  36584. * @param framePerSecond The frames per second of the animation
  36585. * @param dataType The data type of the animation
  36586. * @param loopMode The loop mode of the animation
  36587. * @param enableBlending Specifies if blending should be enabled
  36588. */
  36589. constructor(
  36590. /**Name of the animation */
  36591. name: string,
  36592. /**Property to animate */
  36593. targetProperty: string,
  36594. /**The frames per second of the animation */
  36595. framePerSecond: number,
  36596. /**The data type of the animation */
  36597. dataType: number,
  36598. /**The loop mode of the animation */
  36599. loopMode?: number | undefined,
  36600. /**Specifies if blending should be enabled */
  36601. enableBlending?: boolean | undefined);
  36602. /**
  36603. * Converts the animation to a string
  36604. * @param fullDetails support for multiple levels of logging within scene loading
  36605. * @returns String form of the animation
  36606. */
  36607. toString(fullDetails?: boolean): string;
  36608. /**
  36609. * Add an event to this animation
  36610. * @param event Event to add
  36611. */
  36612. addEvent(event: AnimationEvent): void;
  36613. /**
  36614. * Remove all events found at the given frame
  36615. * @param frame The frame to remove events from
  36616. */
  36617. removeEvents(frame: number): void;
  36618. /**
  36619. * Retrieves all the events from the animation
  36620. * @returns Events from the animation
  36621. */
  36622. getEvents(): AnimationEvent[];
  36623. /**
  36624. * Creates an animation range
  36625. * @param name Name of the animation range
  36626. * @param from Starting frame of the animation range
  36627. * @param to Ending frame of the animation
  36628. */
  36629. createRange(name: string, from: number, to: number): void;
  36630. /**
  36631. * Deletes an animation range by name
  36632. * @param name Name of the animation range to delete
  36633. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  36634. */
  36635. deleteRange(name: string, deleteFrames?: boolean): void;
  36636. /**
  36637. * Gets the animation range by name, or null if not defined
  36638. * @param name Name of the animation range
  36639. * @returns Nullable animation range
  36640. */
  36641. getRange(name: string): Nullable<AnimationRange>;
  36642. /**
  36643. * Gets the key frames from the animation
  36644. * @returns The key frames of the animation
  36645. */
  36646. getKeys(): Array<IAnimationKey>;
  36647. /**
  36648. * Gets the highest frame rate of the animation
  36649. * @returns Highest frame rate of the animation
  36650. */
  36651. getHighestFrame(): number;
  36652. /**
  36653. * Gets the easing function of the animation
  36654. * @returns Easing function of the animation
  36655. */
  36656. getEasingFunction(): IEasingFunction;
  36657. /**
  36658. * Sets the easing function of the animation
  36659. * @param easingFunction A custom mathematical formula for animation
  36660. */
  36661. setEasingFunction(easingFunction: EasingFunction): void;
  36662. /**
  36663. * Interpolates a scalar linearly
  36664. * @param startValue Start value of the animation curve
  36665. * @param endValue End value of the animation curve
  36666. * @param gradient Scalar amount to interpolate
  36667. * @returns Interpolated scalar value
  36668. */
  36669. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  36670. /**
  36671. * Interpolates a scalar cubically
  36672. * @param startValue Start value of the animation curve
  36673. * @param outTangent End tangent of the animation
  36674. * @param endValue End value of the animation curve
  36675. * @param inTangent Start tangent of the animation curve
  36676. * @param gradient Scalar amount to interpolate
  36677. * @returns Interpolated scalar value
  36678. */
  36679. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  36680. /**
  36681. * Interpolates a quaternion using a spherical linear interpolation
  36682. * @param startValue Start value of the animation curve
  36683. * @param endValue End value of the animation curve
  36684. * @param gradient Scalar amount to interpolate
  36685. * @returns Interpolated quaternion value
  36686. */
  36687. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  36688. /**
  36689. * Interpolates a quaternion cubically
  36690. * @param startValue Start value of the animation curve
  36691. * @param outTangent End tangent of the animation curve
  36692. * @param endValue End value of the animation curve
  36693. * @param inTangent Start tangent of the animation curve
  36694. * @param gradient Scalar amount to interpolate
  36695. * @returns Interpolated quaternion value
  36696. */
  36697. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  36698. /**
  36699. * Interpolates a Vector3 linearl
  36700. * @param startValue Start value of the animation curve
  36701. * @param endValue End value of the animation curve
  36702. * @param gradient Scalar amount to interpolate
  36703. * @returns Interpolated scalar value
  36704. */
  36705. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  36706. /**
  36707. * Interpolates a Vector3 cubically
  36708. * @param startValue Start value of the animation curve
  36709. * @param outTangent End tangent of the animation
  36710. * @param endValue End value of the animation curve
  36711. * @param inTangent Start tangent of the animation curve
  36712. * @param gradient Scalar amount to interpolate
  36713. * @returns InterpolatedVector3 value
  36714. */
  36715. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  36716. /**
  36717. * Interpolates a Vector2 linearly
  36718. * @param startValue Start value of the animation curve
  36719. * @param endValue End value of the animation curve
  36720. * @param gradient Scalar amount to interpolate
  36721. * @returns Interpolated Vector2 value
  36722. */
  36723. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  36724. /**
  36725. * Interpolates a Vector2 cubically
  36726. * @param startValue Start value of the animation curve
  36727. * @param outTangent End tangent of the animation
  36728. * @param endValue End value of the animation curve
  36729. * @param inTangent Start tangent of the animation curve
  36730. * @param gradient Scalar amount to interpolate
  36731. * @returns Interpolated Vector2 value
  36732. */
  36733. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  36734. /**
  36735. * Interpolates a size linearly
  36736. * @param startValue Start value of the animation curve
  36737. * @param endValue End value of the animation curve
  36738. * @param gradient Scalar amount to interpolate
  36739. * @returns Interpolated Size value
  36740. */
  36741. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  36742. /**
  36743. * Interpolates a Color3 linearly
  36744. * @param startValue Start value of the animation curve
  36745. * @param endValue End value of the animation curve
  36746. * @param gradient Scalar amount to interpolate
  36747. * @returns Interpolated Color3 value
  36748. */
  36749. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  36750. /**
  36751. * Interpolates a Color4 linearly
  36752. * @param startValue Start value of the animation curve
  36753. * @param endValue End value of the animation curve
  36754. * @param gradient Scalar amount to interpolate
  36755. * @returns Interpolated Color3 value
  36756. */
  36757. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  36758. /**
  36759. * @hidden Internal use only
  36760. */
  36761. _getKeyValue(value: any): any;
  36762. /**
  36763. * @hidden Internal use only
  36764. */
  36765. _interpolate(currentFrame: number, state: _IAnimationState): any;
  36766. /**
  36767. * Defines the function to use to interpolate matrices
  36768. * @param startValue defines the start matrix
  36769. * @param endValue defines the end matrix
  36770. * @param gradient defines the gradient between both matrices
  36771. * @param result defines an optional target matrix where to store the interpolation
  36772. * @returns the interpolated matrix
  36773. */
  36774. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  36775. /**
  36776. * Makes a copy of the animation
  36777. * @returns Cloned animation
  36778. */
  36779. clone(): Animation;
  36780. /**
  36781. * Sets the key frames of the animation
  36782. * @param values The animation key frames to set
  36783. */
  36784. setKeys(values: Array<IAnimationKey>): void;
  36785. /**
  36786. * Serializes the animation to an object
  36787. * @returns Serialized object
  36788. */
  36789. serialize(): any;
  36790. /**
  36791. * Float animation type
  36792. */
  36793. static readonly ANIMATIONTYPE_FLOAT: number;
  36794. /**
  36795. * Vector3 animation type
  36796. */
  36797. static readonly ANIMATIONTYPE_VECTOR3: number;
  36798. /**
  36799. * Quaternion animation type
  36800. */
  36801. static readonly ANIMATIONTYPE_QUATERNION: number;
  36802. /**
  36803. * Matrix animation type
  36804. */
  36805. static readonly ANIMATIONTYPE_MATRIX: number;
  36806. /**
  36807. * Color3 animation type
  36808. */
  36809. static readonly ANIMATIONTYPE_COLOR3: number;
  36810. /**
  36811. * Color3 animation type
  36812. */
  36813. static readonly ANIMATIONTYPE_COLOR4: number;
  36814. /**
  36815. * Vector2 animation type
  36816. */
  36817. static readonly ANIMATIONTYPE_VECTOR2: number;
  36818. /**
  36819. * Size animation type
  36820. */
  36821. static readonly ANIMATIONTYPE_SIZE: number;
  36822. /**
  36823. * Relative Loop Mode
  36824. */
  36825. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  36826. /**
  36827. * Cycle Loop Mode
  36828. */
  36829. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  36830. /**
  36831. * Constant Loop Mode
  36832. */
  36833. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  36834. /** @hidden */
  36835. static _UniversalLerp(left: any, right: any, amount: number): any;
  36836. /**
  36837. * Parses an animation object and creates an animation
  36838. * @param parsedAnimation Parsed animation object
  36839. * @returns Animation object
  36840. */
  36841. static Parse(parsedAnimation: any): Animation;
  36842. /**
  36843. * Appends the serialized animations from the source animations
  36844. * @param source Source containing the animations
  36845. * @param destination Target to store the animations
  36846. */
  36847. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  36848. /**
  36849. * Creates a new animation or an array of animations from a snippet saved in a remote file
  36850. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  36851. * @param url defines the url to load from
  36852. * @returns a promise that will resolve to the new animation or an array of animations
  36853. */
  36854. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  36855. /**
  36856. * Creates an animation or an array of animations from a snippet saved by the Inspector
  36857. * @param snippetId defines the snippet to load
  36858. * @returns a promise that will resolve to the new animation or a new array of animations
  36859. */
  36860. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  36861. }
  36862. }
  36863. declare module BABYLON {
  36864. /**
  36865. * Interface containing an array of animations
  36866. */
  36867. export interface IAnimatable {
  36868. /**
  36869. * Array of animations
  36870. */
  36871. animations: Nullable<Array<Animation>>;
  36872. }
  36873. }
  36874. declare module BABYLON {
  36875. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  36876. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36877. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36878. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36879. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36880. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36881. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36882. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36883. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36884. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36885. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36886. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36887. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36888. /**
  36889. * Decorator used to define property that can be serialized as reference to a camera
  36890. * @param sourceName defines the name of the property to decorate
  36891. */
  36892. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  36893. /**
  36894. * Class used to help serialization objects
  36895. */
  36896. export class SerializationHelper {
  36897. /** @hidden */
  36898. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  36899. /** @hidden */
  36900. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  36901. /** @hidden */
  36902. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  36903. /** @hidden */
  36904. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  36905. /**
  36906. * Appends the serialized animations from the source animations
  36907. * @param source Source containing the animations
  36908. * @param destination Target to store the animations
  36909. */
  36910. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  36911. /**
  36912. * Static function used to serialized a specific entity
  36913. * @param entity defines the entity to serialize
  36914. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  36915. * @returns a JSON compatible object representing the serialization of the entity
  36916. */
  36917. static Serialize<T>(entity: T, serializationObject?: any): any;
  36918. /**
  36919. * Creates a new entity from a serialization data object
  36920. * @param creationFunction defines a function used to instanciated the new entity
  36921. * @param source defines the source serialization data
  36922. * @param scene defines the hosting scene
  36923. * @param rootUrl defines the root url for resources
  36924. * @returns a new entity
  36925. */
  36926. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  36927. /**
  36928. * Clones an object
  36929. * @param creationFunction defines the function used to instanciate the new object
  36930. * @param source defines the source object
  36931. * @returns the cloned object
  36932. */
  36933. static Clone<T>(creationFunction: () => T, source: T): T;
  36934. /**
  36935. * Instanciates a new object based on a source one (some data will be shared between both object)
  36936. * @param creationFunction defines the function used to instanciate the new object
  36937. * @param source defines the source object
  36938. * @returns the new object
  36939. */
  36940. static Instanciate<T>(creationFunction: () => T, source: T): T;
  36941. }
  36942. }
  36943. declare module BABYLON {
  36944. /**
  36945. * Base class of all the textures in babylon.
  36946. * It groups all the common properties the materials, post process, lights... might need
  36947. * in order to make a correct use of the texture.
  36948. */
  36949. export class BaseTexture implements IAnimatable {
  36950. /**
  36951. * Default anisotropic filtering level for the application.
  36952. * It is set to 4 as a good tradeoff between perf and quality.
  36953. */
  36954. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  36955. /**
  36956. * Gets or sets the unique id of the texture
  36957. */
  36958. uniqueId: number;
  36959. /**
  36960. * Define the name of the texture.
  36961. */
  36962. name: string;
  36963. /**
  36964. * Gets or sets an object used to store user defined information.
  36965. */
  36966. metadata: any;
  36967. /**
  36968. * For internal use only. Please do not use.
  36969. */
  36970. reservedDataStore: any;
  36971. private _hasAlpha;
  36972. /**
  36973. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  36974. */
  36975. set hasAlpha(value: boolean);
  36976. get hasAlpha(): boolean;
  36977. /**
  36978. * Defines if the alpha value should be determined via the rgb values.
  36979. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  36980. */
  36981. getAlphaFromRGB: boolean;
  36982. /**
  36983. * Intensity or strength of the texture.
  36984. * It is commonly used by materials to fine tune the intensity of the texture
  36985. */
  36986. level: number;
  36987. /**
  36988. * Define the UV chanel to use starting from 0 and defaulting to 0.
  36989. * This is part of the texture as textures usually maps to one uv set.
  36990. */
  36991. coordinatesIndex: number;
  36992. protected _coordinatesMode: number;
  36993. /**
  36994. * How a texture is mapped.
  36995. *
  36996. * | Value | Type | Description |
  36997. * | ----- | ----------------------------------- | ----------- |
  36998. * | 0 | EXPLICIT_MODE | |
  36999. * | 1 | SPHERICAL_MODE | |
  37000. * | 2 | PLANAR_MODE | |
  37001. * | 3 | CUBIC_MODE | |
  37002. * | 4 | PROJECTION_MODE | |
  37003. * | 5 | SKYBOX_MODE | |
  37004. * | 6 | INVCUBIC_MODE | |
  37005. * | 7 | EQUIRECTANGULAR_MODE | |
  37006. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  37007. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  37008. */
  37009. set coordinatesMode(value: number);
  37010. get coordinatesMode(): number;
  37011. private _wrapU;
  37012. /**
  37013. * | Value | Type | Description |
  37014. * | ----- | ------------------ | ----------- |
  37015. * | 0 | CLAMP_ADDRESSMODE | |
  37016. * | 1 | WRAP_ADDRESSMODE | |
  37017. * | 2 | MIRROR_ADDRESSMODE | |
  37018. */
  37019. get wrapU(): number;
  37020. set wrapU(value: number);
  37021. private _wrapV;
  37022. /**
  37023. * | Value | Type | Description |
  37024. * | ----- | ------------------ | ----------- |
  37025. * | 0 | CLAMP_ADDRESSMODE | |
  37026. * | 1 | WRAP_ADDRESSMODE | |
  37027. * | 2 | MIRROR_ADDRESSMODE | |
  37028. */
  37029. get wrapV(): number;
  37030. set wrapV(value: number);
  37031. /**
  37032. * | Value | Type | Description |
  37033. * | ----- | ------------------ | ----------- |
  37034. * | 0 | CLAMP_ADDRESSMODE | |
  37035. * | 1 | WRAP_ADDRESSMODE | |
  37036. * | 2 | MIRROR_ADDRESSMODE | |
  37037. */
  37038. wrapR: number;
  37039. /**
  37040. * With compliant hardware and browser (supporting anisotropic filtering)
  37041. * this defines the level of anisotropic filtering in the texture.
  37042. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  37043. */
  37044. anisotropicFilteringLevel: number;
  37045. /**
  37046. * Define if the texture is a cube texture or if false a 2d texture.
  37047. */
  37048. get isCube(): boolean;
  37049. set isCube(value: boolean);
  37050. /**
  37051. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  37052. */
  37053. get is3D(): boolean;
  37054. set is3D(value: boolean);
  37055. /**
  37056. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  37057. */
  37058. get is2DArray(): boolean;
  37059. set is2DArray(value: boolean);
  37060. private _gammaSpace;
  37061. /**
  37062. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  37063. * HDR texture are usually stored in linear space.
  37064. * This only impacts the PBR and Background materials
  37065. */
  37066. get gammaSpace(): boolean;
  37067. set gammaSpace(gamma: boolean);
  37068. /**
  37069. * Gets or sets whether or not the texture contains RGBD data.
  37070. */
  37071. get isRGBD(): boolean;
  37072. set isRGBD(value: boolean);
  37073. /**
  37074. * Is Z inverted in the texture (useful in a cube texture).
  37075. */
  37076. invertZ: boolean;
  37077. /**
  37078. * Are mip maps generated for this texture or not.
  37079. */
  37080. get noMipmap(): boolean;
  37081. /**
  37082. * @hidden
  37083. */
  37084. lodLevelInAlpha: boolean;
  37085. /**
  37086. * With prefiltered texture, defined the offset used during the prefiltering steps.
  37087. */
  37088. get lodGenerationOffset(): number;
  37089. set lodGenerationOffset(value: number);
  37090. /**
  37091. * With prefiltered texture, defined the scale used during the prefiltering steps.
  37092. */
  37093. get lodGenerationScale(): number;
  37094. set lodGenerationScale(value: number);
  37095. /**
  37096. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  37097. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  37098. * average roughness values.
  37099. */
  37100. get linearSpecularLOD(): boolean;
  37101. set linearSpecularLOD(value: boolean);
  37102. /**
  37103. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  37104. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  37105. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  37106. */
  37107. get irradianceTexture(): Nullable<BaseTexture>;
  37108. set irradianceTexture(value: Nullable<BaseTexture>);
  37109. /**
  37110. * Define if the texture is a render target.
  37111. */
  37112. isRenderTarget: boolean;
  37113. /**
  37114. * Define the unique id of the texture in the scene.
  37115. */
  37116. get uid(): string;
  37117. /** @hidden */
  37118. _prefiltered: boolean;
  37119. /**
  37120. * Return a string representation of the texture.
  37121. * @returns the texture as a string
  37122. */
  37123. toString(): string;
  37124. /**
  37125. * Get the class name of the texture.
  37126. * @returns "BaseTexture"
  37127. */
  37128. getClassName(): string;
  37129. /**
  37130. * Define the list of animation attached to the texture.
  37131. */
  37132. animations: Animation[];
  37133. /**
  37134. * An event triggered when the texture is disposed.
  37135. */
  37136. onDisposeObservable: Observable<BaseTexture>;
  37137. private _onDisposeObserver;
  37138. /**
  37139. * Callback triggered when the texture has been disposed.
  37140. * Kept for back compatibility, you can use the onDisposeObservable instead.
  37141. */
  37142. set onDispose(callback: () => void);
  37143. /**
  37144. * Define the current state of the loading sequence when in delayed load mode.
  37145. */
  37146. delayLoadState: number;
  37147. protected _scene: Nullable<Scene>;
  37148. protected _engine: Nullable<ThinEngine>;
  37149. /** @hidden */
  37150. _texture: Nullable<InternalTexture>;
  37151. private _uid;
  37152. /**
  37153. * Define if the texture is preventinga material to render or not.
  37154. * If not and the texture is not ready, the engine will use a default black texture instead.
  37155. */
  37156. get isBlocking(): boolean;
  37157. /**
  37158. * Instantiates a new BaseTexture.
  37159. * Base class of all the textures in babylon.
  37160. * It groups all the common properties the materials, post process, lights... might need
  37161. * in order to make a correct use of the texture.
  37162. * @param sceneOrEngine Define the scene or engine the texture blongs to
  37163. */
  37164. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  37165. /**
  37166. * Get the scene the texture belongs to.
  37167. * @returns the scene or null if undefined
  37168. */
  37169. getScene(): Nullable<Scene>;
  37170. /** @hidden */
  37171. protected _getEngine(): Nullable<ThinEngine>;
  37172. /**
  37173. * Get the texture transform matrix used to offset tile the texture for istance.
  37174. * @returns the transformation matrix
  37175. */
  37176. getTextureMatrix(): Matrix;
  37177. /**
  37178. * Get the texture reflection matrix used to rotate/transform the reflection.
  37179. * @returns the reflection matrix
  37180. */
  37181. getReflectionTextureMatrix(): Matrix;
  37182. /**
  37183. * Get the underlying lower level texture from Babylon.
  37184. * @returns the insternal texture
  37185. */
  37186. getInternalTexture(): Nullable<InternalTexture>;
  37187. /**
  37188. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  37189. * @returns true if ready or not blocking
  37190. */
  37191. isReadyOrNotBlocking(): boolean;
  37192. /**
  37193. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  37194. * @returns true if fully ready
  37195. */
  37196. isReady(): boolean;
  37197. private _cachedSize;
  37198. /**
  37199. * Get the size of the texture.
  37200. * @returns the texture size.
  37201. */
  37202. getSize(): ISize;
  37203. /**
  37204. * Get the base size of the texture.
  37205. * It can be different from the size if the texture has been resized for POT for instance
  37206. * @returns the base size
  37207. */
  37208. getBaseSize(): ISize;
  37209. /**
  37210. * Update the sampling mode of the texture.
  37211. * Default is Trilinear mode.
  37212. *
  37213. * | Value | Type | Description |
  37214. * | ----- | ------------------ | ----------- |
  37215. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  37216. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  37217. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  37218. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  37219. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  37220. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  37221. * | 7 | NEAREST_LINEAR | |
  37222. * | 8 | NEAREST_NEAREST | |
  37223. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  37224. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  37225. * | 11 | LINEAR_LINEAR | |
  37226. * | 12 | LINEAR_NEAREST | |
  37227. *
  37228. * > _mag_: magnification filter (close to the viewer)
  37229. * > _min_: minification filter (far from the viewer)
  37230. * > _mip_: filter used between mip map levels
  37231. *@param samplingMode Define the new sampling mode of the texture
  37232. */
  37233. updateSamplingMode(samplingMode: number): void;
  37234. /**
  37235. * Scales the texture if is `canRescale()`
  37236. * @param ratio the resize factor we want to use to rescale
  37237. */
  37238. scale(ratio: number): void;
  37239. /**
  37240. * Get if the texture can rescale.
  37241. */
  37242. get canRescale(): boolean;
  37243. /** @hidden */
  37244. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  37245. /** @hidden */
  37246. _rebuild(): void;
  37247. /**
  37248. * Triggers the load sequence in delayed load mode.
  37249. */
  37250. delayLoad(): void;
  37251. /**
  37252. * Clones the texture.
  37253. * @returns the cloned texture
  37254. */
  37255. clone(): Nullable<BaseTexture>;
  37256. /**
  37257. * Get the texture underlying type (INT, FLOAT...)
  37258. */
  37259. get textureType(): number;
  37260. /**
  37261. * Get the texture underlying format (RGB, RGBA...)
  37262. */
  37263. get textureFormat(): number;
  37264. /**
  37265. * Indicates that textures need to be re-calculated for all materials
  37266. */
  37267. protected _markAllSubMeshesAsTexturesDirty(): void;
  37268. /**
  37269. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  37270. * This will returns an RGBA array buffer containing either in values (0-255) or
  37271. * float values (0-1) depending of the underlying buffer type.
  37272. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  37273. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  37274. * @param buffer defines a user defined buffer to fill with data (can be null)
  37275. * @returns The Array buffer containing the pixels data.
  37276. */
  37277. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  37278. /**
  37279. * Release and destroy the underlying lower level texture aka internalTexture.
  37280. */
  37281. releaseInternalTexture(): void;
  37282. /** @hidden */
  37283. get _lodTextureHigh(): Nullable<BaseTexture>;
  37284. /** @hidden */
  37285. get _lodTextureMid(): Nullable<BaseTexture>;
  37286. /** @hidden */
  37287. get _lodTextureLow(): Nullable<BaseTexture>;
  37288. /**
  37289. * Dispose the texture and release its associated resources.
  37290. */
  37291. dispose(): void;
  37292. /**
  37293. * Serialize the texture into a JSON representation that can be parsed later on.
  37294. * @returns the JSON representation of the texture
  37295. */
  37296. serialize(): any;
  37297. /**
  37298. * Helper function to be called back once a list of texture contains only ready textures.
  37299. * @param textures Define the list of textures to wait for
  37300. * @param callback Define the callback triggered once the entire list will be ready
  37301. */
  37302. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  37303. private static _isScene;
  37304. }
  37305. }
  37306. declare module BABYLON {
  37307. /**
  37308. * Options to be used when creating an effect.
  37309. */
  37310. export interface IEffectCreationOptions {
  37311. /**
  37312. * Atrributes that will be used in the shader.
  37313. */
  37314. attributes: string[];
  37315. /**
  37316. * Uniform varible names that will be set in the shader.
  37317. */
  37318. uniformsNames: string[];
  37319. /**
  37320. * Uniform buffer variable names that will be set in the shader.
  37321. */
  37322. uniformBuffersNames: string[];
  37323. /**
  37324. * Sampler texture variable names that will be set in the shader.
  37325. */
  37326. samplers: string[];
  37327. /**
  37328. * Define statements that will be set in the shader.
  37329. */
  37330. defines: any;
  37331. /**
  37332. * Possible fallbacks for this effect to improve performance when needed.
  37333. */
  37334. fallbacks: Nullable<IEffectFallbacks>;
  37335. /**
  37336. * Callback that will be called when the shader is compiled.
  37337. */
  37338. onCompiled: Nullable<(effect: Effect) => void>;
  37339. /**
  37340. * Callback that will be called if an error occurs during shader compilation.
  37341. */
  37342. onError: Nullable<(effect: Effect, errors: string) => void>;
  37343. /**
  37344. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  37345. */
  37346. indexParameters?: any;
  37347. /**
  37348. * Max number of lights that can be used in the shader.
  37349. */
  37350. maxSimultaneousLights?: number;
  37351. /**
  37352. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  37353. */
  37354. transformFeedbackVaryings?: Nullable<string[]>;
  37355. /**
  37356. * 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
  37357. */
  37358. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  37359. /**
  37360. * Is this effect rendering to several color attachments ?
  37361. */
  37362. multiTarget?: boolean;
  37363. }
  37364. /**
  37365. * Effect containing vertex and fragment shader that can be executed on an object.
  37366. */
  37367. export class Effect implements IDisposable {
  37368. /**
  37369. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  37370. */
  37371. static ShadersRepository: string;
  37372. /**
  37373. * Enable logging of the shader code when a compilation error occurs
  37374. */
  37375. static LogShaderCodeOnCompilationError: boolean;
  37376. /**
  37377. * Name of the effect.
  37378. */
  37379. name: any;
  37380. /**
  37381. * String container all the define statements that should be set on the shader.
  37382. */
  37383. defines: string;
  37384. /**
  37385. * Callback that will be called when the shader is compiled.
  37386. */
  37387. onCompiled: Nullable<(effect: Effect) => void>;
  37388. /**
  37389. * Callback that will be called if an error occurs during shader compilation.
  37390. */
  37391. onError: Nullable<(effect: Effect, errors: string) => void>;
  37392. /**
  37393. * Callback that will be called when effect is bound.
  37394. */
  37395. onBind: Nullable<(effect: Effect) => void>;
  37396. /**
  37397. * Unique ID of the effect.
  37398. */
  37399. uniqueId: number;
  37400. /**
  37401. * Observable that will be called when the shader is compiled.
  37402. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  37403. */
  37404. onCompileObservable: Observable<Effect>;
  37405. /**
  37406. * Observable that will be called if an error occurs during shader compilation.
  37407. */
  37408. onErrorObservable: Observable<Effect>;
  37409. /** @hidden */
  37410. _onBindObservable: Nullable<Observable<Effect>>;
  37411. /**
  37412. * @hidden
  37413. * Specifies if the effect was previously ready
  37414. */
  37415. _wasPreviouslyReady: boolean;
  37416. /**
  37417. * Observable that will be called when effect is bound.
  37418. */
  37419. get onBindObservable(): Observable<Effect>;
  37420. /** @hidden */
  37421. _bonesComputationForcedToCPU: boolean;
  37422. /** @hidden */
  37423. _multiTarget: boolean;
  37424. private static _uniqueIdSeed;
  37425. private _engine;
  37426. private _uniformBuffersNames;
  37427. private _uniformBuffersNamesList;
  37428. private _uniformsNames;
  37429. private _samplerList;
  37430. private _samplers;
  37431. private _isReady;
  37432. private _compilationError;
  37433. private _allFallbacksProcessed;
  37434. private _attributesNames;
  37435. private _attributes;
  37436. private _attributeLocationByName;
  37437. private _uniforms;
  37438. /**
  37439. * Key for the effect.
  37440. * @hidden
  37441. */
  37442. _key: string;
  37443. private _indexParameters;
  37444. private _fallbacks;
  37445. private _vertexSourceCode;
  37446. private _fragmentSourceCode;
  37447. private _vertexSourceCodeOverride;
  37448. private _fragmentSourceCodeOverride;
  37449. private _transformFeedbackVaryings;
  37450. /**
  37451. * Compiled shader to webGL program.
  37452. * @hidden
  37453. */
  37454. _pipelineContext: Nullable<IPipelineContext>;
  37455. private _valueCache;
  37456. private static _baseCache;
  37457. /**
  37458. * Instantiates an effect.
  37459. * An effect can be used to create/manage/execute vertex and fragment shaders.
  37460. * @param baseName Name of the effect.
  37461. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  37462. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  37463. * @param samplers List of sampler variables that will be passed to the shader.
  37464. * @param engine Engine to be used to render the effect
  37465. * @param defines Define statements to be added to the shader.
  37466. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  37467. * @param onCompiled Callback that will be called when the shader is compiled.
  37468. * @param onError Callback that will be called if an error occurs during shader compilation.
  37469. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  37470. */
  37471. 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);
  37472. private _useFinalCode;
  37473. /**
  37474. * Unique key for this effect
  37475. */
  37476. get key(): string;
  37477. /**
  37478. * If the effect has been compiled and prepared.
  37479. * @returns if the effect is compiled and prepared.
  37480. */
  37481. isReady(): boolean;
  37482. private _isReadyInternal;
  37483. /**
  37484. * The engine the effect was initialized with.
  37485. * @returns the engine.
  37486. */
  37487. getEngine(): Engine;
  37488. /**
  37489. * The pipeline context for this effect
  37490. * @returns the associated pipeline context
  37491. */
  37492. getPipelineContext(): Nullable<IPipelineContext>;
  37493. /**
  37494. * The set of names of attribute variables for the shader.
  37495. * @returns An array of attribute names.
  37496. */
  37497. getAttributesNames(): string[];
  37498. /**
  37499. * Returns the attribute at the given index.
  37500. * @param index The index of the attribute.
  37501. * @returns The location of the attribute.
  37502. */
  37503. getAttributeLocation(index: number): number;
  37504. /**
  37505. * Returns the attribute based on the name of the variable.
  37506. * @param name of the attribute to look up.
  37507. * @returns the attribute location.
  37508. */
  37509. getAttributeLocationByName(name: string): number;
  37510. /**
  37511. * The number of attributes.
  37512. * @returns the numnber of attributes.
  37513. */
  37514. getAttributesCount(): number;
  37515. /**
  37516. * Gets the index of a uniform variable.
  37517. * @param uniformName of the uniform to look up.
  37518. * @returns the index.
  37519. */
  37520. getUniformIndex(uniformName: string): number;
  37521. /**
  37522. * Returns the attribute based on the name of the variable.
  37523. * @param uniformName of the uniform to look up.
  37524. * @returns the location of the uniform.
  37525. */
  37526. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  37527. /**
  37528. * Returns an array of sampler variable names
  37529. * @returns The array of sampler variable names.
  37530. */
  37531. getSamplers(): string[];
  37532. /**
  37533. * Returns an array of uniform variable names
  37534. * @returns The array of uniform variable names.
  37535. */
  37536. getUniformNames(): string[];
  37537. /**
  37538. * Returns an array of uniform buffer variable names
  37539. * @returns The array of uniform buffer variable names.
  37540. */
  37541. getUniformBuffersNames(): string[];
  37542. /**
  37543. * Returns the index parameters used to create the effect
  37544. * @returns The index parameters object
  37545. */
  37546. getIndexParameters(): any;
  37547. /**
  37548. * The error from the last compilation.
  37549. * @returns the error string.
  37550. */
  37551. getCompilationError(): string;
  37552. /**
  37553. * Gets a boolean indicating that all fallbacks were used during compilation
  37554. * @returns true if all fallbacks were used
  37555. */
  37556. allFallbacksProcessed(): boolean;
  37557. /**
  37558. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  37559. * @param func The callback to be used.
  37560. */
  37561. executeWhenCompiled(func: (effect: Effect) => void): void;
  37562. private _checkIsReady;
  37563. private _loadShader;
  37564. /**
  37565. * Gets the vertex shader source code of this effect
  37566. */
  37567. get vertexSourceCode(): string;
  37568. /**
  37569. * Gets the fragment shader source code of this effect
  37570. */
  37571. get fragmentSourceCode(): string;
  37572. /**
  37573. * Recompiles the webGL program
  37574. * @param vertexSourceCode The source code for the vertex shader.
  37575. * @param fragmentSourceCode The source code for the fragment shader.
  37576. * @param onCompiled Callback called when completed.
  37577. * @param onError Callback called on error.
  37578. * @hidden
  37579. */
  37580. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  37581. /**
  37582. * Prepares the effect
  37583. * @hidden
  37584. */
  37585. _prepareEffect(): void;
  37586. private _getShaderCodeAndErrorLine;
  37587. private _processCompilationErrors;
  37588. /**
  37589. * Checks if the effect is supported. (Must be called after compilation)
  37590. */
  37591. get isSupported(): boolean;
  37592. /**
  37593. * Binds a texture to the engine to be used as output of the shader.
  37594. * @param channel Name of the output variable.
  37595. * @param texture Texture to bind.
  37596. * @hidden
  37597. */
  37598. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  37599. /**
  37600. * Sets a texture on the engine to be used in the shader.
  37601. * @param channel Name of the sampler variable.
  37602. * @param texture Texture to set.
  37603. */
  37604. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  37605. /**
  37606. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  37607. * @param channel Name of the sampler variable.
  37608. * @param texture Texture to set.
  37609. */
  37610. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  37611. /**
  37612. * Sets an array of textures on the engine to be used in the shader.
  37613. * @param channel Name of the variable.
  37614. * @param textures Textures to set.
  37615. */
  37616. setTextureArray(channel: string, textures: BaseTexture[]): void;
  37617. /**
  37618. * 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)
  37619. * @param channel Name of the sampler variable.
  37620. * @param postProcess Post process to get the input texture from.
  37621. */
  37622. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  37623. /**
  37624. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  37625. * 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)
  37626. * @param channel Name of the sampler variable.
  37627. * @param postProcess Post process to get the output texture from.
  37628. */
  37629. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  37630. /** @hidden */
  37631. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  37632. /** @hidden */
  37633. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  37634. /** @hidden */
  37635. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  37636. /** @hidden */
  37637. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  37638. /**
  37639. * Binds a buffer to a uniform.
  37640. * @param buffer Buffer to bind.
  37641. * @param name Name of the uniform variable to bind to.
  37642. */
  37643. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  37644. /**
  37645. * Binds block to a uniform.
  37646. * @param blockName Name of the block to bind.
  37647. * @param index Index to bind.
  37648. */
  37649. bindUniformBlock(blockName: string, index: number): void;
  37650. /**
  37651. * Sets an interger value on a uniform variable.
  37652. * @param uniformName Name of the variable.
  37653. * @param value Value to be set.
  37654. * @returns this effect.
  37655. */
  37656. setInt(uniformName: string, value: number): Effect;
  37657. /**
  37658. * Sets an int array on a uniform variable.
  37659. * @param uniformName Name of the variable.
  37660. * @param array array to be set.
  37661. * @returns this effect.
  37662. */
  37663. setIntArray(uniformName: string, array: Int32Array): Effect;
  37664. /**
  37665. * 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)
  37666. * @param uniformName Name of the variable.
  37667. * @param array array to be set.
  37668. * @returns this effect.
  37669. */
  37670. setIntArray2(uniformName: string, array: Int32Array): Effect;
  37671. /**
  37672. * 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)
  37673. * @param uniformName Name of the variable.
  37674. * @param array array to be set.
  37675. * @returns this effect.
  37676. */
  37677. setIntArray3(uniformName: string, array: Int32Array): Effect;
  37678. /**
  37679. * 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)
  37680. * @param uniformName Name of the variable.
  37681. * @param array array to be set.
  37682. * @returns this effect.
  37683. */
  37684. setIntArray4(uniformName: string, array: Int32Array): Effect;
  37685. /**
  37686. * Sets an float array on a uniform variable.
  37687. * @param uniformName Name of the variable.
  37688. * @param array array to be set.
  37689. * @returns this effect.
  37690. */
  37691. setFloatArray(uniformName: string, array: Float32Array): Effect;
  37692. /**
  37693. * 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)
  37694. * @param uniformName Name of the variable.
  37695. * @param array array to be set.
  37696. * @returns this effect.
  37697. */
  37698. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  37699. /**
  37700. * 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)
  37701. * @param uniformName Name of the variable.
  37702. * @param array array to be set.
  37703. * @returns this effect.
  37704. */
  37705. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  37706. /**
  37707. * 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)
  37708. * @param uniformName Name of the variable.
  37709. * @param array array to be set.
  37710. * @returns this effect.
  37711. */
  37712. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  37713. /**
  37714. * Sets an array on a uniform variable.
  37715. * @param uniformName Name of the variable.
  37716. * @param array array to be set.
  37717. * @returns this effect.
  37718. */
  37719. setArray(uniformName: string, array: number[]): Effect;
  37720. /**
  37721. * 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)
  37722. * @param uniformName Name of the variable.
  37723. * @param array array to be set.
  37724. * @returns this effect.
  37725. */
  37726. setArray2(uniformName: string, array: number[]): Effect;
  37727. /**
  37728. * 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)
  37729. * @param uniformName Name of the variable.
  37730. * @param array array to be set.
  37731. * @returns this effect.
  37732. */
  37733. setArray3(uniformName: string, array: number[]): Effect;
  37734. /**
  37735. * 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)
  37736. * @param uniformName Name of the variable.
  37737. * @param array array to be set.
  37738. * @returns this effect.
  37739. */
  37740. setArray4(uniformName: string, array: number[]): Effect;
  37741. /**
  37742. * Sets matrices on a uniform variable.
  37743. * @param uniformName Name of the variable.
  37744. * @param matrices matrices to be set.
  37745. * @returns this effect.
  37746. */
  37747. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  37748. /**
  37749. * Sets matrix on a uniform variable.
  37750. * @param uniformName Name of the variable.
  37751. * @param matrix matrix to be set.
  37752. * @returns this effect.
  37753. */
  37754. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  37755. /**
  37756. * 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)
  37757. * @param uniformName Name of the variable.
  37758. * @param matrix matrix to be set.
  37759. * @returns this effect.
  37760. */
  37761. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  37762. /**
  37763. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  37764. * @param uniformName Name of the variable.
  37765. * @param matrix matrix to be set.
  37766. * @returns this effect.
  37767. */
  37768. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  37769. /**
  37770. * Sets a float on a uniform variable.
  37771. * @param uniformName Name of the variable.
  37772. * @param value value to be set.
  37773. * @returns this effect.
  37774. */
  37775. setFloat(uniformName: string, value: number): Effect;
  37776. /**
  37777. * Sets a boolean on a uniform variable.
  37778. * @param uniformName Name of the variable.
  37779. * @param bool value to be set.
  37780. * @returns this effect.
  37781. */
  37782. setBool(uniformName: string, bool: boolean): Effect;
  37783. /**
  37784. * Sets a Vector2 on a uniform variable.
  37785. * @param uniformName Name of the variable.
  37786. * @param vector2 vector2 to be set.
  37787. * @returns this effect.
  37788. */
  37789. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  37790. /**
  37791. * Sets a float2 on a uniform variable.
  37792. * @param uniformName Name of the variable.
  37793. * @param x First float in float2.
  37794. * @param y Second float in float2.
  37795. * @returns this effect.
  37796. */
  37797. setFloat2(uniformName: string, x: number, y: number): Effect;
  37798. /**
  37799. * Sets a Vector3 on a uniform variable.
  37800. * @param uniformName Name of the variable.
  37801. * @param vector3 Value to be set.
  37802. * @returns this effect.
  37803. */
  37804. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  37805. /**
  37806. * Sets a float3 on a uniform variable.
  37807. * @param uniformName Name of the variable.
  37808. * @param x First float in float3.
  37809. * @param y Second float in float3.
  37810. * @param z Third float in float3.
  37811. * @returns this effect.
  37812. */
  37813. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  37814. /**
  37815. * Sets a Vector4 on a uniform variable.
  37816. * @param uniformName Name of the variable.
  37817. * @param vector4 Value to be set.
  37818. * @returns this effect.
  37819. */
  37820. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  37821. /**
  37822. * Sets a float4 on a uniform variable.
  37823. * @param uniformName Name of the variable.
  37824. * @param x First float in float4.
  37825. * @param y Second float in float4.
  37826. * @param z Third float in float4.
  37827. * @param w Fourth float in float4.
  37828. * @returns this effect.
  37829. */
  37830. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  37831. /**
  37832. * Sets a Color3 on a uniform variable.
  37833. * @param uniformName Name of the variable.
  37834. * @param color3 Value to be set.
  37835. * @returns this effect.
  37836. */
  37837. setColor3(uniformName: string, color3: IColor3Like): Effect;
  37838. /**
  37839. * Sets a Color4 on a uniform variable.
  37840. * @param uniformName Name of the variable.
  37841. * @param color3 Value to be set.
  37842. * @param alpha Alpha value to be set.
  37843. * @returns this effect.
  37844. */
  37845. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  37846. /**
  37847. * Sets a Color4 on a uniform variable
  37848. * @param uniformName defines the name of the variable
  37849. * @param color4 defines the value to be set
  37850. * @returns this effect.
  37851. */
  37852. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  37853. /** Release all associated resources */
  37854. dispose(): void;
  37855. /**
  37856. * This function will add a new shader to the shader store
  37857. * @param name the name of the shader
  37858. * @param pixelShader optional pixel shader content
  37859. * @param vertexShader optional vertex shader content
  37860. */
  37861. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  37862. /**
  37863. * Store of each shader (The can be looked up using effect.key)
  37864. */
  37865. static ShadersStore: {
  37866. [key: string]: string;
  37867. };
  37868. /**
  37869. * Store of each included file for a shader (The can be looked up using effect.key)
  37870. */
  37871. static IncludesShadersStore: {
  37872. [key: string]: string;
  37873. };
  37874. /**
  37875. * Resets the cache of effects.
  37876. */
  37877. static ResetCache(): void;
  37878. }
  37879. }
  37880. declare module BABYLON {
  37881. /**
  37882. * Interface used to describe the capabilities of the engine relatively to the current browser
  37883. */
  37884. export interface EngineCapabilities {
  37885. /** Maximum textures units per fragment shader */
  37886. maxTexturesImageUnits: number;
  37887. /** Maximum texture units per vertex shader */
  37888. maxVertexTextureImageUnits: number;
  37889. /** Maximum textures units in the entire pipeline */
  37890. maxCombinedTexturesImageUnits: number;
  37891. /** Maximum texture size */
  37892. maxTextureSize: number;
  37893. /** Maximum texture samples */
  37894. maxSamples?: number;
  37895. /** Maximum cube texture size */
  37896. maxCubemapTextureSize: number;
  37897. /** Maximum render texture size */
  37898. maxRenderTextureSize: number;
  37899. /** Maximum number of vertex attributes */
  37900. maxVertexAttribs: number;
  37901. /** Maximum number of varyings */
  37902. maxVaryingVectors: number;
  37903. /** Maximum number of uniforms per vertex shader */
  37904. maxVertexUniformVectors: number;
  37905. /** Maximum number of uniforms per fragment shader */
  37906. maxFragmentUniformVectors: number;
  37907. /** Defines if standard derivates (dx/dy) are supported */
  37908. standardDerivatives: boolean;
  37909. /** Defines if s3tc texture compression is supported */
  37910. s3tc?: WEBGL_compressed_texture_s3tc;
  37911. /** Defines if pvrtc texture compression is supported */
  37912. pvrtc: any;
  37913. /** Defines if etc1 texture compression is supported */
  37914. etc1: any;
  37915. /** Defines if etc2 texture compression is supported */
  37916. etc2: any;
  37917. /** Defines if astc texture compression is supported */
  37918. astc: any;
  37919. /** Defines if bptc texture compression is supported */
  37920. bptc: any;
  37921. /** Defines if float textures are supported */
  37922. textureFloat: boolean;
  37923. /** Defines if vertex array objects are supported */
  37924. vertexArrayObject: boolean;
  37925. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  37926. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  37927. /** Gets the maximum level of anisotropy supported */
  37928. maxAnisotropy: number;
  37929. /** Defines if instancing is supported */
  37930. instancedArrays: boolean;
  37931. /** Defines if 32 bits indices are supported */
  37932. uintIndices: boolean;
  37933. /** Defines if high precision shaders are supported */
  37934. highPrecisionShaderSupported: boolean;
  37935. /** Defines if depth reading in the fragment shader is supported */
  37936. fragmentDepthSupported: boolean;
  37937. /** Defines if float texture linear filtering is supported*/
  37938. textureFloatLinearFiltering: boolean;
  37939. /** Defines if rendering to float textures is supported */
  37940. textureFloatRender: boolean;
  37941. /** Defines if half float textures are supported*/
  37942. textureHalfFloat: boolean;
  37943. /** Defines if half float texture linear filtering is supported*/
  37944. textureHalfFloatLinearFiltering: boolean;
  37945. /** Defines if rendering to half float textures is supported */
  37946. textureHalfFloatRender: boolean;
  37947. /** Defines if textureLOD shader command is supported */
  37948. textureLOD: boolean;
  37949. /** Defines if draw buffers extension is supported */
  37950. drawBuffersExtension: boolean;
  37951. /** Defines if depth textures are supported */
  37952. depthTextureExtension: boolean;
  37953. /** Defines if float color buffer are supported */
  37954. colorBufferFloat: boolean;
  37955. /** Gets disjoint timer query extension (null if not supported) */
  37956. timerQuery?: EXT_disjoint_timer_query;
  37957. /** Defines if timestamp can be used with timer query */
  37958. canUseTimestampForTimerQuery: boolean;
  37959. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  37960. multiview?: any;
  37961. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  37962. oculusMultiview?: any;
  37963. /** Function used to let the system compiles shaders in background */
  37964. parallelShaderCompile?: {
  37965. COMPLETION_STATUS_KHR: number;
  37966. };
  37967. /** Max number of texture samples for MSAA */
  37968. maxMSAASamples: number;
  37969. /** Defines if the blend min max extension is supported */
  37970. blendMinMax: boolean;
  37971. }
  37972. }
  37973. declare module BABYLON {
  37974. /**
  37975. * @hidden
  37976. **/
  37977. export class DepthCullingState {
  37978. private _isDepthTestDirty;
  37979. private _isDepthMaskDirty;
  37980. private _isDepthFuncDirty;
  37981. private _isCullFaceDirty;
  37982. private _isCullDirty;
  37983. private _isZOffsetDirty;
  37984. private _isFrontFaceDirty;
  37985. private _depthTest;
  37986. private _depthMask;
  37987. private _depthFunc;
  37988. private _cull;
  37989. private _cullFace;
  37990. private _zOffset;
  37991. private _frontFace;
  37992. /**
  37993. * Initializes the state.
  37994. */
  37995. constructor();
  37996. get isDirty(): boolean;
  37997. get zOffset(): number;
  37998. set zOffset(value: number);
  37999. get cullFace(): Nullable<number>;
  38000. set cullFace(value: Nullable<number>);
  38001. get cull(): Nullable<boolean>;
  38002. set cull(value: Nullable<boolean>);
  38003. get depthFunc(): Nullable<number>;
  38004. set depthFunc(value: Nullable<number>);
  38005. get depthMask(): boolean;
  38006. set depthMask(value: boolean);
  38007. get depthTest(): boolean;
  38008. set depthTest(value: boolean);
  38009. get frontFace(): Nullable<number>;
  38010. set frontFace(value: Nullable<number>);
  38011. reset(): void;
  38012. apply(gl: WebGLRenderingContext): void;
  38013. }
  38014. }
  38015. declare module BABYLON {
  38016. /**
  38017. * @hidden
  38018. **/
  38019. export class StencilState {
  38020. /** 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 */
  38021. static readonly ALWAYS: number;
  38022. /** Passed to stencilOperation to specify that stencil value must be kept */
  38023. static readonly KEEP: number;
  38024. /** Passed to stencilOperation to specify that stencil value must be replaced */
  38025. static readonly REPLACE: number;
  38026. private _isStencilTestDirty;
  38027. private _isStencilMaskDirty;
  38028. private _isStencilFuncDirty;
  38029. private _isStencilOpDirty;
  38030. private _stencilTest;
  38031. private _stencilMask;
  38032. private _stencilFunc;
  38033. private _stencilFuncRef;
  38034. private _stencilFuncMask;
  38035. private _stencilOpStencilFail;
  38036. private _stencilOpDepthFail;
  38037. private _stencilOpStencilDepthPass;
  38038. get isDirty(): boolean;
  38039. get stencilFunc(): number;
  38040. set stencilFunc(value: number);
  38041. get stencilFuncRef(): number;
  38042. set stencilFuncRef(value: number);
  38043. get stencilFuncMask(): number;
  38044. set stencilFuncMask(value: number);
  38045. get stencilOpStencilFail(): number;
  38046. set stencilOpStencilFail(value: number);
  38047. get stencilOpDepthFail(): number;
  38048. set stencilOpDepthFail(value: number);
  38049. get stencilOpStencilDepthPass(): number;
  38050. set stencilOpStencilDepthPass(value: number);
  38051. get stencilMask(): number;
  38052. set stencilMask(value: number);
  38053. get stencilTest(): boolean;
  38054. set stencilTest(value: boolean);
  38055. constructor();
  38056. reset(): void;
  38057. apply(gl: WebGLRenderingContext): void;
  38058. }
  38059. }
  38060. declare module BABYLON {
  38061. /**
  38062. * @hidden
  38063. **/
  38064. export class AlphaState {
  38065. private _isAlphaBlendDirty;
  38066. private _isBlendFunctionParametersDirty;
  38067. private _isBlendEquationParametersDirty;
  38068. private _isBlendConstantsDirty;
  38069. private _alphaBlend;
  38070. private _blendFunctionParameters;
  38071. private _blendEquationParameters;
  38072. private _blendConstants;
  38073. /**
  38074. * Initializes the state.
  38075. */
  38076. constructor();
  38077. get isDirty(): boolean;
  38078. get alphaBlend(): boolean;
  38079. set alphaBlend(value: boolean);
  38080. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  38081. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  38082. setAlphaEquationParameters(rgb: number, alpha: number): void;
  38083. reset(): void;
  38084. apply(gl: WebGLRenderingContext): void;
  38085. }
  38086. }
  38087. declare module BABYLON {
  38088. /** @hidden */
  38089. export class WebGL2ShaderProcessor implements IShaderProcessor {
  38090. attributeProcessor(attribute: string): string;
  38091. varyingProcessor(varying: string, isFragment: boolean): string;
  38092. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  38093. }
  38094. }
  38095. declare module BABYLON {
  38096. /**
  38097. * Interface for attribute information associated with buffer instanciation
  38098. */
  38099. export interface InstancingAttributeInfo {
  38100. /**
  38101. * Name of the GLSL attribute
  38102. * if attribute index is not specified, this is used to retrieve the index from the effect
  38103. */
  38104. attributeName: string;
  38105. /**
  38106. * Index/offset of the attribute in the vertex shader
  38107. * if not specified, this will be computes from the name.
  38108. */
  38109. index?: number;
  38110. /**
  38111. * size of the attribute, 1, 2, 3 or 4
  38112. */
  38113. attributeSize: number;
  38114. /**
  38115. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  38116. */
  38117. offset: number;
  38118. /**
  38119. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  38120. * default to 1
  38121. */
  38122. divisor?: number;
  38123. /**
  38124. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  38125. * default is FLOAT
  38126. */
  38127. attributeType?: number;
  38128. /**
  38129. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  38130. */
  38131. normalized?: boolean;
  38132. }
  38133. }
  38134. declare module BABYLON {
  38135. interface ThinEngine {
  38136. /**
  38137. * Update a video texture
  38138. * @param texture defines the texture to update
  38139. * @param video defines the video element to use
  38140. * @param invertY defines if data must be stored with Y axis inverted
  38141. */
  38142. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  38143. }
  38144. }
  38145. declare module BABYLON {
  38146. interface ThinEngine {
  38147. /**
  38148. * Creates a dynamic texture
  38149. * @param width defines the width of the texture
  38150. * @param height defines the height of the texture
  38151. * @param generateMipMaps defines if the engine should generate the mip levels
  38152. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  38153. * @returns the dynamic texture inside an InternalTexture
  38154. */
  38155. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  38156. /**
  38157. * Update the content of a dynamic texture
  38158. * @param texture defines the texture to update
  38159. * @param canvas defines the canvas containing the source
  38160. * @param invertY defines if data must be stored with Y axis inverted
  38161. * @param premulAlpha defines if alpha is stored as premultiplied
  38162. * @param format defines the format of the data
  38163. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  38164. */
  38165. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  38166. }
  38167. }
  38168. declare module BABYLON {
  38169. /**
  38170. * Settings for finer control over video usage
  38171. */
  38172. export interface VideoTextureSettings {
  38173. /**
  38174. * Applies `autoplay` to video, if specified
  38175. */
  38176. autoPlay?: boolean;
  38177. /**
  38178. * Applies `muted` to video, if specified
  38179. */
  38180. muted?: boolean;
  38181. /**
  38182. * Applies `loop` to video, if specified
  38183. */
  38184. loop?: boolean;
  38185. /**
  38186. * Automatically updates internal texture from video at every frame in the render loop
  38187. */
  38188. autoUpdateTexture: boolean;
  38189. /**
  38190. * Image src displayed during the video loading or until the user interacts with the video.
  38191. */
  38192. poster?: string;
  38193. }
  38194. /**
  38195. * If you want to display a video in your scene, this is the special texture for that.
  38196. * This special texture works similar to other textures, with the exception of a few parameters.
  38197. * @see https://doc.babylonjs.com/how_to/video_texture
  38198. */
  38199. export class VideoTexture extends Texture {
  38200. /**
  38201. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  38202. */
  38203. readonly autoUpdateTexture: boolean;
  38204. /**
  38205. * The video instance used by the texture internally
  38206. */
  38207. readonly video: HTMLVideoElement;
  38208. private _onUserActionRequestedObservable;
  38209. /**
  38210. * Event triggerd when a dom action is required by the user to play the video.
  38211. * This happens due to recent changes in browser policies preventing video to auto start.
  38212. */
  38213. get onUserActionRequestedObservable(): Observable<Texture>;
  38214. private _generateMipMaps;
  38215. private _stillImageCaptured;
  38216. private _displayingPosterTexture;
  38217. private _settings;
  38218. private _createInternalTextureOnEvent;
  38219. private _frameId;
  38220. private _currentSrc;
  38221. /**
  38222. * Creates a video texture.
  38223. * If you want to display a video in your scene, this is the special texture for that.
  38224. * This special texture works similar to other textures, with the exception of a few parameters.
  38225. * @see https://doc.babylonjs.com/how_to/video_texture
  38226. * @param name optional name, will detect from video source, if not defined
  38227. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  38228. * @param scene is obviously the current scene.
  38229. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  38230. * @param invertY is false by default but can be used to invert video on Y axis
  38231. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  38232. * @param settings allows finer control over video usage
  38233. */
  38234. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  38235. private _getName;
  38236. private _getVideo;
  38237. private _createInternalTexture;
  38238. private reset;
  38239. /**
  38240. * @hidden Internal method to initiate `update`.
  38241. */
  38242. _rebuild(): void;
  38243. /**
  38244. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  38245. */
  38246. update(): void;
  38247. /**
  38248. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  38249. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  38250. */
  38251. updateTexture(isVisible: boolean): void;
  38252. protected _updateInternalTexture: () => void;
  38253. /**
  38254. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  38255. * @param url New url.
  38256. */
  38257. updateURL(url: string): void;
  38258. /**
  38259. * Clones the texture.
  38260. * @returns the cloned texture
  38261. */
  38262. clone(): VideoTexture;
  38263. /**
  38264. * Dispose the texture and release its associated resources.
  38265. */
  38266. dispose(): void;
  38267. /**
  38268. * Creates a video texture straight from a stream.
  38269. * @param scene Define the scene the texture should be created in
  38270. * @param stream Define the stream the texture should be created from
  38271. * @returns The created video texture as a promise
  38272. */
  38273. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  38274. /**
  38275. * Creates a video texture straight from your WebCam video feed.
  38276. * @param scene Define the scene the texture should be created in
  38277. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  38278. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  38279. * @returns The created video texture as a promise
  38280. */
  38281. static CreateFromWebCamAsync(scene: Scene, constraints: {
  38282. minWidth: number;
  38283. maxWidth: number;
  38284. minHeight: number;
  38285. maxHeight: number;
  38286. deviceId: string;
  38287. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  38288. /**
  38289. * Creates a video texture straight from your WebCam video feed.
  38290. * @param scene Define the scene the texture should be created in
  38291. * @param onReady Define a callback to triggered once the texture will be ready
  38292. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  38293. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  38294. */
  38295. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  38296. minWidth: number;
  38297. maxWidth: number;
  38298. minHeight: number;
  38299. maxHeight: number;
  38300. deviceId: string;
  38301. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  38302. }
  38303. }
  38304. declare module BABYLON {
  38305. /**
  38306. * Defines the interface used by objects working like Scene
  38307. * @hidden
  38308. */
  38309. export interface ISceneLike {
  38310. _addPendingData(data: any): void;
  38311. _removePendingData(data: any): void;
  38312. offlineProvider: IOfflineProvider;
  38313. }
  38314. /**
  38315. * Information about the current host
  38316. */
  38317. export interface HostInformation {
  38318. /**
  38319. * Defines if the current host is a mobile
  38320. */
  38321. isMobile: boolean;
  38322. }
  38323. /** Interface defining initialization parameters for Engine class */
  38324. export interface EngineOptions extends WebGLContextAttributes {
  38325. /**
  38326. * Defines if the engine should no exceed a specified device ratio
  38327. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  38328. */
  38329. limitDeviceRatio?: number;
  38330. /**
  38331. * Defines if webvr should be enabled automatically
  38332. * @see https://doc.babylonjs.com/how_to/webvr_camera
  38333. */
  38334. autoEnableWebVR?: boolean;
  38335. /**
  38336. * Defines if webgl2 should be turned off even if supported
  38337. * @see https://doc.babylonjs.com/features/webgl2
  38338. */
  38339. disableWebGL2Support?: boolean;
  38340. /**
  38341. * Defines if webaudio should be initialized as well
  38342. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  38343. */
  38344. audioEngine?: boolean;
  38345. /**
  38346. * Defines if animations should run using a deterministic lock step
  38347. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  38348. */
  38349. deterministicLockstep?: boolean;
  38350. /** Defines the maximum steps to use with deterministic lock step mode */
  38351. lockstepMaxSteps?: number;
  38352. /** Defines the seconds between each deterministic lock step */
  38353. timeStep?: number;
  38354. /**
  38355. * Defines that engine should ignore context lost events
  38356. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  38357. */
  38358. doNotHandleContextLost?: boolean;
  38359. /**
  38360. * Defines that engine should ignore modifying touch action attribute and style
  38361. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  38362. */
  38363. doNotHandleTouchAction?: boolean;
  38364. /**
  38365. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  38366. */
  38367. useHighPrecisionFloats?: boolean;
  38368. /**
  38369. * Make the canvas XR Compatible for XR sessions
  38370. */
  38371. xrCompatible?: boolean;
  38372. /**
  38373. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  38374. */
  38375. useHighPrecisionMatrix?: boolean;
  38376. /**
  38377. * Will prevent the system from falling back to software implementation if a hardware device cannot be created
  38378. */
  38379. failIfMajorPerformanceCaveat?: boolean;
  38380. }
  38381. /**
  38382. * The base engine class (root of all engines)
  38383. */
  38384. export class ThinEngine {
  38385. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  38386. static ExceptionList: ({
  38387. key: string;
  38388. capture: string;
  38389. captureConstraint: number;
  38390. targets: string[];
  38391. } | {
  38392. key: string;
  38393. capture: null;
  38394. captureConstraint: null;
  38395. targets: string[];
  38396. })[];
  38397. /** @hidden */
  38398. static _TextureLoaders: IInternalTextureLoader[];
  38399. /**
  38400. * Returns the current npm package of the sdk
  38401. */
  38402. static get NpmPackage(): string;
  38403. /**
  38404. * Returns the current version of the framework
  38405. */
  38406. static get Version(): string;
  38407. /**
  38408. * Returns a string describing the current engine
  38409. */
  38410. get description(): string;
  38411. /**
  38412. * Gets or sets the epsilon value used by collision engine
  38413. */
  38414. static CollisionsEpsilon: number;
  38415. /**
  38416. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  38417. */
  38418. static get ShadersRepository(): string;
  38419. static set ShadersRepository(value: string);
  38420. /** @hidden */
  38421. _shaderProcessor: IShaderProcessor;
  38422. /**
  38423. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  38424. */
  38425. forcePOTTextures: boolean;
  38426. /**
  38427. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  38428. */
  38429. isFullscreen: boolean;
  38430. /**
  38431. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  38432. */
  38433. cullBackFaces: boolean;
  38434. /**
  38435. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  38436. */
  38437. renderEvenInBackground: boolean;
  38438. /**
  38439. * Gets or sets a boolean indicating that cache can be kept between frames
  38440. */
  38441. preventCacheWipeBetweenFrames: boolean;
  38442. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  38443. validateShaderPrograms: boolean;
  38444. /**
  38445. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  38446. * This can provide greater z depth for distant objects.
  38447. */
  38448. useReverseDepthBuffer: boolean;
  38449. /**
  38450. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  38451. */
  38452. disableUniformBuffers: boolean;
  38453. /** @hidden */
  38454. _uniformBuffers: UniformBuffer[];
  38455. /**
  38456. * Gets a boolean indicating that the engine supports uniform buffers
  38457. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  38458. */
  38459. get supportsUniformBuffers(): boolean;
  38460. /** @hidden */
  38461. _gl: WebGLRenderingContext;
  38462. /** @hidden */
  38463. _webGLVersion: number;
  38464. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  38465. protected _windowIsBackground: boolean;
  38466. protected _creationOptions: EngineOptions;
  38467. protected _highPrecisionShadersAllowed: boolean;
  38468. /** @hidden */
  38469. get _shouldUseHighPrecisionShader(): boolean;
  38470. /**
  38471. * Gets a boolean indicating that only power of 2 textures are supported
  38472. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  38473. */
  38474. get needPOTTextures(): boolean;
  38475. /** @hidden */
  38476. _badOS: boolean;
  38477. /** @hidden */
  38478. _badDesktopOS: boolean;
  38479. private _hardwareScalingLevel;
  38480. /** @hidden */
  38481. _caps: EngineCapabilities;
  38482. private _isStencilEnable;
  38483. private _glVersion;
  38484. private _glRenderer;
  38485. private _glVendor;
  38486. /** @hidden */
  38487. _videoTextureSupported: boolean;
  38488. protected _renderingQueueLaunched: boolean;
  38489. protected _activeRenderLoops: (() => void)[];
  38490. /**
  38491. * Observable signaled when a context lost event is raised
  38492. */
  38493. onContextLostObservable: Observable<ThinEngine>;
  38494. /**
  38495. * Observable signaled when a context restored event is raised
  38496. */
  38497. onContextRestoredObservable: Observable<ThinEngine>;
  38498. private _onContextLost;
  38499. private _onContextRestored;
  38500. protected _contextWasLost: boolean;
  38501. /** @hidden */
  38502. _doNotHandleContextLost: boolean;
  38503. /**
  38504. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  38505. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  38506. */
  38507. get doNotHandleContextLost(): boolean;
  38508. set doNotHandleContextLost(value: boolean);
  38509. /**
  38510. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  38511. */
  38512. disableVertexArrayObjects: boolean;
  38513. /** @hidden */
  38514. protected _colorWrite: boolean;
  38515. /** @hidden */
  38516. protected _colorWriteChanged: boolean;
  38517. /** @hidden */
  38518. protected _depthCullingState: DepthCullingState;
  38519. /** @hidden */
  38520. protected _stencilState: StencilState;
  38521. /** @hidden */
  38522. _alphaState: AlphaState;
  38523. /** @hidden */
  38524. _alphaMode: number;
  38525. /** @hidden */
  38526. _alphaEquation: number;
  38527. /** @hidden */
  38528. _internalTexturesCache: InternalTexture[];
  38529. /** @hidden */
  38530. protected _activeChannel: number;
  38531. private _currentTextureChannel;
  38532. /** @hidden */
  38533. protected _boundTexturesCache: {
  38534. [key: string]: Nullable<InternalTexture>;
  38535. };
  38536. /** @hidden */
  38537. protected _currentEffect: Nullable<Effect>;
  38538. /** @hidden */
  38539. protected _currentProgram: Nullable<WebGLProgram>;
  38540. private _compiledEffects;
  38541. private _vertexAttribArraysEnabled;
  38542. /** @hidden */
  38543. protected _cachedViewport: Nullable<IViewportLike>;
  38544. private _cachedVertexArrayObject;
  38545. /** @hidden */
  38546. protected _cachedVertexBuffers: any;
  38547. /** @hidden */
  38548. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  38549. /** @hidden */
  38550. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  38551. /** @hidden */
  38552. _currentRenderTarget: Nullable<InternalTexture>;
  38553. private _uintIndicesCurrentlySet;
  38554. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  38555. /** @hidden */
  38556. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  38557. /** @hidden */
  38558. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  38559. private _currentBufferPointers;
  38560. private _currentInstanceLocations;
  38561. private _currentInstanceBuffers;
  38562. private _textureUnits;
  38563. /** @hidden */
  38564. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  38565. /** @hidden */
  38566. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  38567. /** @hidden */
  38568. _boundRenderFunction: any;
  38569. private _vaoRecordInProgress;
  38570. private _mustWipeVertexAttributes;
  38571. private _emptyTexture;
  38572. private _emptyCubeTexture;
  38573. private _emptyTexture3D;
  38574. private _emptyTexture2DArray;
  38575. /** @hidden */
  38576. _frameHandler: number;
  38577. private _nextFreeTextureSlots;
  38578. private _maxSimultaneousTextures;
  38579. private _activeRequests;
  38580. /** @hidden */
  38581. _transformTextureUrl: Nullable<(url: string) => string>;
  38582. /**
  38583. * Gets information about the current host
  38584. */
  38585. hostInformation: HostInformation;
  38586. protected get _supportsHardwareTextureRescaling(): boolean;
  38587. private _framebufferDimensionsObject;
  38588. /**
  38589. * sets the object from which width and height will be taken from when getting render width and height
  38590. * Will fallback to the gl object
  38591. * @param dimensions the framebuffer width and height that will be used.
  38592. */
  38593. set framebufferDimensionsObject(dimensions: Nullable<{
  38594. framebufferWidth: number;
  38595. framebufferHeight: number;
  38596. }>);
  38597. /**
  38598. * Gets the current viewport
  38599. */
  38600. get currentViewport(): Nullable<IViewportLike>;
  38601. /**
  38602. * Gets the default empty texture
  38603. */
  38604. get emptyTexture(): InternalTexture;
  38605. /**
  38606. * Gets the default empty 3D texture
  38607. */
  38608. get emptyTexture3D(): InternalTexture;
  38609. /**
  38610. * Gets the default empty 2D array texture
  38611. */
  38612. get emptyTexture2DArray(): InternalTexture;
  38613. /**
  38614. * Gets the default empty cube texture
  38615. */
  38616. get emptyCubeTexture(): InternalTexture;
  38617. /**
  38618. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  38619. */
  38620. readonly premultipliedAlpha: boolean;
  38621. /**
  38622. * Observable event triggered before each texture is initialized
  38623. */
  38624. onBeforeTextureInitObservable: Observable<Texture>;
  38625. /**
  38626. * Creates a new engine
  38627. * @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
  38628. * @param antialias defines enable antialiasing (default: false)
  38629. * @param options defines further options to be sent to the getContext() function
  38630. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  38631. */
  38632. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  38633. private _rebuildInternalTextures;
  38634. private _rebuildEffects;
  38635. /**
  38636. * Gets a boolean indicating if all created effects are ready
  38637. * @returns true if all effects are ready
  38638. */
  38639. areAllEffectsReady(): boolean;
  38640. protected _rebuildBuffers(): void;
  38641. protected _initGLContext(): void;
  38642. /**
  38643. * Gets version of the current webGL context
  38644. */
  38645. get webGLVersion(): number;
  38646. /**
  38647. * Gets a string identifying the name of the class
  38648. * @returns "Engine" string
  38649. */
  38650. getClassName(): string;
  38651. /**
  38652. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  38653. */
  38654. get isStencilEnable(): boolean;
  38655. /** @hidden */
  38656. _prepareWorkingCanvas(): void;
  38657. /**
  38658. * Reset the texture cache to empty state
  38659. */
  38660. resetTextureCache(): void;
  38661. /**
  38662. * Gets an object containing information about the current webGL context
  38663. * @returns an object containing the vender, the renderer and the version of the current webGL context
  38664. */
  38665. getGlInfo(): {
  38666. vendor: string;
  38667. renderer: string;
  38668. version: string;
  38669. };
  38670. /**
  38671. * Defines the hardware scaling level.
  38672. * By default the hardware scaling level is computed from the window device ratio.
  38673. * 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.
  38674. * @param level defines the level to use
  38675. */
  38676. setHardwareScalingLevel(level: number): void;
  38677. /**
  38678. * Gets the current hardware scaling level.
  38679. * By default the hardware scaling level is computed from the window device ratio.
  38680. * 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.
  38681. * @returns a number indicating the current hardware scaling level
  38682. */
  38683. getHardwareScalingLevel(): number;
  38684. /**
  38685. * Gets the list of loaded textures
  38686. * @returns an array containing all loaded textures
  38687. */
  38688. getLoadedTexturesCache(): InternalTexture[];
  38689. /**
  38690. * Gets the object containing all engine capabilities
  38691. * @returns the EngineCapabilities object
  38692. */
  38693. getCaps(): EngineCapabilities;
  38694. /**
  38695. * stop executing a render loop function and remove it from the execution array
  38696. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  38697. */
  38698. stopRenderLoop(renderFunction?: () => void): void;
  38699. /** @hidden */
  38700. _renderLoop(): void;
  38701. /**
  38702. * Gets the HTML canvas attached with the current webGL context
  38703. * @returns a HTML canvas
  38704. */
  38705. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  38706. /**
  38707. * Gets host window
  38708. * @returns the host window object
  38709. */
  38710. getHostWindow(): Nullable<Window>;
  38711. /**
  38712. * Gets the current render width
  38713. * @param useScreen defines if screen size must be used (or the current render target if any)
  38714. * @returns a number defining the current render width
  38715. */
  38716. getRenderWidth(useScreen?: boolean): number;
  38717. /**
  38718. * Gets the current render height
  38719. * @param useScreen defines if screen size must be used (or the current render target if any)
  38720. * @returns a number defining the current render height
  38721. */
  38722. getRenderHeight(useScreen?: boolean): number;
  38723. /**
  38724. * Can be used to override the current requestAnimationFrame requester.
  38725. * @hidden
  38726. */
  38727. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  38728. /**
  38729. * Register and execute a render loop. The engine can have more than one render function
  38730. * @param renderFunction defines the function to continuously execute
  38731. */
  38732. runRenderLoop(renderFunction: () => void): void;
  38733. /**
  38734. * Clear the current render buffer or the current render target (if any is set up)
  38735. * @param color defines the color to use
  38736. * @param backBuffer defines if the back buffer must be cleared
  38737. * @param depth defines if the depth buffer must be cleared
  38738. * @param stencil defines if the stencil buffer must be cleared
  38739. */
  38740. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  38741. private _viewportCached;
  38742. /** @hidden */
  38743. _viewport(x: number, y: number, width: number, height: number): void;
  38744. /**
  38745. * Set the WebGL's viewport
  38746. * @param viewport defines the viewport element to be used
  38747. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  38748. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  38749. */
  38750. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  38751. /**
  38752. * Begin a new frame
  38753. */
  38754. beginFrame(): void;
  38755. /**
  38756. * Enf the current frame
  38757. */
  38758. endFrame(): void;
  38759. /**
  38760. * Resize the view according to the canvas' size
  38761. */
  38762. resize(): void;
  38763. /**
  38764. * Force a specific size of the canvas
  38765. * @param width defines the new canvas' width
  38766. * @param height defines the new canvas' height
  38767. * @returns true if the size was changed
  38768. */
  38769. setSize(width: number, height: number): boolean;
  38770. /**
  38771. * Binds the frame buffer to the specified texture.
  38772. * @param texture The texture to render to or null for the default canvas
  38773. * @param faceIndex The face of the texture to render to in case of cube texture
  38774. * @param requiredWidth The width of the target to render to
  38775. * @param requiredHeight The height of the target to render to
  38776. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  38777. * @param lodLevel defines the lod level to bind to the frame buffer
  38778. * @param layer defines the 2d array index to bind to frame buffer to
  38779. */
  38780. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  38781. /** @hidden */
  38782. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  38783. /**
  38784. * Unbind the current render target texture from the webGL context
  38785. * @param texture defines the render target texture to unbind
  38786. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  38787. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  38788. */
  38789. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  38790. /**
  38791. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  38792. */
  38793. flushFramebuffer(): void;
  38794. /**
  38795. * Unbind the current render target and bind the default framebuffer
  38796. */
  38797. restoreDefaultFramebuffer(): void;
  38798. /** @hidden */
  38799. protected _resetVertexBufferBinding(): void;
  38800. /**
  38801. * Creates a vertex buffer
  38802. * @param data the data for the vertex buffer
  38803. * @returns the new WebGL static buffer
  38804. */
  38805. createVertexBuffer(data: DataArray): DataBuffer;
  38806. private _createVertexBuffer;
  38807. /**
  38808. * Creates a dynamic vertex buffer
  38809. * @param data the data for the dynamic vertex buffer
  38810. * @returns the new WebGL dynamic buffer
  38811. */
  38812. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  38813. protected _resetIndexBufferBinding(): void;
  38814. /**
  38815. * Creates a new index buffer
  38816. * @param indices defines the content of the index buffer
  38817. * @param updatable defines if the index buffer must be updatable
  38818. * @returns a new webGL buffer
  38819. */
  38820. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  38821. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  38822. /**
  38823. * Bind a webGL buffer to the webGL context
  38824. * @param buffer defines the buffer to bind
  38825. */
  38826. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  38827. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  38828. private bindBuffer;
  38829. /**
  38830. * update the bound buffer with the given data
  38831. * @param data defines the data to update
  38832. */
  38833. updateArrayBuffer(data: Float32Array): void;
  38834. private _vertexAttribPointer;
  38835. /** @hidden */
  38836. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  38837. private _bindVertexBuffersAttributes;
  38838. /**
  38839. * Records a vertex array object
  38840. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  38841. * @param vertexBuffers defines the list of vertex buffers to store
  38842. * @param indexBuffer defines the index buffer to store
  38843. * @param effect defines the effect to store
  38844. * @returns the new vertex array object
  38845. */
  38846. recordVertexArrayObject(vertexBuffers: {
  38847. [key: string]: VertexBuffer;
  38848. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  38849. /**
  38850. * Bind a specific vertex array object
  38851. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  38852. * @param vertexArrayObject defines the vertex array object to bind
  38853. * @param indexBuffer defines the index buffer to bind
  38854. */
  38855. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  38856. /**
  38857. * Bind webGl buffers directly to the webGL context
  38858. * @param vertexBuffer defines the vertex buffer to bind
  38859. * @param indexBuffer defines the index buffer to bind
  38860. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  38861. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  38862. * @param effect defines the effect associated with the vertex buffer
  38863. */
  38864. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  38865. private _unbindVertexArrayObject;
  38866. /**
  38867. * Bind a list of vertex buffers to the webGL context
  38868. * @param vertexBuffers defines the list of vertex buffers to bind
  38869. * @param indexBuffer defines the index buffer to bind
  38870. * @param effect defines the effect associated with the vertex buffers
  38871. */
  38872. bindBuffers(vertexBuffers: {
  38873. [key: string]: Nullable<VertexBuffer>;
  38874. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  38875. /**
  38876. * Unbind all instance attributes
  38877. */
  38878. unbindInstanceAttributes(): void;
  38879. /**
  38880. * Release and free the memory of a vertex array object
  38881. * @param vao defines the vertex array object to delete
  38882. */
  38883. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  38884. /** @hidden */
  38885. _releaseBuffer(buffer: DataBuffer): boolean;
  38886. protected _deleteBuffer(buffer: DataBuffer): void;
  38887. /**
  38888. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  38889. * @param instancesBuffer defines the webGL buffer to update and bind
  38890. * @param data defines the data to store in the buffer
  38891. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  38892. */
  38893. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  38894. /**
  38895. * Bind the content of a webGL buffer used with instantiation
  38896. * @param instancesBuffer defines the webGL buffer to bind
  38897. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  38898. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  38899. */
  38900. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  38901. /**
  38902. * Disable the instance attribute corresponding to the name in parameter
  38903. * @param name defines the name of the attribute to disable
  38904. */
  38905. disableInstanceAttributeByName(name: string): void;
  38906. /**
  38907. * Disable the instance attribute corresponding to the location in parameter
  38908. * @param attributeLocation defines the attribute location of the attribute to disable
  38909. */
  38910. disableInstanceAttribute(attributeLocation: number): void;
  38911. /**
  38912. * Disable the attribute corresponding to the location in parameter
  38913. * @param attributeLocation defines the attribute location of the attribute to disable
  38914. */
  38915. disableAttributeByIndex(attributeLocation: number): void;
  38916. /**
  38917. * Send a draw order
  38918. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  38919. * @param indexStart defines the starting index
  38920. * @param indexCount defines the number of index to draw
  38921. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  38922. */
  38923. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  38924. /**
  38925. * Draw a list of points
  38926. * @param verticesStart defines the index of first vertex to draw
  38927. * @param verticesCount defines the count of vertices to draw
  38928. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  38929. */
  38930. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  38931. /**
  38932. * Draw a list of unindexed primitives
  38933. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  38934. * @param verticesStart defines the index of first vertex to draw
  38935. * @param verticesCount defines the count of vertices to draw
  38936. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  38937. */
  38938. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  38939. /**
  38940. * Draw a list of indexed primitives
  38941. * @param fillMode defines the primitive to use
  38942. * @param indexStart defines the starting index
  38943. * @param indexCount defines the number of index to draw
  38944. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  38945. */
  38946. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  38947. /**
  38948. * Draw a list of unindexed primitives
  38949. * @param fillMode defines the primitive to use
  38950. * @param verticesStart defines the index of first vertex to draw
  38951. * @param verticesCount defines the count of vertices to draw
  38952. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  38953. */
  38954. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  38955. private _drawMode;
  38956. /** @hidden */
  38957. protected _reportDrawCall(): void;
  38958. /** @hidden */
  38959. _releaseEffect(effect: Effect): void;
  38960. /** @hidden */
  38961. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  38962. /**
  38963. * Create a new effect (used to store vertex/fragment shaders)
  38964. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  38965. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  38966. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  38967. * @param samplers defines an array of string used to represent textures
  38968. * @param defines defines the string containing the defines to use to compile the shaders
  38969. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  38970. * @param onCompiled defines a function to call when the effect creation is successful
  38971. * @param onError defines a function to call when the effect creation has failed
  38972. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  38973. * @returns the new Effect
  38974. */
  38975. 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;
  38976. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  38977. private _compileShader;
  38978. private _compileRawShader;
  38979. /** @hidden */
  38980. _getShaderSource(shader: WebGLShader): Nullable<string>;
  38981. /**
  38982. * Directly creates a webGL program
  38983. * @param pipelineContext defines the pipeline context to attach to
  38984. * @param vertexCode defines the vertex shader code to use
  38985. * @param fragmentCode defines the fragment shader code to use
  38986. * @param context defines the webGL context to use (if not set, the current one will be used)
  38987. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  38988. * @returns the new webGL program
  38989. */
  38990. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  38991. /**
  38992. * Creates a webGL program
  38993. * @param pipelineContext defines the pipeline context to attach to
  38994. * @param vertexCode defines the vertex shader code to use
  38995. * @param fragmentCode defines the fragment shader code to use
  38996. * @param defines defines the string containing the defines to use to compile the shaders
  38997. * @param context defines the webGL context to use (if not set, the current one will be used)
  38998. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  38999. * @returns the new webGL program
  39000. */
  39001. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39002. /**
  39003. * Creates a new pipeline context
  39004. * @returns the new pipeline
  39005. */
  39006. createPipelineContext(): IPipelineContext;
  39007. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39008. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  39009. /** @hidden */
  39010. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  39011. /** @hidden */
  39012. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  39013. /** @hidden */
  39014. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  39015. /**
  39016. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  39017. * @param pipelineContext defines the pipeline context to use
  39018. * @param uniformsNames defines the list of uniform names
  39019. * @returns an array of webGL uniform locations
  39020. */
  39021. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  39022. /**
  39023. * Gets the lsit of active attributes for a given webGL program
  39024. * @param pipelineContext defines the pipeline context to use
  39025. * @param attributesNames defines the list of attribute names to get
  39026. * @returns an array of indices indicating the offset of each attribute
  39027. */
  39028. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  39029. /**
  39030. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  39031. * @param effect defines the effect to activate
  39032. */
  39033. enableEffect(effect: Nullable<Effect>): void;
  39034. /**
  39035. * Set the value of an uniform to a number (int)
  39036. * @param uniform defines the webGL uniform location where to store the value
  39037. * @param value defines the int number to store
  39038. * @returns true if the value was set
  39039. */
  39040. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  39041. /**
  39042. * Set the value of an uniform to an array of int32
  39043. * @param uniform defines the webGL uniform location where to store the value
  39044. * @param array defines the array of int32 to store
  39045. * @returns true if the value was set
  39046. */
  39047. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  39048. /**
  39049. * Set the value of an uniform to an array of int32 (stored as vec2)
  39050. * @param uniform defines the webGL uniform location where to store the value
  39051. * @param array defines the array of int32 to store
  39052. * @returns true if the value was set
  39053. */
  39054. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  39055. /**
  39056. * Set the value of an uniform to an array of int32 (stored as vec3)
  39057. * @param uniform defines the webGL uniform location where to store the value
  39058. * @param array defines the array of int32 to store
  39059. * @returns true if the value was set
  39060. */
  39061. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  39062. /**
  39063. * Set the value of an uniform to an array of int32 (stored as vec4)
  39064. * @param uniform defines the webGL uniform location where to store the value
  39065. * @param array defines the array of int32 to store
  39066. * @returns true if the value was set
  39067. */
  39068. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  39069. /**
  39070. * Set the value of an uniform to an array of number
  39071. * @param uniform defines the webGL uniform location where to store the value
  39072. * @param array defines the array of number to store
  39073. * @returns true if the value was set
  39074. */
  39075. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  39076. /**
  39077. * Set the value of an uniform to an array of number (stored as vec2)
  39078. * @param uniform defines the webGL uniform location where to store the value
  39079. * @param array defines the array of number to store
  39080. * @returns true if the value was set
  39081. */
  39082. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  39083. /**
  39084. * Set the value of an uniform to an array of number (stored as vec3)
  39085. * @param uniform defines the webGL uniform location where to store the value
  39086. * @param array defines the array of number to store
  39087. * @returns true if the value was set
  39088. */
  39089. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  39090. /**
  39091. * Set the value of an uniform to an array of number (stored as vec4)
  39092. * @param uniform defines the webGL uniform location where to store the value
  39093. * @param array defines the array of number to store
  39094. * @returns true if the value was set
  39095. */
  39096. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  39097. /**
  39098. * Set the value of an uniform to an array of float32 (stored as matrices)
  39099. * @param uniform defines the webGL uniform location where to store the value
  39100. * @param matrices defines the array of float32 to store
  39101. * @returns true if the value was set
  39102. */
  39103. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  39104. /**
  39105. * Set the value of an uniform to a matrix (3x3)
  39106. * @param uniform defines the webGL uniform location where to store the value
  39107. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  39108. * @returns true if the value was set
  39109. */
  39110. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  39111. /**
  39112. * Set the value of an uniform to a matrix (2x2)
  39113. * @param uniform defines the webGL uniform location where to store the value
  39114. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  39115. * @returns true if the value was set
  39116. */
  39117. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  39118. /**
  39119. * Set the value of an uniform to a number (float)
  39120. * @param uniform defines the webGL uniform location where to store the value
  39121. * @param value defines the float number to store
  39122. * @returns true if the value was transfered
  39123. */
  39124. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  39125. /**
  39126. * Set the value of an uniform to a vec2
  39127. * @param uniform defines the webGL uniform location where to store the value
  39128. * @param x defines the 1st component of the value
  39129. * @param y defines the 2nd component of the value
  39130. * @returns true if the value was set
  39131. */
  39132. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  39133. /**
  39134. * Set the value of an uniform to a vec3
  39135. * @param uniform defines the webGL uniform location where to store the value
  39136. * @param x defines the 1st component of the value
  39137. * @param y defines the 2nd component of the value
  39138. * @param z defines the 3rd component of the value
  39139. * @returns true if the value was set
  39140. */
  39141. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  39142. /**
  39143. * Set the value of an uniform to a vec4
  39144. * @param uniform defines the webGL uniform location where to store the value
  39145. * @param x defines the 1st component of the value
  39146. * @param y defines the 2nd component of the value
  39147. * @param z defines the 3rd component of the value
  39148. * @param w defines the 4th component of the value
  39149. * @returns true if the value was set
  39150. */
  39151. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  39152. /**
  39153. * Apply all cached states (depth, culling, stencil and alpha)
  39154. */
  39155. applyStates(): void;
  39156. /**
  39157. * Enable or disable color writing
  39158. * @param enable defines the state to set
  39159. */
  39160. setColorWrite(enable: boolean): void;
  39161. /**
  39162. * Gets a boolean indicating if color writing is enabled
  39163. * @returns the current color writing state
  39164. */
  39165. getColorWrite(): boolean;
  39166. /**
  39167. * Gets the depth culling state manager
  39168. */
  39169. get depthCullingState(): DepthCullingState;
  39170. /**
  39171. * Gets the alpha state manager
  39172. */
  39173. get alphaState(): AlphaState;
  39174. /**
  39175. * Gets the stencil state manager
  39176. */
  39177. get stencilState(): StencilState;
  39178. /**
  39179. * Clears the list of texture accessible through engine.
  39180. * This can help preventing texture load conflict due to name collision.
  39181. */
  39182. clearInternalTexturesCache(): void;
  39183. /**
  39184. * Force the entire cache to be cleared
  39185. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  39186. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  39187. */
  39188. wipeCaches(bruteForce?: boolean): void;
  39189. /** @hidden */
  39190. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  39191. min: number;
  39192. mag: number;
  39193. };
  39194. /** @hidden */
  39195. _createTexture(): WebGLTexture;
  39196. /**
  39197. * Usually called from Texture.ts.
  39198. * Passed information to create a WebGLTexture
  39199. * @param url defines a value which contains one of the following:
  39200. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  39201. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  39202. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  39203. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  39204. * @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)
  39205. * @param scene needed for loading to the correct scene
  39206. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  39207. * @param onLoad optional callback to be called upon successful completion
  39208. * @param onError optional callback to be called upon failure
  39209. * @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
  39210. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  39211. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  39212. * @param forcedExtension defines the extension to use to pick the right loader
  39213. * @param mimeType defines an optional mime type
  39214. * @returns a InternalTexture for assignment back into BABYLON.Texture
  39215. */
  39216. 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;
  39217. /**
  39218. * Loads an image as an HTMLImageElement.
  39219. * @param input url string, ArrayBuffer, or Blob to load
  39220. * @param onLoad callback called when the image successfully loads
  39221. * @param onError callback called when the image fails to load
  39222. * @param offlineProvider offline provider for caching
  39223. * @param mimeType optional mime type
  39224. * @returns the HTMLImageElement of the loaded image
  39225. * @hidden
  39226. */
  39227. 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>;
  39228. /**
  39229. * @hidden
  39230. */
  39231. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  39232. private _unpackFlipYCached;
  39233. /**
  39234. * In case you are sharing the context with other applications, it might
  39235. * be interested to not cache the unpack flip y state to ensure a consistent
  39236. * value would be set.
  39237. */
  39238. enableUnpackFlipYCached: boolean;
  39239. /** @hidden */
  39240. _unpackFlipY(value: boolean): void;
  39241. /** @hidden */
  39242. _getUnpackAlignement(): number;
  39243. private _getTextureTarget;
  39244. /**
  39245. * Update the sampling mode of a given texture
  39246. * @param samplingMode defines the required sampling mode
  39247. * @param texture defines the texture to update
  39248. * @param generateMipMaps defines whether to generate mipmaps for the texture
  39249. */
  39250. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  39251. /**
  39252. * Update the sampling mode of a given texture
  39253. * @param texture defines the texture to update
  39254. * @param wrapU defines the texture wrap mode of the u coordinates
  39255. * @param wrapV defines the texture wrap mode of the v coordinates
  39256. * @param wrapR defines the texture wrap mode of the r coordinates
  39257. */
  39258. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  39259. /** @hidden */
  39260. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  39261. width: number;
  39262. height: number;
  39263. layers?: number;
  39264. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  39265. /** @hidden */
  39266. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  39267. /** @hidden */
  39268. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  39269. /**
  39270. * Update a portion of an internal texture
  39271. * @param texture defines the texture to update
  39272. * @param imageData defines the data to store into the texture
  39273. * @param xOffset defines the x coordinates of the update rectangle
  39274. * @param yOffset defines the y coordinates of the update rectangle
  39275. * @param width defines the width of the update rectangle
  39276. * @param height defines the height of the update rectangle
  39277. * @param faceIndex defines the face index if texture is a cube (0 by default)
  39278. * @param lod defines the lod level to update (0 by default)
  39279. */
  39280. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  39281. /** @hidden */
  39282. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  39283. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  39284. private _prepareWebGLTexture;
  39285. /** @hidden */
  39286. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  39287. private _getDepthStencilBuffer;
  39288. /** @hidden */
  39289. _releaseFramebufferObjects(texture: InternalTexture): void;
  39290. /** @hidden */
  39291. _releaseTexture(texture: InternalTexture): void;
  39292. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  39293. protected _setProgram(program: WebGLProgram): void;
  39294. protected _boundUniforms: {
  39295. [key: number]: WebGLUniformLocation;
  39296. };
  39297. /**
  39298. * Binds an effect to the webGL context
  39299. * @param effect defines the effect to bind
  39300. */
  39301. bindSamplers(effect: Effect): void;
  39302. private _activateCurrentTexture;
  39303. /** @hidden */
  39304. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  39305. /** @hidden */
  39306. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  39307. /**
  39308. * Unbind all textures from the webGL context
  39309. */
  39310. unbindAllTextures(): void;
  39311. /**
  39312. * Sets a texture to the according uniform.
  39313. * @param channel The texture channel
  39314. * @param uniform The uniform to set
  39315. * @param texture The texture to apply
  39316. */
  39317. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  39318. private _bindSamplerUniformToChannel;
  39319. private _getTextureWrapMode;
  39320. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  39321. /**
  39322. * Sets an array of texture to the webGL context
  39323. * @param channel defines the channel where the texture array must be set
  39324. * @param uniform defines the associated uniform location
  39325. * @param textures defines the array of textures to bind
  39326. */
  39327. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  39328. /** @hidden */
  39329. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  39330. private _setTextureParameterFloat;
  39331. private _setTextureParameterInteger;
  39332. /**
  39333. * Unbind all vertex attributes from the webGL context
  39334. */
  39335. unbindAllAttributes(): void;
  39336. /**
  39337. * 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
  39338. */
  39339. releaseEffects(): void;
  39340. /**
  39341. * Dispose and release all associated resources
  39342. */
  39343. dispose(): void;
  39344. /**
  39345. * Attach a new callback raised when context lost event is fired
  39346. * @param callback defines the callback to call
  39347. */
  39348. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  39349. /**
  39350. * Attach a new callback raised when context restored event is fired
  39351. * @param callback defines the callback to call
  39352. */
  39353. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  39354. /**
  39355. * Get the current error code of the webGL context
  39356. * @returns the error code
  39357. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  39358. */
  39359. getError(): number;
  39360. private _canRenderToFloatFramebuffer;
  39361. private _canRenderToHalfFloatFramebuffer;
  39362. private _canRenderToFramebuffer;
  39363. /** @hidden */
  39364. _getWebGLTextureType(type: number): number;
  39365. /** @hidden */
  39366. _getInternalFormat(format: number): number;
  39367. /** @hidden */
  39368. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  39369. /** @hidden */
  39370. _getRGBAMultiSampleBufferFormat(type: number): number;
  39371. /** @hidden */
  39372. _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;
  39373. /**
  39374. * Loads a file from a url
  39375. * @param url url to load
  39376. * @param onSuccess callback called when the file successfully loads
  39377. * @param onProgress callback called while file is loading (if the server supports this mode)
  39378. * @param offlineProvider defines the offline provider for caching
  39379. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  39380. * @param onError callback called when the file fails to load
  39381. * @returns a file request object
  39382. * @hidden
  39383. */
  39384. 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;
  39385. /**
  39386. * Reads pixels from the current frame buffer. Please note that this function can be slow
  39387. * @param x defines the x coordinate of the rectangle where pixels must be read
  39388. * @param y defines the y coordinate of the rectangle where pixels must be read
  39389. * @param width defines the width of the rectangle where pixels must be read
  39390. * @param height defines the height of the rectangle where pixels must be read
  39391. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  39392. * @returns a Uint8Array containing RGBA colors
  39393. */
  39394. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  39395. private static _IsSupported;
  39396. private static _HasMajorPerformanceCaveat;
  39397. /**
  39398. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  39399. */
  39400. static get IsSupported(): boolean;
  39401. /**
  39402. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  39403. * @returns true if the engine can be created
  39404. * @ignorenaming
  39405. */
  39406. static isSupported(): boolean;
  39407. /**
  39408. * Gets a boolean indicating if the engine can be instanciated on a performant device (ie. if a webGL context can be found and it does not use a slow implementation)
  39409. */
  39410. static get HasMajorPerformanceCaveat(): boolean;
  39411. /**
  39412. * Find the next highest power of two.
  39413. * @param x Number to start search from.
  39414. * @return Next highest power of two.
  39415. */
  39416. static CeilingPOT(x: number): number;
  39417. /**
  39418. * Find the next lowest power of two.
  39419. * @param x Number to start search from.
  39420. * @return Next lowest power of two.
  39421. */
  39422. static FloorPOT(x: number): number;
  39423. /**
  39424. * Find the nearest power of two.
  39425. * @param x Number to start search from.
  39426. * @return Next nearest power of two.
  39427. */
  39428. static NearestPOT(x: number): number;
  39429. /**
  39430. * Get the closest exponent of two
  39431. * @param value defines the value to approximate
  39432. * @param max defines the maximum value to return
  39433. * @param mode defines how to define the closest value
  39434. * @returns closest exponent of two of the given value
  39435. */
  39436. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  39437. /**
  39438. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  39439. * @param func - the function to be called
  39440. * @param requester - the object that will request the next frame. Falls back to window.
  39441. * @returns frame number
  39442. */
  39443. static QueueNewFrame(func: () => void, requester?: any): number;
  39444. /**
  39445. * Gets host document
  39446. * @returns the host document object
  39447. */
  39448. getHostDocument(): Nullable<Document>;
  39449. }
  39450. }
  39451. declare module BABYLON {
  39452. /**
  39453. * Defines the source of the internal texture
  39454. */
  39455. export enum InternalTextureSource {
  39456. /**
  39457. * The source of the texture data is unknown
  39458. */
  39459. Unknown = 0,
  39460. /**
  39461. * Texture data comes from an URL
  39462. */
  39463. Url = 1,
  39464. /**
  39465. * Texture data is only used for temporary storage
  39466. */
  39467. Temp = 2,
  39468. /**
  39469. * Texture data comes from raw data (ArrayBuffer)
  39470. */
  39471. Raw = 3,
  39472. /**
  39473. * Texture content is dynamic (video or dynamic texture)
  39474. */
  39475. Dynamic = 4,
  39476. /**
  39477. * Texture content is generated by rendering to it
  39478. */
  39479. RenderTarget = 5,
  39480. /**
  39481. * Texture content is part of a multi render target process
  39482. */
  39483. MultiRenderTarget = 6,
  39484. /**
  39485. * Texture data comes from a cube data file
  39486. */
  39487. Cube = 7,
  39488. /**
  39489. * Texture data comes from a raw cube data
  39490. */
  39491. CubeRaw = 8,
  39492. /**
  39493. * Texture data come from a prefiltered cube data file
  39494. */
  39495. CubePrefiltered = 9,
  39496. /**
  39497. * Texture content is raw 3D data
  39498. */
  39499. Raw3D = 10,
  39500. /**
  39501. * Texture content is raw 2D array data
  39502. */
  39503. Raw2DArray = 11,
  39504. /**
  39505. * Texture content is a depth texture
  39506. */
  39507. Depth = 12,
  39508. /**
  39509. * Texture data comes from a raw cube data encoded with RGBD
  39510. */
  39511. CubeRawRGBD = 13
  39512. }
  39513. /**
  39514. * Class used to store data associated with WebGL texture data for the engine
  39515. * This class should not be used directly
  39516. */
  39517. export class InternalTexture {
  39518. /** @hidden */
  39519. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  39520. /**
  39521. * Defines if the texture is ready
  39522. */
  39523. isReady: boolean;
  39524. /**
  39525. * Defines if the texture is a cube texture
  39526. */
  39527. isCube: boolean;
  39528. /**
  39529. * Defines if the texture contains 3D data
  39530. */
  39531. is3D: boolean;
  39532. /**
  39533. * Defines if the texture contains 2D array data
  39534. */
  39535. is2DArray: boolean;
  39536. /**
  39537. * Defines if the texture contains multiview data
  39538. */
  39539. isMultiview: boolean;
  39540. /**
  39541. * Gets the URL used to load this texture
  39542. */
  39543. url: string;
  39544. /**
  39545. * Gets the sampling mode of the texture
  39546. */
  39547. samplingMode: number;
  39548. /**
  39549. * Gets a boolean indicating if the texture needs mipmaps generation
  39550. */
  39551. generateMipMaps: boolean;
  39552. /**
  39553. * Gets the number of samples used by the texture (WebGL2+ only)
  39554. */
  39555. samples: number;
  39556. /**
  39557. * Gets the type of the texture (int, float...)
  39558. */
  39559. type: number;
  39560. /**
  39561. * Gets the format of the texture (RGB, RGBA...)
  39562. */
  39563. format: number;
  39564. /**
  39565. * Observable called when the texture is loaded
  39566. */
  39567. onLoadedObservable: Observable<InternalTexture>;
  39568. /**
  39569. * Gets the width of the texture
  39570. */
  39571. width: number;
  39572. /**
  39573. * Gets the height of the texture
  39574. */
  39575. height: number;
  39576. /**
  39577. * Gets the depth of the texture
  39578. */
  39579. depth: number;
  39580. /**
  39581. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  39582. */
  39583. baseWidth: number;
  39584. /**
  39585. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  39586. */
  39587. baseHeight: number;
  39588. /**
  39589. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  39590. */
  39591. baseDepth: number;
  39592. /**
  39593. * Gets a boolean indicating if the texture is inverted on Y axis
  39594. */
  39595. invertY: boolean;
  39596. /** @hidden */
  39597. _invertVScale: boolean;
  39598. /** @hidden */
  39599. _associatedChannel: number;
  39600. /** @hidden */
  39601. _source: InternalTextureSource;
  39602. /** @hidden */
  39603. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  39604. /** @hidden */
  39605. _bufferView: Nullable<ArrayBufferView>;
  39606. /** @hidden */
  39607. _bufferViewArray: Nullable<ArrayBufferView[]>;
  39608. /** @hidden */
  39609. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  39610. /** @hidden */
  39611. _size: number;
  39612. /** @hidden */
  39613. _extension: string;
  39614. /** @hidden */
  39615. _files: Nullable<string[]>;
  39616. /** @hidden */
  39617. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  39618. /** @hidden */
  39619. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  39620. /** @hidden */
  39621. _framebuffer: Nullable<WebGLFramebuffer>;
  39622. /** @hidden */
  39623. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  39624. /** @hidden */
  39625. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  39626. /** @hidden */
  39627. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  39628. /** @hidden */
  39629. _attachments: Nullable<number[]>;
  39630. /** @hidden */
  39631. _textureArray: Nullable<InternalTexture[]>;
  39632. /** @hidden */
  39633. _cachedCoordinatesMode: Nullable<number>;
  39634. /** @hidden */
  39635. _cachedWrapU: Nullable<number>;
  39636. /** @hidden */
  39637. _cachedWrapV: Nullable<number>;
  39638. /** @hidden */
  39639. _cachedWrapR: Nullable<number>;
  39640. /** @hidden */
  39641. _cachedAnisotropicFilteringLevel: Nullable<number>;
  39642. /** @hidden */
  39643. _isDisabled: boolean;
  39644. /** @hidden */
  39645. _compression: Nullable<string>;
  39646. /** @hidden */
  39647. _generateStencilBuffer: boolean;
  39648. /** @hidden */
  39649. _generateDepthBuffer: boolean;
  39650. /** @hidden */
  39651. _comparisonFunction: number;
  39652. /** @hidden */
  39653. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  39654. /** @hidden */
  39655. _lodGenerationScale: number;
  39656. /** @hidden */
  39657. _lodGenerationOffset: number;
  39658. /** @hidden */
  39659. _depthStencilTexture: Nullable<InternalTexture>;
  39660. /** @hidden */
  39661. _colorTextureArray: Nullable<WebGLTexture>;
  39662. /** @hidden */
  39663. _depthStencilTextureArray: Nullable<WebGLTexture>;
  39664. /** @hidden */
  39665. _lodTextureHigh: Nullable<BaseTexture>;
  39666. /** @hidden */
  39667. _lodTextureMid: Nullable<BaseTexture>;
  39668. /** @hidden */
  39669. _lodTextureLow: Nullable<BaseTexture>;
  39670. /** @hidden */
  39671. _isRGBD: boolean;
  39672. /** @hidden */
  39673. _linearSpecularLOD: boolean;
  39674. /** @hidden */
  39675. _irradianceTexture: Nullable<BaseTexture>;
  39676. /** @hidden */
  39677. _webGLTexture: Nullable<WebGLTexture>;
  39678. /** @hidden */
  39679. _references: number;
  39680. /** @hidden */
  39681. _gammaSpace: Nullable<boolean>;
  39682. private _engine;
  39683. /**
  39684. * Gets the Engine the texture belongs to.
  39685. * @returns The babylon engine
  39686. */
  39687. getEngine(): ThinEngine;
  39688. /**
  39689. * Gets the data source type of the texture
  39690. */
  39691. get source(): InternalTextureSource;
  39692. /**
  39693. * Creates a new InternalTexture
  39694. * @param engine defines the engine to use
  39695. * @param source defines the type of data that will be used
  39696. * @param delayAllocation if the texture allocation should be delayed (default: false)
  39697. */
  39698. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  39699. /**
  39700. * Increments the number of references (ie. the number of Texture that point to it)
  39701. */
  39702. incrementReferences(): void;
  39703. /**
  39704. * Change the size of the texture (not the size of the content)
  39705. * @param width defines the new width
  39706. * @param height defines the new height
  39707. * @param depth defines the new depth (1 by default)
  39708. */
  39709. updateSize(width: int, height: int, depth?: int): void;
  39710. /** @hidden */
  39711. _rebuild(): void;
  39712. /** @hidden */
  39713. _swapAndDie(target: InternalTexture): void;
  39714. /**
  39715. * Dispose the current allocated resources
  39716. */
  39717. dispose(): void;
  39718. }
  39719. }
  39720. declare module BABYLON {
  39721. /**
  39722. * Class used to work with sound analyzer using fast fourier transform (FFT)
  39723. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  39724. */
  39725. export class Analyser {
  39726. /**
  39727. * Gets or sets the smoothing
  39728. * @ignorenaming
  39729. */
  39730. SMOOTHING: number;
  39731. /**
  39732. * Gets or sets the FFT table size
  39733. * @ignorenaming
  39734. */
  39735. FFT_SIZE: number;
  39736. /**
  39737. * Gets or sets the bar graph amplitude
  39738. * @ignorenaming
  39739. */
  39740. BARGRAPHAMPLITUDE: number;
  39741. /**
  39742. * Gets or sets the position of the debug canvas
  39743. * @ignorenaming
  39744. */
  39745. DEBUGCANVASPOS: {
  39746. x: number;
  39747. y: number;
  39748. };
  39749. /**
  39750. * Gets or sets the debug canvas size
  39751. * @ignorenaming
  39752. */
  39753. DEBUGCANVASSIZE: {
  39754. width: number;
  39755. height: number;
  39756. };
  39757. private _byteFreqs;
  39758. private _byteTime;
  39759. private _floatFreqs;
  39760. private _webAudioAnalyser;
  39761. private _debugCanvas;
  39762. private _debugCanvasContext;
  39763. private _scene;
  39764. private _registerFunc;
  39765. private _audioEngine;
  39766. /**
  39767. * Creates a new analyser
  39768. * @param scene defines hosting scene
  39769. */
  39770. constructor(scene: Scene);
  39771. /**
  39772. * Get the number of data values you will have to play with for the visualization
  39773. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  39774. * @returns a number
  39775. */
  39776. getFrequencyBinCount(): number;
  39777. /**
  39778. * Gets the current frequency data as a byte array
  39779. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  39780. * @returns a Uint8Array
  39781. */
  39782. getByteFrequencyData(): Uint8Array;
  39783. /**
  39784. * Gets the current waveform as a byte array
  39785. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  39786. * @returns a Uint8Array
  39787. */
  39788. getByteTimeDomainData(): Uint8Array;
  39789. /**
  39790. * Gets the current frequency data as a float array
  39791. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  39792. * @returns a Float32Array
  39793. */
  39794. getFloatFrequencyData(): Float32Array;
  39795. /**
  39796. * Renders the debug canvas
  39797. */
  39798. drawDebugCanvas(): void;
  39799. /**
  39800. * Stops rendering the debug canvas and removes it
  39801. */
  39802. stopDebugCanvas(): void;
  39803. /**
  39804. * Connects two audio nodes
  39805. * @param inputAudioNode defines first node to connect
  39806. * @param outputAudioNode defines second node to connect
  39807. */
  39808. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  39809. /**
  39810. * Releases all associated resources
  39811. */
  39812. dispose(): void;
  39813. }
  39814. }
  39815. declare module BABYLON {
  39816. /**
  39817. * This represents an audio engine and it is responsible
  39818. * to play, synchronize and analyse sounds throughout the application.
  39819. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  39820. */
  39821. export interface IAudioEngine extends IDisposable {
  39822. /**
  39823. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  39824. */
  39825. readonly canUseWebAudio: boolean;
  39826. /**
  39827. * Gets the current AudioContext if available.
  39828. */
  39829. readonly audioContext: Nullable<AudioContext>;
  39830. /**
  39831. * The master gain node defines the global audio volume of your audio engine.
  39832. */
  39833. readonly masterGain: GainNode;
  39834. /**
  39835. * Gets whether or not mp3 are supported by your browser.
  39836. */
  39837. readonly isMP3supported: boolean;
  39838. /**
  39839. * Gets whether or not ogg are supported by your browser.
  39840. */
  39841. readonly isOGGsupported: boolean;
  39842. /**
  39843. * Defines if Babylon should emit a warning if WebAudio is not supported.
  39844. * @ignoreNaming
  39845. */
  39846. WarnedWebAudioUnsupported: boolean;
  39847. /**
  39848. * Defines if the audio engine relies on a custom unlocked button.
  39849. * In this case, the embedded button will not be displayed.
  39850. */
  39851. useCustomUnlockedButton: boolean;
  39852. /**
  39853. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  39854. */
  39855. readonly unlocked: boolean;
  39856. /**
  39857. * Event raised when audio has been unlocked on the browser.
  39858. */
  39859. onAudioUnlockedObservable: Observable<AudioEngine>;
  39860. /**
  39861. * Event raised when audio has been locked on the browser.
  39862. */
  39863. onAudioLockedObservable: Observable<AudioEngine>;
  39864. /**
  39865. * Flags the audio engine in Locked state.
  39866. * This happens due to new browser policies preventing audio to autoplay.
  39867. */
  39868. lock(): void;
  39869. /**
  39870. * Unlocks the audio engine once a user action has been done on the dom.
  39871. * This is helpful to resume play once browser policies have been satisfied.
  39872. */
  39873. unlock(): void;
  39874. /**
  39875. * Gets the global volume sets on the master gain.
  39876. * @returns the global volume if set or -1 otherwise
  39877. */
  39878. getGlobalVolume(): number;
  39879. /**
  39880. * Sets the global volume of your experience (sets on the master gain).
  39881. * @param newVolume Defines the new global volume of the application
  39882. */
  39883. setGlobalVolume(newVolume: number): void;
  39884. /**
  39885. * Connect the audio engine to an audio analyser allowing some amazing
  39886. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  39887. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  39888. * @param analyser The analyser to connect to the engine
  39889. */
  39890. connectToAnalyser(analyser: Analyser): void;
  39891. }
  39892. /**
  39893. * This represents the default audio engine used in babylon.
  39894. * It is responsible to play, synchronize and analyse sounds throughout the application.
  39895. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  39896. */
  39897. export class AudioEngine implements IAudioEngine {
  39898. private _audioContext;
  39899. private _audioContextInitialized;
  39900. private _muteButton;
  39901. private _hostElement;
  39902. /**
  39903. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  39904. */
  39905. canUseWebAudio: boolean;
  39906. /**
  39907. * The master gain node defines the global audio volume of your audio engine.
  39908. */
  39909. masterGain: GainNode;
  39910. /**
  39911. * Defines if Babylon should emit a warning if WebAudio is not supported.
  39912. * @ignoreNaming
  39913. */
  39914. WarnedWebAudioUnsupported: boolean;
  39915. /**
  39916. * Gets whether or not mp3 are supported by your browser.
  39917. */
  39918. isMP3supported: boolean;
  39919. /**
  39920. * Gets whether or not ogg are supported by your browser.
  39921. */
  39922. isOGGsupported: boolean;
  39923. /**
  39924. * Gets whether audio has been unlocked on the device.
  39925. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  39926. * a user interaction has happened.
  39927. */
  39928. unlocked: boolean;
  39929. /**
  39930. * Defines if the audio engine relies on a custom unlocked button.
  39931. * In this case, the embedded button will not be displayed.
  39932. */
  39933. useCustomUnlockedButton: boolean;
  39934. /**
  39935. * Event raised when audio has been unlocked on the browser.
  39936. */
  39937. onAudioUnlockedObservable: Observable<AudioEngine>;
  39938. /**
  39939. * Event raised when audio has been locked on the browser.
  39940. */
  39941. onAudioLockedObservable: Observable<AudioEngine>;
  39942. /**
  39943. * Gets the current AudioContext if available.
  39944. */
  39945. get audioContext(): Nullable<AudioContext>;
  39946. private _connectedAnalyser;
  39947. /**
  39948. * Instantiates a new audio engine.
  39949. *
  39950. * There should be only one per page as some browsers restrict the number
  39951. * of audio contexts you can create.
  39952. * @param hostElement defines the host element where to display the mute icon if necessary
  39953. */
  39954. constructor(hostElement?: Nullable<HTMLElement>);
  39955. /**
  39956. * Flags the audio engine in Locked state.
  39957. * This happens due to new browser policies preventing audio to autoplay.
  39958. */
  39959. lock(): void;
  39960. /**
  39961. * Unlocks the audio engine once a user action has been done on the dom.
  39962. * This is helpful to resume play once browser policies have been satisfied.
  39963. */
  39964. unlock(): void;
  39965. private _resumeAudioContext;
  39966. private _initializeAudioContext;
  39967. private _tryToRun;
  39968. private _triggerRunningState;
  39969. private _triggerSuspendedState;
  39970. private _displayMuteButton;
  39971. private _moveButtonToTopLeft;
  39972. private _onResize;
  39973. private _hideMuteButton;
  39974. /**
  39975. * Destroy and release the resources associated with the audio ccontext.
  39976. */
  39977. dispose(): void;
  39978. /**
  39979. * Gets the global volume sets on the master gain.
  39980. * @returns the global volume if set or -1 otherwise
  39981. */
  39982. getGlobalVolume(): number;
  39983. /**
  39984. * Sets the global volume of your experience (sets on the master gain).
  39985. * @param newVolume Defines the new global volume of the application
  39986. */
  39987. setGlobalVolume(newVolume: number): void;
  39988. /**
  39989. * Connect the audio engine to an audio analyser allowing some amazing
  39990. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  39991. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  39992. * @param analyser The analyser to connect to the engine
  39993. */
  39994. connectToAnalyser(analyser: Analyser): void;
  39995. }
  39996. }
  39997. declare module BABYLON {
  39998. /**
  39999. * Interface used to present a loading screen while loading a scene
  40000. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  40001. */
  40002. export interface ILoadingScreen {
  40003. /**
  40004. * Function called to display the loading screen
  40005. */
  40006. displayLoadingUI: () => void;
  40007. /**
  40008. * Function called to hide the loading screen
  40009. */
  40010. hideLoadingUI: () => void;
  40011. /**
  40012. * Gets or sets the color to use for the background
  40013. */
  40014. loadingUIBackgroundColor: string;
  40015. /**
  40016. * Gets or sets the text to display while loading
  40017. */
  40018. loadingUIText: string;
  40019. }
  40020. /**
  40021. * Class used for the default loading screen
  40022. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  40023. */
  40024. export class DefaultLoadingScreen implements ILoadingScreen {
  40025. private _renderingCanvas;
  40026. private _loadingText;
  40027. private _loadingDivBackgroundColor;
  40028. private _loadingDiv;
  40029. private _loadingTextDiv;
  40030. /** Gets or sets the logo url to use for the default loading screen */
  40031. static DefaultLogoUrl: string;
  40032. /** Gets or sets the spinner url to use for the default loading screen */
  40033. static DefaultSpinnerUrl: string;
  40034. /**
  40035. * Creates a new default loading screen
  40036. * @param _renderingCanvas defines the canvas used to render the scene
  40037. * @param _loadingText defines the default text to display
  40038. * @param _loadingDivBackgroundColor defines the default background color
  40039. */
  40040. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  40041. /**
  40042. * Function called to display the loading screen
  40043. */
  40044. displayLoadingUI(): void;
  40045. /**
  40046. * Function called to hide the loading screen
  40047. */
  40048. hideLoadingUI(): void;
  40049. /**
  40050. * Gets or sets the text to display while loading
  40051. */
  40052. set loadingUIText(text: string);
  40053. get loadingUIText(): string;
  40054. /**
  40055. * Gets or sets the color to use for the background
  40056. */
  40057. get loadingUIBackgroundColor(): string;
  40058. set loadingUIBackgroundColor(color: string);
  40059. private _resizeLoadingUI;
  40060. }
  40061. }
  40062. declare module BABYLON {
  40063. /**
  40064. * Interface for any object that can request an animation frame
  40065. */
  40066. export interface ICustomAnimationFrameRequester {
  40067. /**
  40068. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  40069. */
  40070. renderFunction?: Function;
  40071. /**
  40072. * Called to request the next frame to render to
  40073. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  40074. */
  40075. requestAnimationFrame: Function;
  40076. /**
  40077. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  40078. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  40079. */
  40080. requestID?: number;
  40081. }
  40082. }
  40083. declare module BABYLON {
  40084. /**
  40085. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  40086. */
  40087. export class PerformanceMonitor {
  40088. private _enabled;
  40089. private _rollingFrameTime;
  40090. private _lastFrameTimeMs;
  40091. /**
  40092. * constructor
  40093. * @param frameSampleSize The number of samples required to saturate the sliding window
  40094. */
  40095. constructor(frameSampleSize?: number);
  40096. /**
  40097. * Samples current frame
  40098. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  40099. */
  40100. sampleFrame(timeMs?: number): void;
  40101. /**
  40102. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  40103. */
  40104. get averageFrameTime(): number;
  40105. /**
  40106. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  40107. */
  40108. get averageFrameTimeVariance(): number;
  40109. /**
  40110. * Returns the frame time of the most recent frame
  40111. */
  40112. get instantaneousFrameTime(): number;
  40113. /**
  40114. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  40115. */
  40116. get averageFPS(): number;
  40117. /**
  40118. * Returns the average framerate in frames per second using the most recent frame time
  40119. */
  40120. get instantaneousFPS(): number;
  40121. /**
  40122. * Returns true if enough samples have been taken to completely fill the sliding window
  40123. */
  40124. get isSaturated(): boolean;
  40125. /**
  40126. * Enables contributions to the sliding window sample set
  40127. */
  40128. enable(): void;
  40129. /**
  40130. * Disables contributions to the sliding window sample set
  40131. * Samples will not be interpolated over the disabled period
  40132. */
  40133. disable(): void;
  40134. /**
  40135. * Returns true if sampling is enabled
  40136. */
  40137. get isEnabled(): boolean;
  40138. /**
  40139. * Resets performance monitor
  40140. */
  40141. reset(): void;
  40142. }
  40143. /**
  40144. * RollingAverage
  40145. *
  40146. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  40147. */
  40148. export class RollingAverage {
  40149. /**
  40150. * Current average
  40151. */
  40152. average: number;
  40153. /**
  40154. * Current variance
  40155. */
  40156. variance: number;
  40157. protected _samples: Array<number>;
  40158. protected _sampleCount: number;
  40159. protected _pos: number;
  40160. protected _m2: number;
  40161. /**
  40162. * constructor
  40163. * @param length The number of samples required to saturate the sliding window
  40164. */
  40165. constructor(length: number);
  40166. /**
  40167. * Adds a sample to the sample set
  40168. * @param v The sample value
  40169. */
  40170. add(v: number): void;
  40171. /**
  40172. * Returns previously added values or null if outside of history or outside the sliding window domain
  40173. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  40174. * @return Value previously recorded with add() or null if outside of range
  40175. */
  40176. history(i: number): number;
  40177. /**
  40178. * Returns true if enough samples have been taken to completely fill the sliding window
  40179. * @return true if sample-set saturated
  40180. */
  40181. isSaturated(): boolean;
  40182. /**
  40183. * Resets the rolling average (equivalent to 0 samples taken so far)
  40184. */
  40185. reset(): void;
  40186. /**
  40187. * Wraps a value around the sample range boundaries
  40188. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  40189. * @return Wrapped position in sample range
  40190. */
  40191. protected _wrapPosition(i: number): number;
  40192. }
  40193. }
  40194. declare module BABYLON {
  40195. /**
  40196. * This class is used to track a performance counter which is number based.
  40197. * The user has access to many properties which give statistics of different nature.
  40198. *
  40199. * The implementer can track two kinds of Performance Counter: time and count.
  40200. * 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.
  40201. * 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.
  40202. */
  40203. export class PerfCounter {
  40204. /**
  40205. * Gets or sets a global boolean to turn on and off all the counters
  40206. */
  40207. static Enabled: boolean;
  40208. /**
  40209. * Returns the smallest value ever
  40210. */
  40211. get min(): number;
  40212. /**
  40213. * Returns the biggest value ever
  40214. */
  40215. get max(): number;
  40216. /**
  40217. * Returns the average value since the performance counter is running
  40218. */
  40219. get average(): number;
  40220. /**
  40221. * Returns the average value of the last second the counter was monitored
  40222. */
  40223. get lastSecAverage(): number;
  40224. /**
  40225. * Returns the current value
  40226. */
  40227. get current(): number;
  40228. /**
  40229. * Gets the accumulated total
  40230. */
  40231. get total(): number;
  40232. /**
  40233. * Gets the total value count
  40234. */
  40235. get count(): number;
  40236. /**
  40237. * Creates a new counter
  40238. */
  40239. constructor();
  40240. /**
  40241. * Call this method to start monitoring a new frame.
  40242. * 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.
  40243. */
  40244. fetchNewFrame(): void;
  40245. /**
  40246. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  40247. * @param newCount the count value to add to the monitored count
  40248. * @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.
  40249. */
  40250. addCount(newCount: number, fetchResult: boolean): void;
  40251. /**
  40252. * Start monitoring this performance counter
  40253. */
  40254. beginMonitoring(): void;
  40255. /**
  40256. * Compute the time lapsed since the previous beginMonitoring() call.
  40257. * @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
  40258. */
  40259. endMonitoring(newFrame?: boolean): void;
  40260. private _fetchResult;
  40261. private _startMonitoringTime;
  40262. private _min;
  40263. private _max;
  40264. private _average;
  40265. private _current;
  40266. private _totalValueCount;
  40267. private _totalAccumulated;
  40268. private _lastSecAverage;
  40269. private _lastSecAccumulated;
  40270. private _lastSecTime;
  40271. private _lastSecValueCount;
  40272. }
  40273. }
  40274. declare module BABYLON {
  40275. interface ThinEngine {
  40276. /** @hidden */
  40277. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  40278. }
  40279. }
  40280. declare module BABYLON {
  40281. /**
  40282. * Defines the interface used by display changed events
  40283. */
  40284. export interface IDisplayChangedEventArgs {
  40285. /** Gets the vrDisplay object (if any) */
  40286. vrDisplay: Nullable<any>;
  40287. /** Gets a boolean indicating if webVR is supported */
  40288. vrSupported: boolean;
  40289. }
  40290. /**
  40291. * Defines the interface used by objects containing a viewport (like a camera)
  40292. */
  40293. interface IViewportOwnerLike {
  40294. /**
  40295. * Gets or sets the viewport
  40296. */
  40297. viewport: IViewportLike;
  40298. }
  40299. /**
  40300. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  40301. */
  40302. export class Engine extends ThinEngine {
  40303. /** Defines that alpha blending is disabled */
  40304. static readonly ALPHA_DISABLE: number;
  40305. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  40306. static readonly ALPHA_ADD: number;
  40307. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  40308. static readonly ALPHA_COMBINE: number;
  40309. /** Defines that alpha blending to DEST - SRC * DEST */
  40310. static readonly ALPHA_SUBTRACT: number;
  40311. /** Defines that alpha blending to SRC * DEST */
  40312. static readonly ALPHA_MULTIPLY: number;
  40313. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  40314. static readonly ALPHA_MAXIMIZED: number;
  40315. /** Defines that alpha blending to SRC + DEST */
  40316. static readonly ALPHA_ONEONE: number;
  40317. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  40318. static readonly ALPHA_PREMULTIPLIED: number;
  40319. /**
  40320. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  40321. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  40322. */
  40323. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  40324. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  40325. static readonly ALPHA_INTERPOLATE: number;
  40326. /**
  40327. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  40328. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  40329. */
  40330. static readonly ALPHA_SCREENMODE: number;
  40331. /** Defines that the ressource is not delayed*/
  40332. static readonly DELAYLOADSTATE_NONE: number;
  40333. /** Defines that the ressource was successfully delay loaded */
  40334. static readonly DELAYLOADSTATE_LOADED: number;
  40335. /** Defines that the ressource is currently delay loading */
  40336. static readonly DELAYLOADSTATE_LOADING: number;
  40337. /** Defines that the ressource is delayed and has not started loading */
  40338. static readonly DELAYLOADSTATE_NOTLOADED: number;
  40339. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  40340. static readonly NEVER: number;
  40341. /** 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 */
  40342. static readonly ALWAYS: number;
  40343. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  40344. static readonly LESS: number;
  40345. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  40346. static readonly EQUAL: number;
  40347. /** 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 */
  40348. static readonly LEQUAL: number;
  40349. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  40350. static readonly GREATER: number;
  40351. /** 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 */
  40352. static readonly GEQUAL: number;
  40353. /** 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 */
  40354. static readonly NOTEQUAL: number;
  40355. /** Passed to stencilOperation to specify that stencil value must be kept */
  40356. static readonly KEEP: number;
  40357. /** Passed to stencilOperation to specify that stencil value must be replaced */
  40358. static readonly REPLACE: number;
  40359. /** Passed to stencilOperation to specify that stencil value must be incremented */
  40360. static readonly INCR: number;
  40361. /** Passed to stencilOperation to specify that stencil value must be decremented */
  40362. static readonly DECR: number;
  40363. /** Passed to stencilOperation to specify that stencil value must be inverted */
  40364. static readonly INVERT: number;
  40365. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  40366. static readonly INCR_WRAP: number;
  40367. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  40368. static readonly DECR_WRAP: number;
  40369. /** Texture is not repeating outside of 0..1 UVs */
  40370. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  40371. /** Texture is repeating outside of 0..1 UVs */
  40372. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  40373. /** Texture is repeating and mirrored */
  40374. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  40375. /** ALPHA */
  40376. static readonly TEXTUREFORMAT_ALPHA: number;
  40377. /** LUMINANCE */
  40378. static readonly TEXTUREFORMAT_LUMINANCE: number;
  40379. /** LUMINANCE_ALPHA */
  40380. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  40381. /** RGB */
  40382. static readonly TEXTUREFORMAT_RGB: number;
  40383. /** RGBA */
  40384. static readonly TEXTUREFORMAT_RGBA: number;
  40385. /** RED */
  40386. static readonly TEXTUREFORMAT_RED: number;
  40387. /** RED (2nd reference) */
  40388. static readonly TEXTUREFORMAT_R: number;
  40389. /** RG */
  40390. static readonly TEXTUREFORMAT_RG: number;
  40391. /** RED_INTEGER */
  40392. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  40393. /** RED_INTEGER (2nd reference) */
  40394. static readonly TEXTUREFORMAT_R_INTEGER: number;
  40395. /** RG_INTEGER */
  40396. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  40397. /** RGB_INTEGER */
  40398. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  40399. /** RGBA_INTEGER */
  40400. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  40401. /** UNSIGNED_BYTE */
  40402. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  40403. /** UNSIGNED_BYTE (2nd reference) */
  40404. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  40405. /** FLOAT */
  40406. static readonly TEXTURETYPE_FLOAT: number;
  40407. /** HALF_FLOAT */
  40408. static readonly TEXTURETYPE_HALF_FLOAT: number;
  40409. /** BYTE */
  40410. static readonly TEXTURETYPE_BYTE: number;
  40411. /** SHORT */
  40412. static readonly TEXTURETYPE_SHORT: number;
  40413. /** UNSIGNED_SHORT */
  40414. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  40415. /** INT */
  40416. static readonly TEXTURETYPE_INT: number;
  40417. /** UNSIGNED_INT */
  40418. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  40419. /** UNSIGNED_SHORT_4_4_4_4 */
  40420. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  40421. /** UNSIGNED_SHORT_5_5_5_1 */
  40422. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  40423. /** UNSIGNED_SHORT_5_6_5 */
  40424. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  40425. /** UNSIGNED_INT_2_10_10_10_REV */
  40426. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  40427. /** UNSIGNED_INT_24_8 */
  40428. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  40429. /** UNSIGNED_INT_10F_11F_11F_REV */
  40430. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  40431. /** UNSIGNED_INT_5_9_9_9_REV */
  40432. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  40433. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  40434. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  40435. /** nearest is mag = nearest and min = nearest and mip = linear */
  40436. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  40437. /** Bilinear is mag = linear and min = linear and mip = nearest */
  40438. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  40439. /** Trilinear is mag = linear and min = linear and mip = linear */
  40440. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  40441. /** nearest is mag = nearest and min = nearest and mip = linear */
  40442. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  40443. /** Bilinear is mag = linear and min = linear and mip = nearest */
  40444. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  40445. /** Trilinear is mag = linear and min = linear and mip = linear */
  40446. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  40447. /** mag = nearest and min = nearest and mip = nearest */
  40448. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  40449. /** mag = nearest and min = linear and mip = nearest */
  40450. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  40451. /** mag = nearest and min = linear and mip = linear */
  40452. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  40453. /** mag = nearest and min = linear and mip = none */
  40454. static readonly TEXTURE_NEAREST_LINEAR: number;
  40455. /** mag = nearest and min = nearest and mip = none */
  40456. static readonly TEXTURE_NEAREST_NEAREST: number;
  40457. /** mag = linear and min = nearest and mip = nearest */
  40458. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  40459. /** mag = linear and min = nearest and mip = linear */
  40460. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  40461. /** mag = linear and min = linear and mip = none */
  40462. static readonly TEXTURE_LINEAR_LINEAR: number;
  40463. /** mag = linear and min = nearest and mip = none */
  40464. static readonly TEXTURE_LINEAR_NEAREST: number;
  40465. /** Explicit coordinates mode */
  40466. static readonly TEXTURE_EXPLICIT_MODE: number;
  40467. /** Spherical coordinates mode */
  40468. static readonly TEXTURE_SPHERICAL_MODE: number;
  40469. /** Planar coordinates mode */
  40470. static readonly TEXTURE_PLANAR_MODE: number;
  40471. /** Cubic coordinates mode */
  40472. static readonly TEXTURE_CUBIC_MODE: number;
  40473. /** Projection coordinates mode */
  40474. static readonly TEXTURE_PROJECTION_MODE: number;
  40475. /** Skybox coordinates mode */
  40476. static readonly TEXTURE_SKYBOX_MODE: number;
  40477. /** Inverse Cubic coordinates mode */
  40478. static readonly TEXTURE_INVCUBIC_MODE: number;
  40479. /** Equirectangular coordinates mode */
  40480. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  40481. /** Equirectangular Fixed coordinates mode */
  40482. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  40483. /** Equirectangular Fixed Mirrored coordinates mode */
  40484. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  40485. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  40486. static readonly SCALEMODE_FLOOR: number;
  40487. /** Defines that texture rescaling will look for the nearest power of 2 size */
  40488. static readonly SCALEMODE_NEAREST: number;
  40489. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  40490. static readonly SCALEMODE_CEILING: number;
  40491. /**
  40492. * Returns the current npm package of the sdk
  40493. */
  40494. static get NpmPackage(): string;
  40495. /**
  40496. * Returns the current version of the framework
  40497. */
  40498. static get Version(): string;
  40499. /** Gets the list of created engines */
  40500. static get Instances(): Engine[];
  40501. /**
  40502. * Gets the latest created engine
  40503. */
  40504. static get LastCreatedEngine(): Nullable<Engine>;
  40505. /**
  40506. * Gets the latest created scene
  40507. */
  40508. static get LastCreatedScene(): Nullable<Scene>;
  40509. /**
  40510. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  40511. * @param flag defines which part of the materials must be marked as dirty
  40512. * @param predicate defines a predicate used to filter which materials should be affected
  40513. */
  40514. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  40515. /**
  40516. * Method called to create the default loading screen.
  40517. * This can be overriden in your own app.
  40518. * @param canvas The rendering canvas element
  40519. * @returns The loading screen
  40520. */
  40521. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  40522. /**
  40523. * Method called to create the default rescale post process on each engine.
  40524. */
  40525. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  40526. /**
  40527. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  40528. **/
  40529. enableOfflineSupport: boolean;
  40530. /**
  40531. * 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)
  40532. **/
  40533. disableManifestCheck: boolean;
  40534. /**
  40535. * Gets the list of created scenes
  40536. */
  40537. scenes: Scene[];
  40538. /**
  40539. * Event raised when a new scene is created
  40540. */
  40541. onNewSceneAddedObservable: Observable<Scene>;
  40542. /**
  40543. * Gets the list of created postprocesses
  40544. */
  40545. postProcesses: PostProcess[];
  40546. /**
  40547. * Gets a boolean indicating if the pointer is currently locked
  40548. */
  40549. isPointerLock: boolean;
  40550. /**
  40551. * Observable event triggered each time the rendering canvas is resized
  40552. */
  40553. onResizeObservable: Observable<Engine>;
  40554. /**
  40555. * Observable event triggered each time the canvas loses focus
  40556. */
  40557. onCanvasBlurObservable: Observable<Engine>;
  40558. /**
  40559. * Observable event triggered each time the canvas gains focus
  40560. */
  40561. onCanvasFocusObservable: Observable<Engine>;
  40562. /**
  40563. * Observable event triggered each time the canvas receives pointerout event
  40564. */
  40565. onCanvasPointerOutObservable: Observable<PointerEvent>;
  40566. /**
  40567. * Observable raised when the engine begins a new frame
  40568. */
  40569. onBeginFrameObservable: Observable<Engine>;
  40570. /**
  40571. * If set, will be used to request the next animation frame for the render loop
  40572. */
  40573. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  40574. /**
  40575. * Observable raised when the engine ends the current frame
  40576. */
  40577. onEndFrameObservable: Observable<Engine>;
  40578. /**
  40579. * Observable raised when the engine is about to compile a shader
  40580. */
  40581. onBeforeShaderCompilationObservable: Observable<Engine>;
  40582. /**
  40583. * Observable raised when the engine has jsut compiled a shader
  40584. */
  40585. onAfterShaderCompilationObservable: Observable<Engine>;
  40586. /**
  40587. * Gets the audio engine
  40588. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  40589. * @ignorenaming
  40590. */
  40591. static audioEngine: IAudioEngine;
  40592. /**
  40593. * Default AudioEngine factory responsible of creating the Audio Engine.
  40594. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  40595. */
  40596. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  40597. /**
  40598. * Default offline support factory responsible of creating a tool used to store data locally.
  40599. * By default, this will create a Database object if the workload has been embedded.
  40600. */
  40601. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  40602. private _loadingScreen;
  40603. private _pointerLockRequested;
  40604. private _rescalePostProcess;
  40605. private _deterministicLockstep;
  40606. private _lockstepMaxSteps;
  40607. private _timeStep;
  40608. protected get _supportsHardwareTextureRescaling(): boolean;
  40609. private _fps;
  40610. private _deltaTime;
  40611. /** @hidden */
  40612. _drawCalls: PerfCounter;
  40613. /** 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 */
  40614. canvasTabIndex: number;
  40615. /**
  40616. * Turn this value on if you want to pause FPS computation when in background
  40617. */
  40618. disablePerformanceMonitorInBackground: boolean;
  40619. private _performanceMonitor;
  40620. /**
  40621. * Gets the performance monitor attached to this engine
  40622. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  40623. */
  40624. get performanceMonitor(): PerformanceMonitor;
  40625. private _onFocus;
  40626. private _onBlur;
  40627. private _onCanvasPointerOut;
  40628. private _onCanvasBlur;
  40629. private _onCanvasFocus;
  40630. private _onFullscreenChange;
  40631. private _onPointerLockChange;
  40632. /**
  40633. * Gets the HTML element used to attach event listeners
  40634. * @returns a HTML element
  40635. */
  40636. getInputElement(): Nullable<HTMLElement>;
  40637. /**
  40638. * Creates a new engine
  40639. * @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
  40640. * @param antialias defines enable antialiasing (default: false)
  40641. * @param options defines further options to be sent to the getContext() function
  40642. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  40643. */
  40644. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  40645. /**
  40646. * Gets current aspect ratio
  40647. * @param viewportOwner defines the camera to use to get the aspect ratio
  40648. * @param useScreen defines if screen size must be used (or the current render target if any)
  40649. * @returns a number defining the aspect ratio
  40650. */
  40651. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  40652. /**
  40653. * Gets current screen aspect ratio
  40654. * @returns a number defining the aspect ratio
  40655. */
  40656. getScreenAspectRatio(): number;
  40657. /**
  40658. * Gets the client rect of the HTML canvas attached with the current webGL context
  40659. * @returns a client rectanglee
  40660. */
  40661. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  40662. /**
  40663. * Gets the client rect of the HTML element used for events
  40664. * @returns a client rectanglee
  40665. */
  40666. getInputElementClientRect(): Nullable<ClientRect>;
  40667. /**
  40668. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  40669. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40670. * @returns true if engine is in deterministic lock step mode
  40671. */
  40672. isDeterministicLockStep(): boolean;
  40673. /**
  40674. * Gets the max steps when engine is running in deterministic lock step
  40675. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40676. * @returns the max steps
  40677. */
  40678. getLockstepMaxSteps(): number;
  40679. /**
  40680. * Returns the time in ms between steps when using deterministic lock step.
  40681. * @returns time step in (ms)
  40682. */
  40683. getTimeStep(): number;
  40684. /**
  40685. * Force the mipmap generation for the given render target texture
  40686. * @param texture defines the render target texture to use
  40687. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  40688. */
  40689. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  40690. /** States */
  40691. /**
  40692. * Set various states to the webGL context
  40693. * @param culling defines backface culling state
  40694. * @param zOffset defines the value to apply to zOffset (0 by default)
  40695. * @param force defines if states must be applied even if cache is up to date
  40696. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  40697. */
  40698. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  40699. /**
  40700. * Set the z offset to apply to current rendering
  40701. * @param value defines the offset to apply
  40702. */
  40703. setZOffset(value: number): void;
  40704. /**
  40705. * Gets the current value of the zOffset
  40706. * @returns the current zOffset state
  40707. */
  40708. getZOffset(): number;
  40709. /**
  40710. * Enable or disable depth buffering
  40711. * @param enable defines the state to set
  40712. */
  40713. setDepthBuffer(enable: boolean): void;
  40714. /**
  40715. * Gets a boolean indicating if depth writing is enabled
  40716. * @returns the current depth writing state
  40717. */
  40718. getDepthWrite(): boolean;
  40719. /**
  40720. * Enable or disable depth writing
  40721. * @param enable defines the state to set
  40722. */
  40723. setDepthWrite(enable: boolean): void;
  40724. /**
  40725. * Gets a boolean indicating if stencil buffer is enabled
  40726. * @returns the current stencil buffer state
  40727. */
  40728. getStencilBuffer(): boolean;
  40729. /**
  40730. * Enable or disable the stencil buffer
  40731. * @param enable defines if the stencil buffer must be enabled or disabled
  40732. */
  40733. setStencilBuffer(enable: boolean): void;
  40734. /**
  40735. * Gets the current stencil mask
  40736. * @returns a number defining the new stencil mask to use
  40737. */
  40738. getStencilMask(): number;
  40739. /**
  40740. * Sets the current stencil mask
  40741. * @param mask defines the new stencil mask to use
  40742. */
  40743. setStencilMask(mask: number): void;
  40744. /**
  40745. * Gets the current stencil function
  40746. * @returns a number defining the stencil function to use
  40747. */
  40748. getStencilFunction(): number;
  40749. /**
  40750. * Gets the current stencil reference value
  40751. * @returns a number defining the stencil reference value to use
  40752. */
  40753. getStencilFunctionReference(): number;
  40754. /**
  40755. * Gets the current stencil mask
  40756. * @returns a number defining the stencil mask to use
  40757. */
  40758. getStencilFunctionMask(): number;
  40759. /**
  40760. * Sets the current stencil function
  40761. * @param stencilFunc defines the new stencil function to use
  40762. */
  40763. setStencilFunction(stencilFunc: number): void;
  40764. /**
  40765. * Sets the current stencil reference
  40766. * @param reference defines the new stencil reference to use
  40767. */
  40768. setStencilFunctionReference(reference: number): void;
  40769. /**
  40770. * Sets the current stencil mask
  40771. * @param mask defines the new stencil mask to use
  40772. */
  40773. setStencilFunctionMask(mask: number): void;
  40774. /**
  40775. * Gets the current stencil operation when stencil fails
  40776. * @returns a number defining stencil operation to use when stencil fails
  40777. */
  40778. getStencilOperationFail(): number;
  40779. /**
  40780. * Gets the current stencil operation when depth fails
  40781. * @returns a number defining stencil operation to use when depth fails
  40782. */
  40783. getStencilOperationDepthFail(): number;
  40784. /**
  40785. * Gets the current stencil operation when stencil passes
  40786. * @returns a number defining stencil operation to use when stencil passes
  40787. */
  40788. getStencilOperationPass(): number;
  40789. /**
  40790. * Sets the stencil operation to use when stencil fails
  40791. * @param operation defines the stencil operation to use when stencil fails
  40792. */
  40793. setStencilOperationFail(operation: number): void;
  40794. /**
  40795. * Sets the stencil operation to use when depth fails
  40796. * @param operation defines the stencil operation to use when depth fails
  40797. */
  40798. setStencilOperationDepthFail(operation: number): void;
  40799. /**
  40800. * Sets the stencil operation to use when stencil passes
  40801. * @param operation defines the stencil operation to use when stencil passes
  40802. */
  40803. setStencilOperationPass(operation: number): void;
  40804. /**
  40805. * Sets a boolean indicating if the dithering state is enabled or disabled
  40806. * @param value defines the dithering state
  40807. */
  40808. setDitheringState(value: boolean): void;
  40809. /**
  40810. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  40811. * @param value defines the rasterizer state
  40812. */
  40813. setRasterizerState(value: boolean): void;
  40814. /**
  40815. * Gets the current depth function
  40816. * @returns a number defining the depth function
  40817. */
  40818. getDepthFunction(): Nullable<number>;
  40819. /**
  40820. * Sets the current depth function
  40821. * @param depthFunc defines the function to use
  40822. */
  40823. setDepthFunction(depthFunc: number): void;
  40824. /**
  40825. * Sets the current depth function to GREATER
  40826. */
  40827. setDepthFunctionToGreater(): void;
  40828. /**
  40829. * Sets the current depth function to GEQUAL
  40830. */
  40831. setDepthFunctionToGreaterOrEqual(): void;
  40832. /**
  40833. * Sets the current depth function to LESS
  40834. */
  40835. setDepthFunctionToLess(): void;
  40836. /**
  40837. * Sets the current depth function to LEQUAL
  40838. */
  40839. setDepthFunctionToLessOrEqual(): void;
  40840. private _cachedStencilBuffer;
  40841. private _cachedStencilFunction;
  40842. private _cachedStencilMask;
  40843. private _cachedStencilOperationPass;
  40844. private _cachedStencilOperationFail;
  40845. private _cachedStencilOperationDepthFail;
  40846. private _cachedStencilReference;
  40847. /**
  40848. * Caches the the state of the stencil buffer
  40849. */
  40850. cacheStencilState(): void;
  40851. /**
  40852. * Restores the state of the stencil buffer
  40853. */
  40854. restoreStencilState(): void;
  40855. /**
  40856. * Directly set the WebGL Viewport
  40857. * @param x defines the x coordinate of the viewport (in screen space)
  40858. * @param y defines the y coordinate of the viewport (in screen space)
  40859. * @param width defines the width of the viewport (in screen space)
  40860. * @param height defines the height of the viewport (in screen space)
  40861. * @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
  40862. */
  40863. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  40864. /**
  40865. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  40866. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  40867. * @param y defines the y-coordinate of the corner of the clear rectangle
  40868. * @param width defines the width of the clear rectangle
  40869. * @param height defines the height of the clear rectangle
  40870. * @param clearColor defines the clear color
  40871. */
  40872. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  40873. /**
  40874. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  40875. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  40876. * @param y defines the y-coordinate of the corner of the clear rectangle
  40877. * @param width defines the width of the clear rectangle
  40878. * @param height defines the height of the clear rectangle
  40879. */
  40880. enableScissor(x: number, y: number, width: number, height: number): void;
  40881. /**
  40882. * Disable previously set scissor test rectangle
  40883. */
  40884. disableScissor(): void;
  40885. protected _reportDrawCall(): void;
  40886. /**
  40887. * Initializes a webVR display and starts listening to display change events
  40888. * The onVRDisplayChangedObservable will be notified upon these changes
  40889. * @returns The onVRDisplayChangedObservable
  40890. */
  40891. initWebVR(): Observable<IDisplayChangedEventArgs>;
  40892. /** @hidden */
  40893. _prepareVRComponent(): void;
  40894. /** @hidden */
  40895. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  40896. /** @hidden */
  40897. _submitVRFrame(): void;
  40898. /**
  40899. * Call this function to leave webVR mode
  40900. * Will do nothing if webVR is not supported or if there is no webVR device
  40901. * @see https://doc.babylonjs.com/how_to/webvr_camera
  40902. */
  40903. disableVR(): void;
  40904. /**
  40905. * Gets a boolean indicating that the system is in VR mode and is presenting
  40906. * @returns true if VR mode is engaged
  40907. */
  40908. isVRPresenting(): boolean;
  40909. /** @hidden */
  40910. _requestVRFrame(): void;
  40911. /** @hidden */
  40912. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  40913. /**
  40914. * Gets the source code of the vertex shader associated with a specific webGL program
  40915. * @param program defines the program to use
  40916. * @returns a string containing the source code of the vertex shader associated with the program
  40917. */
  40918. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  40919. /**
  40920. * Gets the source code of the fragment shader associated with a specific webGL program
  40921. * @param program defines the program to use
  40922. * @returns a string containing the source code of the fragment shader associated with the program
  40923. */
  40924. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  40925. /**
  40926. * Sets a depth stencil texture from a render target to the according uniform.
  40927. * @param channel The texture channel
  40928. * @param uniform The uniform to set
  40929. * @param texture The render target texture containing the depth stencil texture to apply
  40930. */
  40931. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  40932. /**
  40933. * Sets a texture to the webGL context from a postprocess
  40934. * @param channel defines the channel to use
  40935. * @param postProcess defines the source postprocess
  40936. */
  40937. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  40938. /**
  40939. * Binds the output of the passed in post process to the texture channel specified
  40940. * @param channel The channel the texture should be bound to
  40941. * @param postProcess The post process which's output should be bound
  40942. */
  40943. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  40944. protected _rebuildBuffers(): void;
  40945. /** @hidden */
  40946. _renderFrame(): void;
  40947. _renderLoop(): void;
  40948. /** @hidden */
  40949. _renderViews(): boolean;
  40950. /**
  40951. * Toggle full screen mode
  40952. * @param requestPointerLock defines if a pointer lock should be requested from the user
  40953. */
  40954. switchFullscreen(requestPointerLock: boolean): void;
  40955. /**
  40956. * Enters full screen mode
  40957. * @param requestPointerLock defines if a pointer lock should be requested from the user
  40958. */
  40959. enterFullscreen(requestPointerLock: boolean): void;
  40960. /**
  40961. * Exits full screen mode
  40962. */
  40963. exitFullscreen(): void;
  40964. /**
  40965. * Enters Pointerlock mode
  40966. */
  40967. enterPointerlock(): void;
  40968. /**
  40969. * Exits Pointerlock mode
  40970. */
  40971. exitPointerlock(): void;
  40972. /**
  40973. * Begin a new frame
  40974. */
  40975. beginFrame(): void;
  40976. /**
  40977. * Enf the current frame
  40978. */
  40979. endFrame(): void;
  40980. resize(): void;
  40981. /**
  40982. * Force a specific size of the canvas
  40983. * @param width defines the new canvas' width
  40984. * @param height defines the new canvas' height
  40985. * @returns true if the size was changed
  40986. */
  40987. setSize(width: number, height: number): boolean;
  40988. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  40989. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  40990. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  40991. _releaseTexture(texture: InternalTexture): void;
  40992. /**
  40993. * @hidden
  40994. * Rescales a texture
  40995. * @param source input texutre
  40996. * @param destination destination texture
  40997. * @param scene scene to use to render the resize
  40998. * @param internalFormat format to use when resizing
  40999. * @param onComplete callback to be called when resize has completed
  41000. */
  41001. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  41002. /**
  41003. * Gets the current framerate
  41004. * @returns a number representing the framerate
  41005. */
  41006. getFps(): number;
  41007. /**
  41008. * Gets the time spent between current and previous frame
  41009. * @returns a number representing the delta time in ms
  41010. */
  41011. getDeltaTime(): number;
  41012. private _measureFps;
  41013. /** @hidden */
  41014. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  41015. /**
  41016. * Updates the sample count of a render target texture
  41017. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  41018. * @param texture defines the texture to update
  41019. * @param samples defines the sample count to set
  41020. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  41021. */
  41022. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  41023. /**
  41024. * Updates a depth texture Comparison Mode and Function.
  41025. * If the comparison Function is equal to 0, the mode will be set to none.
  41026. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  41027. * @param texture The texture to set the comparison function for
  41028. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  41029. */
  41030. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  41031. /**
  41032. * Creates a webGL buffer to use with instanciation
  41033. * @param capacity defines the size of the buffer
  41034. * @returns the webGL buffer
  41035. */
  41036. createInstancesBuffer(capacity: number): DataBuffer;
  41037. /**
  41038. * Delete a webGL buffer used with instanciation
  41039. * @param buffer defines the webGL buffer to delete
  41040. */
  41041. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  41042. private _clientWaitAsync;
  41043. /** @hidden */
  41044. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  41045. dispose(): void;
  41046. private _disableTouchAction;
  41047. /**
  41048. * Display the loading screen
  41049. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41050. */
  41051. displayLoadingUI(): void;
  41052. /**
  41053. * Hide the loading screen
  41054. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41055. */
  41056. hideLoadingUI(): void;
  41057. /**
  41058. * Gets the current loading screen object
  41059. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41060. */
  41061. get loadingScreen(): ILoadingScreen;
  41062. /**
  41063. * Sets the current loading screen object
  41064. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41065. */
  41066. set loadingScreen(loadingScreen: ILoadingScreen);
  41067. /**
  41068. * Sets the current loading screen text
  41069. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41070. */
  41071. set loadingUIText(text: string);
  41072. /**
  41073. * Sets the current loading screen background color
  41074. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  41075. */
  41076. set loadingUIBackgroundColor(color: string);
  41077. /** Pointerlock and fullscreen */
  41078. /**
  41079. * Ask the browser to promote the current element to pointerlock mode
  41080. * @param element defines the DOM element to promote
  41081. */
  41082. static _RequestPointerlock(element: HTMLElement): void;
  41083. /**
  41084. * Asks the browser to exit pointerlock mode
  41085. */
  41086. static _ExitPointerlock(): void;
  41087. /**
  41088. * Ask the browser to promote the current element to fullscreen rendering mode
  41089. * @param element defines the DOM element to promote
  41090. */
  41091. static _RequestFullscreen(element: HTMLElement): void;
  41092. /**
  41093. * Asks the browser to exit fullscreen mode
  41094. */
  41095. static _ExitFullscreen(): void;
  41096. }
  41097. }
  41098. declare module BABYLON {
  41099. /**
  41100. * The engine store class is responsible to hold all the instances of Engine and Scene created
  41101. * during the life time of the application.
  41102. */
  41103. export class EngineStore {
  41104. /** Gets the list of created engines */
  41105. static Instances: Engine[];
  41106. /** @hidden */
  41107. static _LastCreatedScene: Nullable<Scene>;
  41108. /**
  41109. * Gets the latest created engine
  41110. */
  41111. static get LastCreatedEngine(): Nullable<Engine>;
  41112. /**
  41113. * Gets the latest created scene
  41114. */
  41115. static get LastCreatedScene(): Nullable<Scene>;
  41116. /**
  41117. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  41118. * @ignorenaming
  41119. */
  41120. static UseFallbackTexture: boolean;
  41121. /**
  41122. * Texture content used if a texture cannot loaded
  41123. * @ignorenaming
  41124. */
  41125. static FallbackTexture: string;
  41126. }
  41127. }
  41128. declare module BABYLON {
  41129. /**
  41130. * Helper class that provides a small promise polyfill
  41131. */
  41132. export class PromisePolyfill {
  41133. /**
  41134. * Static function used to check if the polyfill is required
  41135. * If this is the case then the function will inject the polyfill to window.Promise
  41136. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  41137. */
  41138. static Apply(force?: boolean): void;
  41139. }
  41140. }
  41141. declare module BABYLON {
  41142. /**
  41143. * Interface for screenshot methods with describe argument called `size` as object with options
  41144. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  41145. */
  41146. export interface IScreenshotSize {
  41147. /**
  41148. * number in pixels for canvas height
  41149. */
  41150. height?: number;
  41151. /**
  41152. * multiplier allowing render at a higher or lower resolution
  41153. * If value is defined then height and width will be ignored and taken from camera
  41154. */
  41155. precision?: number;
  41156. /**
  41157. * number in pixels for canvas width
  41158. */
  41159. width?: number;
  41160. }
  41161. }
  41162. declare module BABYLON {
  41163. interface IColor4Like {
  41164. r: float;
  41165. g: float;
  41166. b: float;
  41167. a: float;
  41168. }
  41169. /**
  41170. * Class containing a set of static utilities functions
  41171. */
  41172. export class Tools {
  41173. /**
  41174. * Gets or sets the base URL to use to load assets
  41175. */
  41176. static get BaseUrl(): string;
  41177. static set BaseUrl(value: string);
  41178. /**
  41179. * Enable/Disable Custom HTTP Request Headers globally.
  41180. * default = false
  41181. * @see CustomRequestHeaders
  41182. */
  41183. static UseCustomRequestHeaders: boolean;
  41184. /**
  41185. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  41186. * i.e. when loading files, where the server/service expects an Authorization header
  41187. */
  41188. static CustomRequestHeaders: {
  41189. [key: string]: string;
  41190. };
  41191. /**
  41192. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  41193. */
  41194. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  41195. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  41196. /**
  41197. * Default behaviour for cors in the application.
  41198. * It can be a string if the expected behavior is identical in the entire app.
  41199. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  41200. */
  41201. static get CorsBehavior(): string | ((url: string | string[]) => string);
  41202. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  41203. /**
  41204. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  41205. * @ignorenaming
  41206. */
  41207. static get UseFallbackTexture(): boolean;
  41208. static set UseFallbackTexture(value: boolean);
  41209. /**
  41210. * Use this object to register external classes like custom textures or material
  41211. * to allow the laoders to instantiate them
  41212. */
  41213. static get RegisteredExternalClasses(): {
  41214. [key: string]: Object;
  41215. };
  41216. static set RegisteredExternalClasses(classes: {
  41217. [key: string]: Object;
  41218. });
  41219. /**
  41220. * Texture content used if a texture cannot loaded
  41221. * @ignorenaming
  41222. */
  41223. static get fallbackTexture(): string;
  41224. static set fallbackTexture(value: string);
  41225. /**
  41226. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  41227. * @param u defines the coordinate on X axis
  41228. * @param v defines the coordinate on Y axis
  41229. * @param width defines the width of the source data
  41230. * @param height defines the height of the source data
  41231. * @param pixels defines the source byte array
  41232. * @param color defines the output color
  41233. */
  41234. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  41235. /**
  41236. * Interpolates between a and b via alpha
  41237. * @param a The lower value (returned when alpha = 0)
  41238. * @param b The upper value (returned when alpha = 1)
  41239. * @param alpha The interpolation-factor
  41240. * @return The mixed value
  41241. */
  41242. static Mix(a: number, b: number, alpha: number): number;
  41243. /**
  41244. * Tries to instantiate a new object from a given class name
  41245. * @param className defines the class name to instantiate
  41246. * @returns the new object or null if the system was not able to do the instantiation
  41247. */
  41248. static Instantiate(className: string): any;
  41249. /**
  41250. * Provides a slice function that will work even on IE
  41251. * @param data defines the array to slice
  41252. * @param start defines the start of the data (optional)
  41253. * @param end defines the end of the data (optional)
  41254. * @returns the new sliced array
  41255. */
  41256. static Slice<T>(data: T, start?: number, end?: number): T;
  41257. /**
  41258. * Polyfill for setImmediate
  41259. * @param action defines the action to execute after the current execution block
  41260. */
  41261. static SetImmediate(action: () => void): void;
  41262. /**
  41263. * Function indicating if a number is an exponent of 2
  41264. * @param value defines the value to test
  41265. * @returns true if the value is an exponent of 2
  41266. */
  41267. static IsExponentOfTwo(value: number): boolean;
  41268. private static _tmpFloatArray;
  41269. /**
  41270. * Returns the nearest 32-bit single precision float representation of a Number
  41271. * @param value A Number. If the parameter is of a different type, it will get converted
  41272. * to a number or to NaN if it cannot be converted
  41273. * @returns number
  41274. */
  41275. static FloatRound(value: number): number;
  41276. /**
  41277. * Extracts the filename from a path
  41278. * @param path defines the path to use
  41279. * @returns the filename
  41280. */
  41281. static GetFilename(path: string): string;
  41282. /**
  41283. * Extracts the "folder" part of a path (everything before the filename).
  41284. * @param uri The URI to extract the info from
  41285. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  41286. * @returns The "folder" part of the path
  41287. */
  41288. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  41289. /**
  41290. * Extracts text content from a DOM element hierarchy
  41291. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  41292. */
  41293. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  41294. /**
  41295. * Convert an angle in radians to degrees
  41296. * @param angle defines the angle to convert
  41297. * @returns the angle in degrees
  41298. */
  41299. static ToDegrees(angle: number): number;
  41300. /**
  41301. * Convert an angle in degrees to radians
  41302. * @param angle defines the angle to convert
  41303. * @returns the angle in radians
  41304. */
  41305. static ToRadians(angle: number): number;
  41306. /**
  41307. * Returns an array if obj is not an array
  41308. * @param obj defines the object to evaluate as an array
  41309. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  41310. * @returns either obj directly if obj is an array or a new array containing obj
  41311. */
  41312. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  41313. /**
  41314. * Gets the pointer prefix to use
  41315. * @param engine defines the engine we are finding the prefix for
  41316. * @returns "pointer" if touch is enabled. Else returns "mouse"
  41317. */
  41318. static GetPointerPrefix(engine: Engine): string;
  41319. /**
  41320. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  41321. * @param url define the url we are trying
  41322. * @param element define the dom element where to configure the cors policy
  41323. */
  41324. static SetCorsBehavior(url: string | string[], element: {
  41325. crossOrigin: string | null;
  41326. }): void;
  41327. /**
  41328. * Removes unwanted characters from an url
  41329. * @param url defines the url to clean
  41330. * @returns the cleaned url
  41331. */
  41332. static CleanUrl(url: string): string;
  41333. /**
  41334. * Gets or sets a function used to pre-process url before using them to load assets
  41335. */
  41336. static get PreprocessUrl(): (url: string) => string;
  41337. static set PreprocessUrl(processor: (url: string) => string);
  41338. /**
  41339. * Loads an image as an HTMLImageElement.
  41340. * @param input url string, ArrayBuffer, or Blob to load
  41341. * @param onLoad callback called when the image successfully loads
  41342. * @param onError callback called when the image fails to load
  41343. * @param offlineProvider offline provider for caching
  41344. * @param mimeType optional mime type
  41345. * @returns the HTMLImageElement of the loaded image
  41346. */
  41347. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  41348. /**
  41349. * Loads a file from a url
  41350. * @param url url string, ArrayBuffer, or Blob to load
  41351. * @param onSuccess callback called when the file successfully loads
  41352. * @param onProgress callback called while file is loading (if the server supports this mode)
  41353. * @param offlineProvider defines the offline provider for caching
  41354. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  41355. * @param onError callback called when the file fails to load
  41356. * @returns a file request object
  41357. */
  41358. 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;
  41359. /**
  41360. * Loads a file from a url
  41361. * @param url the file url to load
  41362. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  41363. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  41364. */
  41365. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  41366. /**
  41367. * Load a script (identified by an url). When the url returns, the
  41368. * content of this file is added into a new script element, attached to the DOM (body element)
  41369. * @param scriptUrl defines the url of the script to laod
  41370. * @param onSuccess defines the callback called when the script is loaded
  41371. * @param onError defines the callback to call if an error occurs
  41372. * @param scriptId defines the id of the script element
  41373. */
  41374. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  41375. /**
  41376. * Load an asynchronous script (identified by an url). When the url returns, the
  41377. * content of this file is added into a new script element, attached to the DOM (body element)
  41378. * @param scriptUrl defines the url of the script to laod
  41379. * @param scriptId defines the id of the script element
  41380. * @returns a promise request object
  41381. */
  41382. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  41383. /**
  41384. * Loads a file from a blob
  41385. * @param fileToLoad defines the blob to use
  41386. * @param callback defines the callback to call when data is loaded
  41387. * @param progressCallback defines the callback to call during loading process
  41388. * @returns a file request object
  41389. */
  41390. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  41391. /**
  41392. * Reads a file from a File object
  41393. * @param file defines the file to load
  41394. * @param onSuccess defines the callback to call when data is loaded
  41395. * @param onProgress defines the callback to call during loading process
  41396. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  41397. * @param onError defines the callback to call when an error occurs
  41398. * @returns a file request object
  41399. */
  41400. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  41401. /**
  41402. * Creates a data url from a given string content
  41403. * @param content defines the content to convert
  41404. * @returns the new data url link
  41405. */
  41406. static FileAsURL(content: string): string;
  41407. /**
  41408. * Format the given number to a specific decimal format
  41409. * @param value defines the number to format
  41410. * @param decimals defines the number of decimals to use
  41411. * @returns the formatted string
  41412. */
  41413. static Format(value: number, decimals?: number): string;
  41414. /**
  41415. * Tries to copy an object by duplicating every property
  41416. * @param source defines the source object
  41417. * @param destination defines the target object
  41418. * @param doNotCopyList defines a list of properties to avoid
  41419. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  41420. */
  41421. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  41422. /**
  41423. * Gets a boolean indicating if the given object has no own property
  41424. * @param obj defines the object to test
  41425. * @returns true if object has no own property
  41426. */
  41427. static IsEmpty(obj: any): boolean;
  41428. /**
  41429. * Function used to register events at window level
  41430. * @param windowElement defines the Window object to use
  41431. * @param events defines the events to register
  41432. */
  41433. static RegisterTopRootEvents(windowElement: Window, events: {
  41434. name: string;
  41435. handler: Nullable<(e: FocusEvent) => any>;
  41436. }[]): void;
  41437. /**
  41438. * Function used to unregister events from window level
  41439. * @param windowElement defines the Window object to use
  41440. * @param events defines the events to unregister
  41441. */
  41442. static UnregisterTopRootEvents(windowElement: Window, events: {
  41443. name: string;
  41444. handler: Nullable<(e: FocusEvent) => any>;
  41445. }[]): void;
  41446. /**
  41447. * @ignore
  41448. */
  41449. static _ScreenshotCanvas: HTMLCanvasElement;
  41450. /**
  41451. * Dumps the current bound framebuffer
  41452. * @param width defines the rendering width
  41453. * @param height defines the rendering height
  41454. * @param engine defines the hosting engine
  41455. * @param successCallback defines the callback triggered once the data are available
  41456. * @param mimeType defines the mime type of the result
  41457. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  41458. */
  41459. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  41460. /**
  41461. * Converts the canvas data to blob.
  41462. * This acts as a polyfill for browsers not supporting the to blob function.
  41463. * @param canvas Defines the canvas to extract the data from
  41464. * @param successCallback Defines the callback triggered once the data are available
  41465. * @param mimeType Defines the mime type of the result
  41466. */
  41467. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  41468. /**
  41469. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  41470. * @param successCallback defines the callback triggered once the data are available
  41471. * @param mimeType defines the mime type of the result
  41472. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  41473. */
  41474. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  41475. /**
  41476. * Downloads a blob in the browser
  41477. * @param blob defines the blob to download
  41478. * @param fileName defines the name of the downloaded file
  41479. */
  41480. static Download(blob: Blob, fileName: string): void;
  41481. /**
  41482. * Captures a screenshot of the current rendering
  41483. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  41484. * @param engine defines the rendering engine
  41485. * @param camera defines the source camera
  41486. * @param size This parameter can be set to a single number or to an object with the
  41487. * following (optional) properties: precision, width, height. If a single number is passed,
  41488. * it will be used for both width and height. If an object is passed, the screenshot size
  41489. * will be derived from the parameters. The precision property is a multiplier allowing
  41490. * rendering at a higher or lower resolution
  41491. * @param successCallback defines the callback receives a single parameter which contains the
  41492. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  41493. * src parameter of an <img> to display it
  41494. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  41495. * Check your browser for supported MIME types
  41496. */
  41497. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  41498. /**
  41499. * Captures a screenshot of the current rendering
  41500. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  41501. * @param engine defines the rendering engine
  41502. * @param camera defines the source camera
  41503. * @param size This parameter can be set to a single number or to an object with the
  41504. * following (optional) properties: precision, width, height. If a single number is passed,
  41505. * it will be used for both width and height. If an object is passed, the screenshot size
  41506. * will be derived from the parameters. The precision property is a multiplier allowing
  41507. * rendering at a higher or lower resolution
  41508. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  41509. * Check your browser for supported MIME types
  41510. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  41511. * to the src parameter of an <img> to display it
  41512. */
  41513. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  41514. /**
  41515. * Generates an image screenshot from the specified camera.
  41516. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  41517. * @param engine The engine to use for rendering
  41518. * @param camera The camera to use for rendering
  41519. * @param size This parameter can be set to a single number or to an object with the
  41520. * following (optional) properties: precision, width, height. If a single number is passed,
  41521. * it will be used for both width and height. If an object is passed, the screenshot size
  41522. * will be derived from the parameters. The precision property is a multiplier allowing
  41523. * rendering at a higher or lower resolution
  41524. * @param successCallback The callback receives a single parameter which contains the
  41525. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  41526. * src parameter of an <img> to display it
  41527. * @param mimeType The MIME type of the screenshot image (default: image/png).
  41528. * Check your browser for supported MIME types
  41529. * @param samples Texture samples (default: 1)
  41530. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  41531. * @param fileName A name for for the downloaded file.
  41532. */
  41533. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  41534. /**
  41535. * Generates an image screenshot from the specified camera.
  41536. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  41537. * @param engine The engine to use for rendering
  41538. * @param camera The camera to use for rendering
  41539. * @param size This parameter can be set to a single number or to an object with the
  41540. * following (optional) properties: precision, width, height. If a single number is passed,
  41541. * it will be used for both width and height. If an object is passed, the screenshot size
  41542. * will be derived from the parameters. The precision property is a multiplier allowing
  41543. * rendering at a higher or lower resolution
  41544. * @param mimeType The MIME type of the screenshot image (default: image/png).
  41545. * Check your browser for supported MIME types
  41546. * @param samples Texture samples (default: 1)
  41547. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  41548. * @param fileName A name for for the downloaded file.
  41549. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  41550. * to the src parameter of an <img> to display it
  41551. */
  41552. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  41553. /**
  41554. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  41555. * Be aware Math.random() could cause collisions, but:
  41556. * "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"
  41557. * @returns a pseudo random id
  41558. */
  41559. static RandomId(): string;
  41560. /**
  41561. * Test if the given uri is a base64 string
  41562. * @param uri The uri to test
  41563. * @return True if the uri is a base64 string or false otherwise
  41564. */
  41565. static IsBase64(uri: string): boolean;
  41566. /**
  41567. * Decode the given base64 uri.
  41568. * @param uri The uri to decode
  41569. * @return The decoded base64 data.
  41570. */
  41571. static DecodeBase64(uri: string): ArrayBuffer;
  41572. /**
  41573. * Gets the absolute url.
  41574. * @param url the input url
  41575. * @return the absolute url
  41576. */
  41577. static GetAbsoluteUrl(url: string): string;
  41578. /**
  41579. * No log
  41580. */
  41581. static readonly NoneLogLevel: number;
  41582. /**
  41583. * Only message logs
  41584. */
  41585. static readonly MessageLogLevel: number;
  41586. /**
  41587. * Only warning logs
  41588. */
  41589. static readonly WarningLogLevel: number;
  41590. /**
  41591. * Only error logs
  41592. */
  41593. static readonly ErrorLogLevel: number;
  41594. /**
  41595. * All logs
  41596. */
  41597. static readonly AllLogLevel: number;
  41598. /**
  41599. * Gets a value indicating the number of loading errors
  41600. * @ignorenaming
  41601. */
  41602. static get errorsCount(): number;
  41603. /**
  41604. * Callback called when a new log is added
  41605. */
  41606. static OnNewCacheEntry: (entry: string) => void;
  41607. /**
  41608. * Log a message to the console
  41609. * @param message defines the message to log
  41610. */
  41611. static Log(message: string): void;
  41612. /**
  41613. * Write a warning message to the console
  41614. * @param message defines the message to log
  41615. */
  41616. static Warn(message: string): void;
  41617. /**
  41618. * Write an error message to the console
  41619. * @param message defines the message to log
  41620. */
  41621. static Error(message: string): void;
  41622. /**
  41623. * Gets current log cache (list of logs)
  41624. */
  41625. static get LogCache(): string;
  41626. /**
  41627. * Clears the log cache
  41628. */
  41629. static ClearLogCache(): void;
  41630. /**
  41631. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  41632. */
  41633. static set LogLevels(level: number);
  41634. /**
  41635. * Checks if the window object exists
  41636. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  41637. */
  41638. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  41639. /**
  41640. * No performance log
  41641. */
  41642. static readonly PerformanceNoneLogLevel: number;
  41643. /**
  41644. * Use user marks to log performance
  41645. */
  41646. static readonly PerformanceUserMarkLogLevel: number;
  41647. /**
  41648. * Log performance to the console
  41649. */
  41650. static readonly PerformanceConsoleLogLevel: number;
  41651. private static _performance;
  41652. /**
  41653. * Sets the current performance log level
  41654. */
  41655. static set PerformanceLogLevel(level: number);
  41656. private static _StartPerformanceCounterDisabled;
  41657. private static _EndPerformanceCounterDisabled;
  41658. private static _StartUserMark;
  41659. private static _EndUserMark;
  41660. private static _StartPerformanceConsole;
  41661. private static _EndPerformanceConsole;
  41662. /**
  41663. * Starts a performance counter
  41664. */
  41665. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  41666. /**
  41667. * Ends a specific performance coutner
  41668. */
  41669. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  41670. /**
  41671. * Gets either window.performance.now() if supported or Date.now() else
  41672. */
  41673. static get Now(): number;
  41674. /**
  41675. * This method will return the name of the class used to create the instance of the given object.
  41676. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  41677. * @param object the object to get the class name from
  41678. * @param isType defines if the object is actually a type
  41679. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  41680. */
  41681. static GetClassName(object: any, isType?: boolean): string;
  41682. /**
  41683. * Gets the first element of an array satisfying a given predicate
  41684. * @param array defines the array to browse
  41685. * @param predicate defines the predicate to use
  41686. * @returns null if not found or the element
  41687. */
  41688. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  41689. /**
  41690. * This method will return the name of the full name of the class, including its owning module (if any).
  41691. * 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).
  41692. * @param object the object to get the class name from
  41693. * @param isType defines if the object is actually a type
  41694. * @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.
  41695. * @ignorenaming
  41696. */
  41697. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  41698. /**
  41699. * Returns a promise that resolves after the given amount of time.
  41700. * @param delay Number of milliseconds to delay
  41701. * @returns Promise that resolves after the given amount of time
  41702. */
  41703. static DelayAsync(delay: number): Promise<void>;
  41704. /**
  41705. * Utility function to detect if the current user agent is Safari
  41706. * @returns whether or not the current user agent is safari
  41707. */
  41708. static IsSafari(): boolean;
  41709. }
  41710. /**
  41711. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  41712. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  41713. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  41714. * @param name The name of the class, case should be preserved
  41715. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  41716. */
  41717. export function className(name: string, module?: string): (target: Object) => void;
  41718. /**
  41719. * An implementation of a loop for asynchronous functions.
  41720. */
  41721. export class AsyncLoop {
  41722. /**
  41723. * Defines the number of iterations for the loop
  41724. */
  41725. iterations: number;
  41726. /**
  41727. * Defines the current index of the loop.
  41728. */
  41729. index: number;
  41730. private _done;
  41731. private _fn;
  41732. private _successCallback;
  41733. /**
  41734. * Constructor.
  41735. * @param iterations the number of iterations.
  41736. * @param func the function to run each iteration
  41737. * @param successCallback the callback that will be called upon succesful execution
  41738. * @param offset starting offset.
  41739. */
  41740. constructor(
  41741. /**
  41742. * Defines the number of iterations for the loop
  41743. */
  41744. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  41745. /**
  41746. * Execute the next iteration. Must be called after the last iteration was finished.
  41747. */
  41748. executeNext(): void;
  41749. /**
  41750. * Break the loop and run the success callback.
  41751. */
  41752. breakLoop(): void;
  41753. /**
  41754. * Create and run an async loop.
  41755. * @param iterations the number of iterations.
  41756. * @param fn the function to run each iteration
  41757. * @param successCallback the callback that will be called upon succesful execution
  41758. * @param offset starting offset.
  41759. * @returns the created async loop object
  41760. */
  41761. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  41762. /**
  41763. * A for-loop that will run a given number of iterations synchronous and the rest async.
  41764. * @param iterations total number of iterations
  41765. * @param syncedIterations number of synchronous iterations in each async iteration.
  41766. * @param fn the function to call each iteration.
  41767. * @param callback a success call back that will be called when iterating stops.
  41768. * @param breakFunction a break condition (optional)
  41769. * @param timeout timeout settings for the setTimeout function. default - 0.
  41770. * @returns the created async loop object
  41771. */
  41772. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  41773. }
  41774. }
  41775. declare module BABYLON {
  41776. /**
  41777. * This class implement a typical dictionary using a string as key and the generic type T as value.
  41778. * The underlying implementation relies on an associative array to ensure the best performances.
  41779. * The value can be anything including 'null' but except 'undefined'
  41780. */
  41781. export class StringDictionary<T> {
  41782. /**
  41783. * This will clear this dictionary and copy the content from the 'source' one.
  41784. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  41785. * @param source the dictionary to take the content from and copy to this dictionary
  41786. */
  41787. copyFrom(source: StringDictionary<T>): void;
  41788. /**
  41789. * Get a value based from its key
  41790. * @param key the given key to get the matching value from
  41791. * @return the value if found, otherwise undefined is returned
  41792. */
  41793. get(key: string): T | undefined;
  41794. /**
  41795. * Get a value from its key or add it if it doesn't exist.
  41796. * This method will ensure you that a given key/data will be present in the dictionary.
  41797. * @param key the given key to get the matching value from
  41798. * @param factory the factory that will create the value if the key is not present in the dictionary.
  41799. * The factory will only be invoked if there's no data for the given key.
  41800. * @return the value corresponding to the key.
  41801. */
  41802. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  41803. /**
  41804. * Get a value from its key if present in the dictionary otherwise add it
  41805. * @param key the key to get the value from
  41806. * @param val if there's no such key/value pair in the dictionary add it with this value
  41807. * @return the value corresponding to the key
  41808. */
  41809. getOrAdd(key: string, val: T): T;
  41810. /**
  41811. * Check if there's a given key in the dictionary
  41812. * @param key the key to check for
  41813. * @return true if the key is present, false otherwise
  41814. */
  41815. contains(key: string): boolean;
  41816. /**
  41817. * Add a new key and its corresponding value
  41818. * @param key the key to add
  41819. * @param value the value corresponding to the key
  41820. * @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
  41821. */
  41822. add(key: string, value: T): boolean;
  41823. /**
  41824. * Update a specific value associated to a key
  41825. * @param key defines the key to use
  41826. * @param value defines the value to store
  41827. * @returns true if the value was updated (or false if the key was not found)
  41828. */
  41829. set(key: string, value: T): boolean;
  41830. /**
  41831. * Get the element of the given key and remove it from the dictionary
  41832. * @param key defines the key to search
  41833. * @returns the value associated with the key or null if not found
  41834. */
  41835. getAndRemove(key: string): Nullable<T>;
  41836. /**
  41837. * Remove a key/value from the dictionary.
  41838. * @param key the key to remove
  41839. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  41840. */
  41841. remove(key: string): boolean;
  41842. /**
  41843. * Clear the whole content of the dictionary
  41844. */
  41845. clear(): void;
  41846. /**
  41847. * Gets the current count
  41848. */
  41849. get count(): number;
  41850. /**
  41851. * Execute a callback on each key/val of the dictionary.
  41852. * Note that you can remove any element in this dictionary in the callback implementation
  41853. * @param callback the callback to execute on a given key/value pair
  41854. */
  41855. forEach(callback: (key: string, val: T) => void): void;
  41856. /**
  41857. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  41858. * If the callback returns null or undefined the method will iterate to the next key/value pair
  41859. * Note that you can remove any element in this dictionary in the callback implementation
  41860. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  41861. * @returns the first item
  41862. */
  41863. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  41864. private _count;
  41865. private _data;
  41866. }
  41867. }
  41868. declare module BABYLON {
  41869. /** @hidden */
  41870. export interface ICollisionCoordinator {
  41871. createCollider(): Collider;
  41872. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  41873. init(scene: Scene): void;
  41874. }
  41875. /** @hidden */
  41876. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  41877. private _scene;
  41878. private _scaledPosition;
  41879. private _scaledVelocity;
  41880. private _finalPosition;
  41881. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  41882. createCollider(): Collider;
  41883. init(scene: Scene): void;
  41884. private _collideWithWorld;
  41885. }
  41886. }
  41887. declare module BABYLON {
  41888. /**
  41889. * Class used to manage all inputs for the scene.
  41890. */
  41891. export class InputManager {
  41892. /** The distance in pixel that you have to move to prevent some events */
  41893. static DragMovementThreshold: number;
  41894. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  41895. static LongPressDelay: number;
  41896. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  41897. static DoubleClickDelay: number;
  41898. /** If you need to check double click without raising a single click at first click, enable this flag */
  41899. static ExclusiveDoubleClickMode: boolean;
  41900. /** 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. */
  41901. private _alreadyAttached;
  41902. private _wheelEventName;
  41903. private _onPointerMove;
  41904. private _onPointerDown;
  41905. private _onPointerUp;
  41906. private _initClickEvent;
  41907. private _initActionManager;
  41908. private _delayedSimpleClick;
  41909. private _delayedSimpleClickTimeout;
  41910. private _previousDelayedSimpleClickTimeout;
  41911. private _meshPickProceed;
  41912. private _previousButtonPressed;
  41913. private _currentPickResult;
  41914. private _previousPickResult;
  41915. private _totalPointersPressed;
  41916. private _doubleClickOccured;
  41917. private _pointerOverMesh;
  41918. private _pickedDownMesh;
  41919. private _pickedUpMesh;
  41920. private _pointerX;
  41921. private _pointerY;
  41922. private _unTranslatedPointerX;
  41923. private _unTranslatedPointerY;
  41924. private _startingPointerPosition;
  41925. private _previousStartingPointerPosition;
  41926. private _startingPointerTime;
  41927. private _previousStartingPointerTime;
  41928. private _pointerCaptures;
  41929. private _meshUnderPointerId;
  41930. private _onKeyDown;
  41931. private _onKeyUp;
  41932. private _onCanvasFocusObserver;
  41933. private _onCanvasBlurObserver;
  41934. private _scene;
  41935. /**
  41936. * Creates a new InputManager
  41937. * @param scene defines the hosting scene
  41938. */
  41939. constructor(scene: Scene);
  41940. /**
  41941. * Gets the mesh that is currently under the pointer
  41942. */
  41943. get meshUnderPointer(): Nullable<AbstractMesh>;
  41944. /**
  41945. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  41946. * @param pointerId the pointer id to use
  41947. * @returns The mesh under this pointer id or null if not found
  41948. */
  41949. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  41950. /**
  41951. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  41952. */
  41953. get unTranslatedPointer(): Vector2;
  41954. /**
  41955. * Gets or sets the current on-screen X position of the pointer
  41956. */
  41957. get pointerX(): number;
  41958. set pointerX(value: number);
  41959. /**
  41960. * Gets or sets the current on-screen Y position of the pointer
  41961. */
  41962. get pointerY(): number;
  41963. set pointerY(value: number);
  41964. private _updatePointerPosition;
  41965. private _processPointerMove;
  41966. private _setRayOnPointerInfo;
  41967. private _checkPrePointerObservable;
  41968. /**
  41969. * Use this method to simulate a pointer move on a mesh
  41970. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  41971. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  41972. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  41973. */
  41974. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  41975. /**
  41976. * Use this method to simulate a pointer down on a mesh
  41977. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  41978. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  41979. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  41980. */
  41981. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  41982. private _processPointerDown;
  41983. /** @hidden */
  41984. _isPointerSwiping(): boolean;
  41985. /**
  41986. * Use this method to simulate a pointer up on a mesh
  41987. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  41988. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  41989. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  41990. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  41991. */
  41992. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  41993. private _processPointerUp;
  41994. /**
  41995. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  41996. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  41997. * @returns true if the pointer was captured
  41998. */
  41999. isPointerCaptured(pointerId?: number): boolean;
  42000. /**
  42001. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  42002. * @param attachUp defines if you want to attach events to pointerup
  42003. * @param attachDown defines if you want to attach events to pointerdown
  42004. * @param attachMove defines if you want to attach events to pointermove
  42005. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  42006. */
  42007. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  42008. /**
  42009. * Detaches all event handlers
  42010. */
  42011. detachControl(): void;
  42012. /**
  42013. * Force the value of meshUnderPointer
  42014. * @param mesh defines the mesh to use
  42015. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  42016. */
  42017. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  42018. /**
  42019. * Gets the mesh under the pointer
  42020. * @returns a Mesh or null if no mesh is under the pointer
  42021. */
  42022. getPointerOverMesh(): Nullable<AbstractMesh>;
  42023. }
  42024. }
  42025. declare module BABYLON {
  42026. /**
  42027. * This class defines the direct association between an animation and a target
  42028. */
  42029. export class TargetedAnimation {
  42030. /**
  42031. * Animation to perform
  42032. */
  42033. animation: Animation;
  42034. /**
  42035. * Target to animate
  42036. */
  42037. target: any;
  42038. /**
  42039. * Returns the string "TargetedAnimation"
  42040. * @returns "TargetedAnimation"
  42041. */
  42042. getClassName(): string;
  42043. /**
  42044. * Serialize the object
  42045. * @returns the JSON object representing the current entity
  42046. */
  42047. serialize(): any;
  42048. }
  42049. /**
  42050. * Use this class to create coordinated animations on multiple targets
  42051. */
  42052. export class AnimationGroup implements IDisposable {
  42053. /** The name of the animation group */
  42054. name: string;
  42055. private _scene;
  42056. private _targetedAnimations;
  42057. private _animatables;
  42058. private _from;
  42059. private _to;
  42060. private _isStarted;
  42061. private _isPaused;
  42062. private _speedRatio;
  42063. private _loopAnimation;
  42064. private _isAdditive;
  42065. /**
  42066. * Gets or sets the unique id of the node
  42067. */
  42068. uniqueId: number;
  42069. /**
  42070. * This observable will notify when one animation have ended
  42071. */
  42072. onAnimationEndObservable: Observable<TargetedAnimation>;
  42073. /**
  42074. * Observer raised when one animation loops
  42075. */
  42076. onAnimationLoopObservable: Observable<TargetedAnimation>;
  42077. /**
  42078. * Observer raised when all animations have looped
  42079. */
  42080. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  42081. /**
  42082. * This observable will notify when all animations have ended.
  42083. */
  42084. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  42085. /**
  42086. * This observable will notify when all animations have paused.
  42087. */
  42088. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  42089. /**
  42090. * This observable will notify when all animations are playing.
  42091. */
  42092. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  42093. /**
  42094. * Gets the first frame
  42095. */
  42096. get from(): number;
  42097. /**
  42098. * Gets the last frame
  42099. */
  42100. get to(): number;
  42101. /**
  42102. * Define if the animations are started
  42103. */
  42104. get isStarted(): boolean;
  42105. /**
  42106. * Gets a value indicating that the current group is playing
  42107. */
  42108. get isPlaying(): boolean;
  42109. /**
  42110. * Gets or sets the speed ratio to use for all animations
  42111. */
  42112. get speedRatio(): number;
  42113. /**
  42114. * Gets or sets the speed ratio to use for all animations
  42115. */
  42116. set speedRatio(value: number);
  42117. /**
  42118. * Gets or sets if all animations should loop or not
  42119. */
  42120. get loopAnimation(): boolean;
  42121. set loopAnimation(value: boolean);
  42122. /**
  42123. * Gets or sets if all animations should be evaluated additively
  42124. */
  42125. get isAdditive(): boolean;
  42126. set isAdditive(value: boolean);
  42127. /**
  42128. * Gets the targeted animations for this animation group
  42129. */
  42130. get targetedAnimations(): Array<TargetedAnimation>;
  42131. /**
  42132. * returning the list of animatables controlled by this animation group.
  42133. */
  42134. get animatables(): Array<Animatable>;
  42135. /**
  42136. * Gets the list of target animations
  42137. */
  42138. get children(): TargetedAnimation[];
  42139. /**
  42140. * Instantiates a new Animation Group.
  42141. * This helps managing several animations at once.
  42142. * @see https://doc.babylonjs.com/how_to/group
  42143. * @param name Defines the name of the group
  42144. * @param scene Defines the scene the group belongs to
  42145. */
  42146. constructor(
  42147. /** The name of the animation group */
  42148. name: string, scene?: Nullable<Scene>);
  42149. /**
  42150. * Add an animation (with its target) in the group
  42151. * @param animation defines the animation we want to add
  42152. * @param target defines the target of the animation
  42153. * @returns the TargetedAnimation object
  42154. */
  42155. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  42156. /**
  42157. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  42158. * It can add constant keys at begin or end
  42159. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  42160. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  42161. * @returns the animation group
  42162. */
  42163. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  42164. private _animationLoopCount;
  42165. private _animationLoopFlags;
  42166. private _processLoop;
  42167. /**
  42168. * Start all animations on given targets
  42169. * @param loop defines if animations must loop
  42170. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  42171. * @param from defines the from key (optional)
  42172. * @param to defines the to key (optional)
  42173. * @param isAdditive defines the additive state for the resulting animatables (optional)
  42174. * @returns the current animation group
  42175. */
  42176. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  42177. /**
  42178. * Pause all animations
  42179. * @returns the animation group
  42180. */
  42181. pause(): AnimationGroup;
  42182. /**
  42183. * Play all animations to initial state
  42184. * This function will start() the animations if they were not started or will restart() them if they were paused
  42185. * @param loop defines if animations must loop
  42186. * @returns the animation group
  42187. */
  42188. play(loop?: boolean): AnimationGroup;
  42189. /**
  42190. * Reset all animations to initial state
  42191. * @returns the animation group
  42192. */
  42193. reset(): AnimationGroup;
  42194. /**
  42195. * Restart animations from key 0
  42196. * @returns the animation group
  42197. */
  42198. restart(): AnimationGroup;
  42199. /**
  42200. * Stop all animations
  42201. * @returns the animation group
  42202. */
  42203. stop(): AnimationGroup;
  42204. /**
  42205. * Set animation weight for all animatables
  42206. * @param weight defines the weight to use
  42207. * @return the animationGroup
  42208. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  42209. */
  42210. setWeightForAllAnimatables(weight: number): AnimationGroup;
  42211. /**
  42212. * Synchronize and normalize all animatables with a source animatable
  42213. * @param root defines the root animatable to synchronize with
  42214. * @return the animationGroup
  42215. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  42216. */
  42217. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  42218. /**
  42219. * Goes to a specific frame in this animation group
  42220. * @param frame the frame number to go to
  42221. * @return the animationGroup
  42222. */
  42223. goToFrame(frame: number): AnimationGroup;
  42224. /**
  42225. * Dispose all associated resources
  42226. */
  42227. dispose(): void;
  42228. private _checkAnimationGroupEnded;
  42229. /**
  42230. * Clone the current animation group and returns a copy
  42231. * @param newName defines the name of the new group
  42232. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  42233. * @returns the new aniamtion group
  42234. */
  42235. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  42236. /**
  42237. * Serializes the animationGroup to an object
  42238. * @returns Serialized object
  42239. */
  42240. serialize(): any;
  42241. /**
  42242. * Returns a new AnimationGroup object parsed from the source provided.
  42243. * @param parsedAnimationGroup defines the source
  42244. * @param scene defines the scene that will receive the animationGroup
  42245. * @returns a new AnimationGroup
  42246. */
  42247. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  42248. /**
  42249. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  42250. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  42251. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  42252. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  42253. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  42254. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  42255. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  42256. */
  42257. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  42258. /**
  42259. * Returns the string "AnimationGroup"
  42260. * @returns "AnimationGroup"
  42261. */
  42262. getClassName(): string;
  42263. /**
  42264. * Creates a detailled string about the object
  42265. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  42266. * @returns a string representing the object
  42267. */
  42268. toString(fullDetails?: boolean): string;
  42269. }
  42270. }
  42271. declare module BABYLON {
  42272. /**
  42273. * Define an interface for all classes that will hold resources
  42274. */
  42275. export interface IDisposable {
  42276. /**
  42277. * Releases all held resources
  42278. */
  42279. dispose(): void;
  42280. }
  42281. /** Interface defining initialization parameters for Scene class */
  42282. export interface SceneOptions {
  42283. /**
  42284. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  42285. * It will improve performance when the number of geometries becomes important.
  42286. */
  42287. useGeometryUniqueIdsMap?: boolean;
  42288. /**
  42289. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  42290. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  42291. */
  42292. useMaterialMeshMap?: boolean;
  42293. /**
  42294. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  42295. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  42296. */
  42297. useClonedMeshMap?: boolean;
  42298. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  42299. virtual?: boolean;
  42300. }
  42301. /**
  42302. * Represents a scene to be rendered by the engine.
  42303. * @see https://doc.babylonjs.com/features/scene
  42304. */
  42305. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  42306. /** The fog is deactivated */
  42307. static readonly FOGMODE_NONE: number;
  42308. /** The fog density is following an exponential function */
  42309. static readonly FOGMODE_EXP: number;
  42310. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  42311. static readonly FOGMODE_EXP2: number;
  42312. /** The fog density is following a linear function. */
  42313. static readonly FOGMODE_LINEAR: number;
  42314. /**
  42315. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  42316. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42317. */
  42318. static MinDeltaTime: number;
  42319. /**
  42320. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  42321. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42322. */
  42323. static MaxDeltaTime: number;
  42324. /**
  42325. * Factory used to create the default material.
  42326. * @param name The name of the material to create
  42327. * @param scene The scene to create the material for
  42328. * @returns The default material
  42329. */
  42330. static DefaultMaterialFactory(scene: Scene): Material;
  42331. /**
  42332. * Factory used to create the a collision coordinator.
  42333. * @returns The collision coordinator
  42334. */
  42335. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  42336. /** @hidden */
  42337. _inputManager: InputManager;
  42338. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  42339. cameraToUseForPointers: Nullable<Camera>;
  42340. /** @hidden */
  42341. readonly _isScene: boolean;
  42342. /** @hidden */
  42343. _blockEntityCollection: boolean;
  42344. /**
  42345. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  42346. */
  42347. autoClear: boolean;
  42348. /**
  42349. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  42350. */
  42351. autoClearDepthAndStencil: boolean;
  42352. /**
  42353. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  42354. */
  42355. clearColor: Color4;
  42356. /**
  42357. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  42358. */
  42359. ambientColor: Color3;
  42360. /**
  42361. * This is use to store the default BRDF lookup for PBR materials in your scene.
  42362. * It should only be one of the following (if not the default embedded one):
  42363. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  42364. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  42365. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  42366. * The material properties need to be setup according to the type of texture in use.
  42367. */
  42368. environmentBRDFTexture: BaseTexture;
  42369. /**
  42370. * Texture used in all pbr material as the reflection texture.
  42371. * As in the majority of the scene they are the same (exception for multi room and so on),
  42372. * this is easier to reference from here than from all the materials.
  42373. */
  42374. get environmentTexture(): Nullable<BaseTexture>;
  42375. /**
  42376. * Texture used in all pbr material as the reflection texture.
  42377. * As in the majority of the scene they are the same (exception for multi room and so on),
  42378. * this is easier to set here than in all the materials.
  42379. */
  42380. set environmentTexture(value: Nullable<BaseTexture>);
  42381. /** @hidden */
  42382. protected _environmentIntensity: number;
  42383. /**
  42384. * Intensity of the environment in all pbr material.
  42385. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  42386. * As in the majority of the scene they are the same (exception for multi room and so on),
  42387. * this is easier to reference from here than from all the materials.
  42388. */
  42389. get environmentIntensity(): number;
  42390. /**
  42391. * Intensity of the environment in all pbr material.
  42392. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  42393. * As in the majority of the scene they are the same (exception for multi room and so on),
  42394. * this is easier to set here than in all the materials.
  42395. */
  42396. set environmentIntensity(value: number);
  42397. /** @hidden */
  42398. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42399. /**
  42400. * Default image processing configuration used either in the rendering
  42401. * Forward main pass or through the imageProcessingPostProcess if present.
  42402. * As in the majority of the scene they are the same (exception for multi camera),
  42403. * this is easier to reference from here than from all the materials and post process.
  42404. *
  42405. * No setter as we it is a shared configuration, you can set the values instead.
  42406. */
  42407. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  42408. private _forceWireframe;
  42409. /**
  42410. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  42411. */
  42412. set forceWireframe(value: boolean);
  42413. get forceWireframe(): boolean;
  42414. private _skipFrustumClipping;
  42415. /**
  42416. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  42417. */
  42418. set skipFrustumClipping(value: boolean);
  42419. get skipFrustumClipping(): boolean;
  42420. private _forcePointsCloud;
  42421. /**
  42422. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  42423. */
  42424. set forcePointsCloud(value: boolean);
  42425. get forcePointsCloud(): boolean;
  42426. /**
  42427. * Gets or sets the active clipplane 1
  42428. */
  42429. clipPlane: Nullable<Plane>;
  42430. /**
  42431. * Gets or sets the active clipplane 2
  42432. */
  42433. clipPlane2: Nullable<Plane>;
  42434. /**
  42435. * Gets or sets the active clipplane 3
  42436. */
  42437. clipPlane3: Nullable<Plane>;
  42438. /**
  42439. * Gets or sets the active clipplane 4
  42440. */
  42441. clipPlane4: Nullable<Plane>;
  42442. /**
  42443. * Gets or sets the active clipplane 5
  42444. */
  42445. clipPlane5: Nullable<Plane>;
  42446. /**
  42447. * Gets or sets the active clipplane 6
  42448. */
  42449. clipPlane6: Nullable<Plane>;
  42450. /**
  42451. * Gets or sets a boolean indicating if animations are enabled
  42452. */
  42453. animationsEnabled: boolean;
  42454. private _animationPropertiesOverride;
  42455. /**
  42456. * Gets or sets the animation properties override
  42457. */
  42458. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  42459. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  42460. /**
  42461. * Gets or sets a boolean indicating if a constant deltatime has to be used
  42462. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  42463. */
  42464. useConstantAnimationDeltaTime: boolean;
  42465. /**
  42466. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  42467. * Please note that it requires to run a ray cast through the scene on every frame
  42468. */
  42469. constantlyUpdateMeshUnderPointer: boolean;
  42470. /**
  42471. * Defines the HTML cursor to use when hovering over interactive elements
  42472. */
  42473. hoverCursor: string;
  42474. /**
  42475. * Defines the HTML default cursor to use (empty by default)
  42476. */
  42477. defaultCursor: string;
  42478. /**
  42479. * Defines whether cursors are handled by the scene.
  42480. */
  42481. doNotHandleCursors: boolean;
  42482. /**
  42483. * This is used to call preventDefault() on pointer down
  42484. * in order to block unwanted artifacts like system double clicks
  42485. */
  42486. preventDefaultOnPointerDown: boolean;
  42487. /**
  42488. * This is used to call preventDefault() on pointer up
  42489. * in order to block unwanted artifacts like system double clicks
  42490. */
  42491. preventDefaultOnPointerUp: boolean;
  42492. /**
  42493. * Gets or sets user defined metadata
  42494. */
  42495. metadata: any;
  42496. /**
  42497. * For internal use only. Please do not use.
  42498. */
  42499. reservedDataStore: any;
  42500. /**
  42501. * Gets the name of the plugin used to load this scene (null by default)
  42502. */
  42503. loadingPluginName: string;
  42504. /**
  42505. * Use this array to add regular expressions used to disable offline support for specific urls
  42506. */
  42507. disableOfflineSupportExceptionRules: RegExp[];
  42508. /**
  42509. * An event triggered when the scene is disposed.
  42510. */
  42511. onDisposeObservable: Observable<Scene>;
  42512. private _onDisposeObserver;
  42513. /** Sets a function to be executed when this scene is disposed. */
  42514. set onDispose(callback: () => void);
  42515. /**
  42516. * An event triggered before rendering the scene (right after animations and physics)
  42517. */
  42518. onBeforeRenderObservable: Observable<Scene>;
  42519. private _onBeforeRenderObserver;
  42520. /** Sets a function to be executed before rendering this scene */
  42521. set beforeRender(callback: Nullable<() => void>);
  42522. /**
  42523. * An event triggered after rendering the scene
  42524. */
  42525. onAfterRenderObservable: Observable<Scene>;
  42526. /**
  42527. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  42528. */
  42529. onAfterRenderCameraObservable: Observable<Camera>;
  42530. private _onAfterRenderObserver;
  42531. /** Sets a function to be executed after rendering this scene */
  42532. set afterRender(callback: Nullable<() => void>);
  42533. /**
  42534. * An event triggered before animating the scene
  42535. */
  42536. onBeforeAnimationsObservable: Observable<Scene>;
  42537. /**
  42538. * An event triggered after animations processing
  42539. */
  42540. onAfterAnimationsObservable: Observable<Scene>;
  42541. /**
  42542. * An event triggered before draw calls are ready to be sent
  42543. */
  42544. onBeforeDrawPhaseObservable: Observable<Scene>;
  42545. /**
  42546. * An event triggered after draw calls have been sent
  42547. */
  42548. onAfterDrawPhaseObservable: Observable<Scene>;
  42549. /**
  42550. * An event triggered when the scene is ready
  42551. */
  42552. onReadyObservable: Observable<Scene>;
  42553. /**
  42554. * An event triggered before rendering a camera
  42555. */
  42556. onBeforeCameraRenderObservable: Observable<Camera>;
  42557. private _onBeforeCameraRenderObserver;
  42558. /** Sets a function to be executed before rendering a camera*/
  42559. set beforeCameraRender(callback: () => void);
  42560. /**
  42561. * An event triggered after rendering a camera
  42562. */
  42563. onAfterCameraRenderObservable: Observable<Camera>;
  42564. private _onAfterCameraRenderObserver;
  42565. /** Sets a function to be executed after rendering a camera*/
  42566. set afterCameraRender(callback: () => void);
  42567. /**
  42568. * An event triggered when active meshes evaluation is about to start
  42569. */
  42570. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  42571. /**
  42572. * An event triggered when active meshes evaluation is done
  42573. */
  42574. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  42575. /**
  42576. * An event triggered when particles rendering is about to start
  42577. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  42578. */
  42579. onBeforeParticlesRenderingObservable: Observable<Scene>;
  42580. /**
  42581. * An event triggered when particles rendering is done
  42582. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  42583. */
  42584. onAfterParticlesRenderingObservable: Observable<Scene>;
  42585. /**
  42586. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  42587. */
  42588. onDataLoadedObservable: Observable<Scene>;
  42589. /**
  42590. * An event triggered when a camera is created
  42591. */
  42592. onNewCameraAddedObservable: Observable<Camera>;
  42593. /**
  42594. * An event triggered when a camera is removed
  42595. */
  42596. onCameraRemovedObservable: Observable<Camera>;
  42597. /**
  42598. * An event triggered when a light is created
  42599. */
  42600. onNewLightAddedObservable: Observable<Light>;
  42601. /**
  42602. * An event triggered when a light is removed
  42603. */
  42604. onLightRemovedObservable: Observable<Light>;
  42605. /**
  42606. * An event triggered when a geometry is created
  42607. */
  42608. onNewGeometryAddedObservable: Observable<Geometry>;
  42609. /**
  42610. * An event triggered when a geometry is removed
  42611. */
  42612. onGeometryRemovedObservable: Observable<Geometry>;
  42613. /**
  42614. * An event triggered when a transform node is created
  42615. */
  42616. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  42617. /**
  42618. * An event triggered when a transform node is removed
  42619. */
  42620. onTransformNodeRemovedObservable: Observable<TransformNode>;
  42621. /**
  42622. * An event triggered when a mesh is created
  42623. */
  42624. onNewMeshAddedObservable: Observable<AbstractMesh>;
  42625. /**
  42626. * An event triggered when a mesh is removed
  42627. */
  42628. onMeshRemovedObservable: Observable<AbstractMesh>;
  42629. /**
  42630. * An event triggered when a skeleton is created
  42631. */
  42632. onNewSkeletonAddedObservable: Observable<Skeleton>;
  42633. /**
  42634. * An event triggered when a skeleton is removed
  42635. */
  42636. onSkeletonRemovedObservable: Observable<Skeleton>;
  42637. /**
  42638. * An event triggered when a material is created
  42639. */
  42640. onNewMaterialAddedObservable: Observable<Material>;
  42641. /**
  42642. * An event triggered when a material is removed
  42643. */
  42644. onMaterialRemovedObservable: Observable<Material>;
  42645. /**
  42646. * An event triggered when a texture is created
  42647. */
  42648. onNewTextureAddedObservable: Observable<BaseTexture>;
  42649. /**
  42650. * An event triggered when a texture is removed
  42651. */
  42652. onTextureRemovedObservable: Observable<BaseTexture>;
  42653. /**
  42654. * An event triggered when render targets are about to be rendered
  42655. * Can happen multiple times per frame.
  42656. */
  42657. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  42658. /**
  42659. * An event triggered when render targets were rendered.
  42660. * Can happen multiple times per frame.
  42661. */
  42662. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  42663. /**
  42664. * An event triggered before calculating deterministic simulation step
  42665. */
  42666. onBeforeStepObservable: Observable<Scene>;
  42667. /**
  42668. * An event triggered after calculating deterministic simulation step
  42669. */
  42670. onAfterStepObservable: Observable<Scene>;
  42671. /**
  42672. * An event triggered when the activeCamera property is updated
  42673. */
  42674. onActiveCameraChanged: Observable<Scene>;
  42675. /**
  42676. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  42677. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  42678. * 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)
  42679. */
  42680. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  42681. /**
  42682. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  42683. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  42684. * 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)
  42685. */
  42686. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  42687. /**
  42688. * This Observable will when a mesh has been imported into the scene.
  42689. */
  42690. onMeshImportedObservable: Observable<AbstractMesh>;
  42691. /**
  42692. * This Observable will when an animation file has been imported into the scene.
  42693. */
  42694. onAnimationFileImportedObservable: Observable<Scene>;
  42695. /**
  42696. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  42697. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  42698. */
  42699. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  42700. /** @hidden */
  42701. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  42702. /**
  42703. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  42704. */
  42705. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  42706. /**
  42707. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  42708. */
  42709. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  42710. /**
  42711. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  42712. */
  42713. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  42714. /** Callback called when a pointer move is detected */
  42715. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  42716. /** Callback called when a pointer down is detected */
  42717. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  42718. /** Callback called when a pointer up is detected */
  42719. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  42720. /** Callback called when a pointer pick is detected */
  42721. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  42722. /**
  42723. * 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).
  42724. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  42725. */
  42726. onPrePointerObservable: Observable<PointerInfoPre>;
  42727. /**
  42728. * Observable event triggered each time an input event is received from the rendering canvas
  42729. */
  42730. onPointerObservable: Observable<PointerInfo>;
  42731. /**
  42732. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  42733. */
  42734. get unTranslatedPointer(): Vector2;
  42735. /**
  42736. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  42737. */
  42738. static get DragMovementThreshold(): number;
  42739. static set DragMovementThreshold(value: number);
  42740. /**
  42741. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  42742. */
  42743. static get LongPressDelay(): number;
  42744. static set LongPressDelay(value: number);
  42745. /**
  42746. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  42747. */
  42748. static get DoubleClickDelay(): number;
  42749. static set DoubleClickDelay(value: number);
  42750. /** If you need to check double click without raising a single click at first click, enable this flag */
  42751. static get ExclusiveDoubleClickMode(): boolean;
  42752. static set ExclusiveDoubleClickMode(value: boolean);
  42753. /** @hidden */
  42754. _mirroredCameraPosition: Nullable<Vector3>;
  42755. /**
  42756. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  42757. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  42758. */
  42759. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  42760. /**
  42761. * Observable event triggered each time an keyboard event is received from the hosting window
  42762. */
  42763. onKeyboardObservable: Observable<KeyboardInfo>;
  42764. private _useRightHandedSystem;
  42765. /**
  42766. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  42767. */
  42768. set useRightHandedSystem(value: boolean);
  42769. get useRightHandedSystem(): boolean;
  42770. private _timeAccumulator;
  42771. private _currentStepId;
  42772. private _currentInternalStep;
  42773. /**
  42774. * Sets the step Id used by deterministic lock step
  42775. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42776. * @param newStepId defines the step Id
  42777. */
  42778. setStepId(newStepId: number): void;
  42779. /**
  42780. * Gets the step Id used by deterministic lock step
  42781. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42782. * @returns the step Id
  42783. */
  42784. getStepId(): number;
  42785. /**
  42786. * Gets the internal step used by deterministic lock step
  42787. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42788. * @returns the internal step
  42789. */
  42790. getInternalStep(): number;
  42791. private _fogEnabled;
  42792. /**
  42793. * Gets or sets a boolean indicating if fog is enabled on this scene
  42794. * @see https://doc.babylonjs.com/babylon101/environment#fog
  42795. * (Default is true)
  42796. */
  42797. set fogEnabled(value: boolean);
  42798. get fogEnabled(): boolean;
  42799. private _fogMode;
  42800. /**
  42801. * Gets or sets the fog mode to use
  42802. * @see https://doc.babylonjs.com/babylon101/environment#fog
  42803. * | mode | value |
  42804. * | --- | --- |
  42805. * | FOGMODE_NONE | 0 |
  42806. * | FOGMODE_EXP | 1 |
  42807. * | FOGMODE_EXP2 | 2 |
  42808. * | FOGMODE_LINEAR | 3 |
  42809. */
  42810. set fogMode(value: number);
  42811. get fogMode(): number;
  42812. /**
  42813. * Gets or sets the fog color to use
  42814. * @see https://doc.babylonjs.com/babylon101/environment#fog
  42815. * (Default is Color3(0.2, 0.2, 0.3))
  42816. */
  42817. fogColor: Color3;
  42818. /**
  42819. * Gets or sets the fog density to use
  42820. * @see https://doc.babylonjs.com/babylon101/environment#fog
  42821. * (Default is 0.1)
  42822. */
  42823. fogDensity: number;
  42824. /**
  42825. * Gets or sets the fog start distance to use
  42826. * @see https://doc.babylonjs.com/babylon101/environment#fog
  42827. * (Default is 0)
  42828. */
  42829. fogStart: number;
  42830. /**
  42831. * Gets or sets the fog end distance to use
  42832. * @see https://doc.babylonjs.com/babylon101/environment#fog
  42833. * (Default is 1000)
  42834. */
  42835. fogEnd: number;
  42836. /**
  42837. * Flag indicating that the frame buffer binding is handled by another component
  42838. */
  42839. prePass: boolean;
  42840. private _shadowsEnabled;
  42841. /**
  42842. * Gets or sets a boolean indicating if shadows are enabled on this scene
  42843. */
  42844. set shadowsEnabled(value: boolean);
  42845. get shadowsEnabled(): boolean;
  42846. private _lightsEnabled;
  42847. /**
  42848. * Gets or sets a boolean indicating if lights are enabled on this scene
  42849. */
  42850. set lightsEnabled(value: boolean);
  42851. get lightsEnabled(): boolean;
  42852. /** All of the active cameras added to this scene. */
  42853. activeCameras: Camera[];
  42854. /** @hidden */
  42855. _activeCamera: Nullable<Camera>;
  42856. /** Gets or sets the current active camera */
  42857. get activeCamera(): Nullable<Camera>;
  42858. set activeCamera(value: Nullable<Camera>);
  42859. private _defaultMaterial;
  42860. /** The default material used on meshes when no material is affected */
  42861. get defaultMaterial(): Material;
  42862. /** The default material used on meshes when no material is affected */
  42863. set defaultMaterial(value: Material);
  42864. private _texturesEnabled;
  42865. /**
  42866. * Gets or sets a boolean indicating if textures are enabled on this scene
  42867. */
  42868. set texturesEnabled(value: boolean);
  42869. get texturesEnabled(): boolean;
  42870. /**
  42871. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  42872. */
  42873. physicsEnabled: boolean;
  42874. /**
  42875. * Gets or sets a boolean indicating if particles are enabled on this scene
  42876. */
  42877. particlesEnabled: boolean;
  42878. /**
  42879. * Gets or sets a boolean indicating if sprites are enabled on this scene
  42880. */
  42881. spritesEnabled: boolean;
  42882. private _skeletonsEnabled;
  42883. /**
  42884. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  42885. */
  42886. set skeletonsEnabled(value: boolean);
  42887. get skeletonsEnabled(): boolean;
  42888. /**
  42889. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  42890. */
  42891. lensFlaresEnabled: boolean;
  42892. /**
  42893. * Gets or sets a boolean indicating if collisions are enabled on this scene
  42894. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  42895. */
  42896. collisionsEnabled: boolean;
  42897. private _collisionCoordinator;
  42898. /** @hidden */
  42899. get collisionCoordinator(): ICollisionCoordinator;
  42900. /**
  42901. * Defines the gravity applied to this scene (used only for collisions)
  42902. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  42903. */
  42904. gravity: Vector3;
  42905. /**
  42906. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  42907. */
  42908. postProcessesEnabled: boolean;
  42909. /**
  42910. * Gets the current postprocess manager
  42911. */
  42912. postProcessManager: PostProcessManager;
  42913. /**
  42914. * Gets or sets a boolean indicating if render targets are enabled on this scene
  42915. */
  42916. renderTargetsEnabled: boolean;
  42917. /**
  42918. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  42919. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  42920. */
  42921. dumpNextRenderTargets: boolean;
  42922. /**
  42923. * The list of user defined render targets added to the scene
  42924. */
  42925. customRenderTargets: RenderTargetTexture[];
  42926. /**
  42927. * Defines if texture loading must be delayed
  42928. * If true, textures will only be loaded when they need to be rendered
  42929. */
  42930. useDelayedTextureLoading: boolean;
  42931. /**
  42932. * Gets the list of meshes imported to the scene through SceneLoader
  42933. */
  42934. importedMeshesFiles: String[];
  42935. /**
  42936. * Gets or sets a boolean indicating if probes are enabled on this scene
  42937. */
  42938. probesEnabled: boolean;
  42939. /**
  42940. * Gets or sets the current offline provider to use to store scene data
  42941. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  42942. */
  42943. offlineProvider: IOfflineProvider;
  42944. /**
  42945. * Gets or sets the action manager associated with the scene
  42946. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  42947. */
  42948. actionManager: AbstractActionManager;
  42949. private _meshesForIntersections;
  42950. /**
  42951. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  42952. */
  42953. proceduralTexturesEnabled: boolean;
  42954. private _engine;
  42955. private _totalVertices;
  42956. /** @hidden */
  42957. _activeIndices: PerfCounter;
  42958. /** @hidden */
  42959. _activeParticles: PerfCounter;
  42960. /** @hidden */
  42961. _activeBones: PerfCounter;
  42962. private _animationRatio;
  42963. /** @hidden */
  42964. _animationTimeLast: number;
  42965. /** @hidden */
  42966. _animationTime: number;
  42967. /**
  42968. * Gets or sets a general scale for animation speed
  42969. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  42970. */
  42971. animationTimeScale: number;
  42972. /** @hidden */
  42973. _cachedMaterial: Nullable<Material>;
  42974. /** @hidden */
  42975. _cachedEffect: Nullable<Effect>;
  42976. /** @hidden */
  42977. _cachedVisibility: Nullable<number>;
  42978. private _renderId;
  42979. private _frameId;
  42980. private _executeWhenReadyTimeoutId;
  42981. private _intermediateRendering;
  42982. private _viewUpdateFlag;
  42983. private _projectionUpdateFlag;
  42984. /** @hidden */
  42985. _toBeDisposed: Nullable<IDisposable>[];
  42986. private _activeRequests;
  42987. /** @hidden */
  42988. _pendingData: any[];
  42989. private _isDisposed;
  42990. /**
  42991. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  42992. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  42993. */
  42994. dispatchAllSubMeshesOfActiveMeshes: boolean;
  42995. private _activeMeshes;
  42996. private _processedMaterials;
  42997. private _renderTargets;
  42998. /** @hidden */
  42999. _activeParticleSystems: SmartArray<IParticleSystem>;
  43000. private _activeSkeletons;
  43001. private _softwareSkinnedMeshes;
  43002. private _renderingManager;
  43003. /** @hidden */
  43004. _activeAnimatables: Animatable[];
  43005. private _transformMatrix;
  43006. private _sceneUbo;
  43007. /** @hidden */
  43008. _viewMatrix: Matrix;
  43009. private _projectionMatrix;
  43010. /** @hidden */
  43011. _forcedViewPosition: Nullable<Vector3>;
  43012. /** @hidden */
  43013. _frustumPlanes: Plane[];
  43014. /**
  43015. * Gets the list of frustum planes (built from the active camera)
  43016. */
  43017. get frustumPlanes(): Plane[];
  43018. /**
  43019. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  43020. * This is useful if there are more lights that the maximum simulteanous authorized
  43021. */
  43022. requireLightSorting: boolean;
  43023. /** @hidden */
  43024. readonly useMaterialMeshMap: boolean;
  43025. /** @hidden */
  43026. readonly useClonedMeshMap: boolean;
  43027. private _externalData;
  43028. private _uid;
  43029. /**
  43030. * @hidden
  43031. * Backing store of defined scene components.
  43032. */
  43033. _components: ISceneComponent[];
  43034. /**
  43035. * @hidden
  43036. * Backing store of defined scene components.
  43037. */
  43038. _serializableComponents: ISceneSerializableComponent[];
  43039. /**
  43040. * List of components to register on the next registration step.
  43041. */
  43042. private _transientComponents;
  43043. /**
  43044. * Registers the transient components if needed.
  43045. */
  43046. private _registerTransientComponents;
  43047. /**
  43048. * @hidden
  43049. * Add a component to the scene.
  43050. * Note that the ccomponent could be registered on th next frame if this is called after
  43051. * the register component stage.
  43052. * @param component Defines the component to add to the scene
  43053. */
  43054. _addComponent(component: ISceneComponent): void;
  43055. /**
  43056. * @hidden
  43057. * Gets a component from the scene.
  43058. * @param name defines the name of the component to retrieve
  43059. * @returns the component or null if not present
  43060. */
  43061. _getComponent(name: string): Nullable<ISceneComponent>;
  43062. /**
  43063. * @hidden
  43064. * Defines the actions happening before camera updates.
  43065. */
  43066. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  43067. /**
  43068. * @hidden
  43069. * Defines the actions happening before clear the canvas.
  43070. */
  43071. _beforeClearStage: Stage<SimpleStageAction>;
  43072. /**
  43073. * @hidden
  43074. * Defines the actions when collecting render targets for the frame.
  43075. */
  43076. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  43077. /**
  43078. * @hidden
  43079. * Defines the actions happening for one camera in the frame.
  43080. */
  43081. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  43082. /**
  43083. * @hidden
  43084. * Defines the actions happening during the per mesh ready checks.
  43085. */
  43086. _isReadyForMeshStage: Stage<MeshStageAction>;
  43087. /**
  43088. * @hidden
  43089. * Defines the actions happening before evaluate active mesh checks.
  43090. */
  43091. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  43092. /**
  43093. * @hidden
  43094. * Defines the actions happening during the evaluate sub mesh checks.
  43095. */
  43096. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  43097. /**
  43098. * @hidden
  43099. * Defines the actions happening during the active mesh stage.
  43100. */
  43101. _activeMeshStage: Stage<ActiveMeshStageAction>;
  43102. /**
  43103. * @hidden
  43104. * Defines the actions happening during the per camera render target step.
  43105. */
  43106. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  43107. /**
  43108. * @hidden
  43109. * Defines the actions happening just before the active camera is drawing.
  43110. */
  43111. _beforeCameraDrawStage: Stage<CameraStageAction>;
  43112. /**
  43113. * @hidden
  43114. * Defines the actions happening just before a render target is drawing.
  43115. */
  43116. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  43117. /**
  43118. * @hidden
  43119. * Defines the actions happening just before a rendering group is drawing.
  43120. */
  43121. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  43122. /**
  43123. * @hidden
  43124. * Defines the actions happening just before a mesh is drawing.
  43125. */
  43126. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  43127. /**
  43128. * @hidden
  43129. * Defines the actions happening just after a mesh has been drawn.
  43130. */
  43131. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  43132. /**
  43133. * @hidden
  43134. * Defines the actions happening just after a rendering group has been drawn.
  43135. */
  43136. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  43137. /**
  43138. * @hidden
  43139. * Defines the actions happening just after the active camera has been drawn.
  43140. */
  43141. _afterCameraDrawStage: Stage<CameraStageAction>;
  43142. /**
  43143. * @hidden
  43144. * Defines the actions happening just after a render target has been drawn.
  43145. */
  43146. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  43147. /**
  43148. * @hidden
  43149. * Defines the actions happening just after rendering all cameras and computing intersections.
  43150. */
  43151. _afterRenderStage: Stage<SimpleStageAction>;
  43152. /**
  43153. * @hidden
  43154. * Defines the actions happening when a pointer move event happens.
  43155. */
  43156. _pointerMoveStage: Stage<PointerMoveStageAction>;
  43157. /**
  43158. * @hidden
  43159. * Defines the actions happening when a pointer down event happens.
  43160. */
  43161. _pointerDownStage: Stage<PointerUpDownStageAction>;
  43162. /**
  43163. * @hidden
  43164. * Defines the actions happening when a pointer up event happens.
  43165. */
  43166. _pointerUpStage: Stage<PointerUpDownStageAction>;
  43167. /**
  43168. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  43169. */
  43170. private geometriesByUniqueId;
  43171. /**
  43172. * Creates a new Scene
  43173. * @param engine defines the engine to use to render this scene
  43174. * @param options defines the scene options
  43175. */
  43176. constructor(engine: Engine, options?: SceneOptions);
  43177. /**
  43178. * Gets a string identifying the name of the class
  43179. * @returns "Scene" string
  43180. */
  43181. getClassName(): string;
  43182. private _defaultMeshCandidates;
  43183. /**
  43184. * @hidden
  43185. */
  43186. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  43187. private _defaultSubMeshCandidates;
  43188. /**
  43189. * @hidden
  43190. */
  43191. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  43192. /**
  43193. * Sets the default candidate providers for the scene.
  43194. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  43195. * and getCollidingSubMeshCandidates to their default function
  43196. */
  43197. setDefaultCandidateProviders(): void;
  43198. /**
  43199. * Gets the mesh that is currently under the pointer
  43200. */
  43201. get meshUnderPointer(): Nullable<AbstractMesh>;
  43202. /**
  43203. * Gets or sets the current on-screen X position of the pointer
  43204. */
  43205. get pointerX(): number;
  43206. set pointerX(value: number);
  43207. /**
  43208. * Gets or sets the current on-screen Y position of the pointer
  43209. */
  43210. get pointerY(): number;
  43211. set pointerY(value: number);
  43212. /**
  43213. * Gets the cached material (ie. the latest rendered one)
  43214. * @returns the cached material
  43215. */
  43216. getCachedMaterial(): Nullable<Material>;
  43217. /**
  43218. * Gets the cached effect (ie. the latest rendered one)
  43219. * @returns the cached effect
  43220. */
  43221. getCachedEffect(): Nullable<Effect>;
  43222. /**
  43223. * Gets the cached visibility state (ie. the latest rendered one)
  43224. * @returns the cached visibility state
  43225. */
  43226. getCachedVisibility(): Nullable<number>;
  43227. /**
  43228. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  43229. * @param material defines the current material
  43230. * @param effect defines the current effect
  43231. * @param visibility defines the current visibility state
  43232. * @returns true if one parameter is not cached
  43233. */
  43234. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  43235. /**
  43236. * Gets the engine associated with the scene
  43237. * @returns an Engine
  43238. */
  43239. getEngine(): Engine;
  43240. /**
  43241. * Gets the total number of vertices rendered per frame
  43242. * @returns the total number of vertices rendered per frame
  43243. */
  43244. getTotalVertices(): number;
  43245. /**
  43246. * Gets the performance counter for total vertices
  43247. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  43248. */
  43249. get totalVerticesPerfCounter(): PerfCounter;
  43250. /**
  43251. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  43252. * @returns the total number of active indices rendered per frame
  43253. */
  43254. getActiveIndices(): number;
  43255. /**
  43256. * Gets the performance counter for active indices
  43257. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  43258. */
  43259. get totalActiveIndicesPerfCounter(): PerfCounter;
  43260. /**
  43261. * Gets the total number of active particles rendered per frame
  43262. * @returns the total number of active particles rendered per frame
  43263. */
  43264. getActiveParticles(): number;
  43265. /**
  43266. * Gets the performance counter for active particles
  43267. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  43268. */
  43269. get activeParticlesPerfCounter(): PerfCounter;
  43270. /**
  43271. * Gets the total number of active bones rendered per frame
  43272. * @returns the total number of active bones rendered per frame
  43273. */
  43274. getActiveBones(): number;
  43275. /**
  43276. * Gets the performance counter for active bones
  43277. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  43278. */
  43279. get activeBonesPerfCounter(): PerfCounter;
  43280. /**
  43281. * Gets the array of active meshes
  43282. * @returns an array of AbstractMesh
  43283. */
  43284. getActiveMeshes(): SmartArray<AbstractMesh>;
  43285. /**
  43286. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  43287. * @returns a number
  43288. */
  43289. getAnimationRatio(): number;
  43290. /**
  43291. * Gets an unique Id for the current render phase
  43292. * @returns a number
  43293. */
  43294. getRenderId(): number;
  43295. /**
  43296. * Gets an unique Id for the current frame
  43297. * @returns a number
  43298. */
  43299. getFrameId(): number;
  43300. /** Call this function if you want to manually increment the render Id*/
  43301. incrementRenderId(): void;
  43302. private _createUbo;
  43303. /**
  43304. * Use this method to simulate a pointer move on a mesh
  43305. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43306. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43307. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43308. * @returns the current scene
  43309. */
  43310. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  43311. /**
  43312. * Use this method to simulate a pointer down on a mesh
  43313. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43314. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43315. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43316. * @returns the current scene
  43317. */
  43318. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  43319. /**
  43320. * Use this method to simulate a pointer up on a mesh
  43321. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  43322. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  43323. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  43324. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  43325. * @returns the current scene
  43326. */
  43327. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  43328. /**
  43329. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  43330. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  43331. * @returns true if the pointer was captured
  43332. */
  43333. isPointerCaptured(pointerId?: number): boolean;
  43334. /**
  43335. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  43336. * @param attachUp defines if you want to attach events to pointerup
  43337. * @param attachDown defines if you want to attach events to pointerdown
  43338. * @param attachMove defines if you want to attach events to pointermove
  43339. */
  43340. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  43341. /** Detaches all event handlers*/
  43342. detachControl(): void;
  43343. /**
  43344. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  43345. * Delay loaded resources are not taking in account
  43346. * @return true if all required resources are ready
  43347. */
  43348. isReady(): boolean;
  43349. /** Resets all cached information relative to material (including effect and visibility) */
  43350. resetCachedMaterial(): void;
  43351. /**
  43352. * Registers a function to be called before every frame render
  43353. * @param func defines the function to register
  43354. */
  43355. registerBeforeRender(func: () => void): void;
  43356. /**
  43357. * Unregisters a function called before every frame render
  43358. * @param func defines the function to unregister
  43359. */
  43360. unregisterBeforeRender(func: () => void): void;
  43361. /**
  43362. * Registers a function to be called after every frame render
  43363. * @param func defines the function to register
  43364. */
  43365. registerAfterRender(func: () => void): void;
  43366. /**
  43367. * Unregisters a function called after every frame render
  43368. * @param func defines the function to unregister
  43369. */
  43370. unregisterAfterRender(func: () => void): void;
  43371. private _executeOnceBeforeRender;
  43372. /**
  43373. * The provided function will run before render once and will be disposed afterwards.
  43374. * A timeout delay can be provided so that the function will be executed in N ms.
  43375. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  43376. * @param func The function to be executed.
  43377. * @param timeout optional delay in ms
  43378. */
  43379. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  43380. /** @hidden */
  43381. _addPendingData(data: any): void;
  43382. /** @hidden */
  43383. _removePendingData(data: any): void;
  43384. /**
  43385. * Returns the number of items waiting to be loaded
  43386. * @returns the number of items waiting to be loaded
  43387. */
  43388. getWaitingItemsCount(): number;
  43389. /**
  43390. * Returns a boolean indicating if the scene is still loading data
  43391. */
  43392. get isLoading(): boolean;
  43393. /**
  43394. * Registers a function to be executed when the scene is ready
  43395. * @param {Function} func - the function to be executed
  43396. */
  43397. executeWhenReady(func: () => void): void;
  43398. /**
  43399. * Returns a promise that resolves when the scene is ready
  43400. * @returns A promise that resolves when the scene is ready
  43401. */
  43402. whenReadyAsync(): Promise<void>;
  43403. /** @hidden */
  43404. _checkIsReady(): void;
  43405. /**
  43406. * Gets all animatable attached to the scene
  43407. */
  43408. get animatables(): Animatable[];
  43409. /**
  43410. * Resets the last animation time frame.
  43411. * Useful to override when animations start running when loading a scene for the first time.
  43412. */
  43413. resetLastAnimationTimeFrame(): void;
  43414. /**
  43415. * Gets the current view matrix
  43416. * @returns a Matrix
  43417. */
  43418. getViewMatrix(): Matrix;
  43419. /**
  43420. * Gets the current projection matrix
  43421. * @returns a Matrix
  43422. */
  43423. getProjectionMatrix(): Matrix;
  43424. /**
  43425. * Gets the current transform matrix
  43426. * @returns a Matrix made of View * Projection
  43427. */
  43428. getTransformMatrix(): Matrix;
  43429. /**
  43430. * Sets the current transform matrix
  43431. * @param viewL defines the View matrix to use
  43432. * @param projectionL defines the Projection matrix to use
  43433. * @param viewR defines the right View matrix to use (if provided)
  43434. * @param projectionR defines the right Projection matrix to use (if provided)
  43435. */
  43436. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  43437. /**
  43438. * Gets the uniform buffer used to store scene data
  43439. * @returns a UniformBuffer
  43440. */
  43441. getSceneUniformBuffer(): UniformBuffer;
  43442. /**
  43443. * Gets an unique (relatively to the current scene) Id
  43444. * @returns an unique number for the scene
  43445. */
  43446. getUniqueId(): number;
  43447. /**
  43448. * Add a mesh to the list of scene's meshes
  43449. * @param newMesh defines the mesh to add
  43450. * @param recursive if all child meshes should also be added to the scene
  43451. */
  43452. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  43453. /**
  43454. * Remove a mesh for the list of scene's meshes
  43455. * @param toRemove defines the mesh to remove
  43456. * @param recursive if all child meshes should also be removed from the scene
  43457. * @returns the index where the mesh was in the mesh list
  43458. */
  43459. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  43460. /**
  43461. * Add a transform node to the list of scene's transform nodes
  43462. * @param newTransformNode defines the transform node to add
  43463. */
  43464. addTransformNode(newTransformNode: TransformNode): void;
  43465. /**
  43466. * Remove a transform node for the list of scene's transform nodes
  43467. * @param toRemove defines the transform node to remove
  43468. * @returns the index where the transform node was in the transform node list
  43469. */
  43470. removeTransformNode(toRemove: TransformNode): number;
  43471. /**
  43472. * Remove a skeleton for the list of scene's skeletons
  43473. * @param toRemove defines the skeleton to remove
  43474. * @returns the index where the skeleton was in the skeleton list
  43475. */
  43476. removeSkeleton(toRemove: Skeleton): number;
  43477. /**
  43478. * Remove a morph target for the list of scene's morph targets
  43479. * @param toRemove defines the morph target to remove
  43480. * @returns the index where the morph target was in the morph target list
  43481. */
  43482. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  43483. /**
  43484. * Remove a light for the list of scene's lights
  43485. * @param toRemove defines the light to remove
  43486. * @returns the index where the light was in the light list
  43487. */
  43488. removeLight(toRemove: Light): number;
  43489. /**
  43490. * Remove a camera for the list of scene's cameras
  43491. * @param toRemove defines the camera to remove
  43492. * @returns the index where the camera was in the camera list
  43493. */
  43494. removeCamera(toRemove: Camera): number;
  43495. /**
  43496. * Remove a particle system for the list of scene's particle systems
  43497. * @param toRemove defines the particle system to remove
  43498. * @returns the index where the particle system was in the particle system list
  43499. */
  43500. removeParticleSystem(toRemove: IParticleSystem): number;
  43501. /**
  43502. * Remove a animation for the list of scene's animations
  43503. * @param toRemove defines the animation to remove
  43504. * @returns the index where the animation was in the animation list
  43505. */
  43506. removeAnimation(toRemove: Animation): number;
  43507. /**
  43508. * Will stop the animation of the given target
  43509. * @param target - the target
  43510. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  43511. * @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)
  43512. */
  43513. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  43514. /**
  43515. * Removes the given animation group from this scene.
  43516. * @param toRemove The animation group to remove
  43517. * @returns The index of the removed animation group
  43518. */
  43519. removeAnimationGroup(toRemove: AnimationGroup): number;
  43520. /**
  43521. * Removes the given multi-material from this scene.
  43522. * @param toRemove The multi-material to remove
  43523. * @returns The index of the removed multi-material
  43524. */
  43525. removeMultiMaterial(toRemove: MultiMaterial): number;
  43526. /**
  43527. * Removes the given material from this scene.
  43528. * @param toRemove The material to remove
  43529. * @returns The index of the removed material
  43530. */
  43531. removeMaterial(toRemove: Material): number;
  43532. /**
  43533. * Removes the given action manager from this scene.
  43534. * @param toRemove The action manager to remove
  43535. * @returns The index of the removed action manager
  43536. */
  43537. removeActionManager(toRemove: AbstractActionManager): number;
  43538. /**
  43539. * Removes the given texture from this scene.
  43540. * @param toRemove The texture to remove
  43541. * @returns The index of the removed texture
  43542. */
  43543. removeTexture(toRemove: BaseTexture): number;
  43544. /**
  43545. * Adds the given light to this scene
  43546. * @param newLight The light to add
  43547. */
  43548. addLight(newLight: Light): void;
  43549. /**
  43550. * Sorts the list list based on light priorities
  43551. */
  43552. sortLightsByPriority(): void;
  43553. /**
  43554. * Adds the given camera to this scene
  43555. * @param newCamera The camera to add
  43556. */
  43557. addCamera(newCamera: Camera): void;
  43558. /**
  43559. * Adds the given skeleton to this scene
  43560. * @param newSkeleton The skeleton to add
  43561. */
  43562. addSkeleton(newSkeleton: Skeleton): void;
  43563. /**
  43564. * Adds the given particle system to this scene
  43565. * @param newParticleSystem The particle system to add
  43566. */
  43567. addParticleSystem(newParticleSystem: IParticleSystem): void;
  43568. /**
  43569. * Adds the given animation to this scene
  43570. * @param newAnimation The animation to add
  43571. */
  43572. addAnimation(newAnimation: Animation): void;
  43573. /**
  43574. * Adds the given animation group to this scene.
  43575. * @param newAnimationGroup The animation group to add
  43576. */
  43577. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  43578. /**
  43579. * Adds the given multi-material to this scene
  43580. * @param newMultiMaterial The multi-material to add
  43581. */
  43582. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  43583. /**
  43584. * Adds the given material to this scene
  43585. * @param newMaterial The material to add
  43586. */
  43587. addMaterial(newMaterial: Material): void;
  43588. /**
  43589. * Adds the given morph target to this scene
  43590. * @param newMorphTargetManager The morph target to add
  43591. */
  43592. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  43593. /**
  43594. * Adds the given geometry to this scene
  43595. * @param newGeometry The geometry to add
  43596. */
  43597. addGeometry(newGeometry: Geometry): void;
  43598. /**
  43599. * Adds the given action manager to this scene
  43600. * @param newActionManager The action manager to add
  43601. */
  43602. addActionManager(newActionManager: AbstractActionManager): void;
  43603. /**
  43604. * Adds the given texture to this scene.
  43605. * @param newTexture The texture to add
  43606. */
  43607. addTexture(newTexture: BaseTexture): void;
  43608. /**
  43609. * Switch active camera
  43610. * @param newCamera defines the new active camera
  43611. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  43612. */
  43613. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  43614. /**
  43615. * sets the active camera of the scene using its ID
  43616. * @param id defines the camera's ID
  43617. * @return the new active camera or null if none found.
  43618. */
  43619. setActiveCameraByID(id: string): Nullable<Camera>;
  43620. /**
  43621. * sets the active camera of the scene using its name
  43622. * @param name defines the camera's name
  43623. * @returns the new active camera or null if none found.
  43624. */
  43625. setActiveCameraByName(name: string): Nullable<Camera>;
  43626. /**
  43627. * get an animation group using its name
  43628. * @param name defines the material's name
  43629. * @return the animation group or null if none found.
  43630. */
  43631. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  43632. /**
  43633. * Get a material using its unique id
  43634. * @param uniqueId defines the material's unique id
  43635. * @return the material or null if none found.
  43636. */
  43637. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  43638. /**
  43639. * get a material using its id
  43640. * @param id defines the material's ID
  43641. * @return the material or null if none found.
  43642. */
  43643. getMaterialByID(id: string): Nullable<Material>;
  43644. /**
  43645. * Gets a the last added material using a given id
  43646. * @param id defines the material's ID
  43647. * @return the last material with the given id or null if none found.
  43648. */
  43649. getLastMaterialByID(id: string): Nullable<Material>;
  43650. /**
  43651. * Gets a material using its name
  43652. * @param name defines the material's name
  43653. * @return the material or null if none found.
  43654. */
  43655. getMaterialByName(name: string): Nullable<Material>;
  43656. /**
  43657. * Get a texture using its unique id
  43658. * @param uniqueId defines the texture's unique id
  43659. * @return the texture or null if none found.
  43660. */
  43661. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  43662. /**
  43663. * Gets a camera using its id
  43664. * @param id defines the id to look for
  43665. * @returns the camera or null if not found
  43666. */
  43667. getCameraByID(id: string): Nullable<Camera>;
  43668. /**
  43669. * Gets a camera using its unique id
  43670. * @param uniqueId defines the unique id to look for
  43671. * @returns the camera or null if not found
  43672. */
  43673. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  43674. /**
  43675. * Gets a camera using its name
  43676. * @param name defines the camera's name
  43677. * @return the camera or null if none found.
  43678. */
  43679. getCameraByName(name: string): Nullable<Camera>;
  43680. /**
  43681. * Gets a bone using its id
  43682. * @param id defines the bone's id
  43683. * @return the bone or null if not found
  43684. */
  43685. getBoneByID(id: string): Nullable<Bone>;
  43686. /**
  43687. * Gets a bone using its id
  43688. * @param name defines the bone's name
  43689. * @return the bone or null if not found
  43690. */
  43691. getBoneByName(name: string): Nullable<Bone>;
  43692. /**
  43693. * Gets a light node using its name
  43694. * @param name defines the the light's name
  43695. * @return the light or null if none found.
  43696. */
  43697. getLightByName(name: string): Nullable<Light>;
  43698. /**
  43699. * Gets a light node using its id
  43700. * @param id defines the light's id
  43701. * @return the light or null if none found.
  43702. */
  43703. getLightByID(id: string): Nullable<Light>;
  43704. /**
  43705. * Gets a light node using its scene-generated unique ID
  43706. * @param uniqueId defines the light's unique id
  43707. * @return the light or null if none found.
  43708. */
  43709. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  43710. /**
  43711. * Gets a particle system by id
  43712. * @param id defines the particle system id
  43713. * @return the corresponding system or null if none found
  43714. */
  43715. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  43716. /**
  43717. * Gets a geometry using its ID
  43718. * @param id defines the geometry's id
  43719. * @return the geometry or null if none found.
  43720. */
  43721. getGeometryByID(id: string): Nullable<Geometry>;
  43722. private _getGeometryByUniqueID;
  43723. /**
  43724. * Add a new geometry to this scene
  43725. * @param geometry defines the geometry to be added to the scene.
  43726. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  43727. * @return a boolean defining if the geometry was added or not
  43728. */
  43729. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  43730. /**
  43731. * Removes an existing geometry
  43732. * @param geometry defines the geometry to be removed from the scene
  43733. * @return a boolean defining if the geometry was removed or not
  43734. */
  43735. removeGeometry(geometry: Geometry): boolean;
  43736. /**
  43737. * Gets the list of geometries attached to the scene
  43738. * @returns an array of Geometry
  43739. */
  43740. getGeometries(): Geometry[];
  43741. /**
  43742. * Gets the first added mesh found of a given ID
  43743. * @param id defines the id to search for
  43744. * @return the mesh found or null if not found at all
  43745. */
  43746. getMeshByID(id: string): Nullable<AbstractMesh>;
  43747. /**
  43748. * Gets a list of meshes using their id
  43749. * @param id defines the id to search for
  43750. * @returns a list of meshes
  43751. */
  43752. getMeshesByID(id: string): Array<AbstractMesh>;
  43753. /**
  43754. * Gets the first added transform node found of a given ID
  43755. * @param id defines the id to search for
  43756. * @return the found transform node or null if not found at all.
  43757. */
  43758. getTransformNodeByID(id: string): Nullable<TransformNode>;
  43759. /**
  43760. * Gets a transform node with its auto-generated unique id
  43761. * @param uniqueId efines the unique id to search for
  43762. * @return the found transform node or null if not found at all.
  43763. */
  43764. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  43765. /**
  43766. * Gets a list of transform nodes using their id
  43767. * @param id defines the id to search for
  43768. * @returns a list of transform nodes
  43769. */
  43770. getTransformNodesByID(id: string): Array<TransformNode>;
  43771. /**
  43772. * Gets a mesh with its auto-generated unique id
  43773. * @param uniqueId defines the unique id to search for
  43774. * @return the found mesh or null if not found at all.
  43775. */
  43776. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  43777. /**
  43778. * Gets a the last added mesh using a given id
  43779. * @param id defines the id to search for
  43780. * @return the found mesh or null if not found at all.
  43781. */
  43782. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  43783. /**
  43784. * Gets a the last added node (Mesh, Camera, Light) using a given id
  43785. * @param id defines the id to search for
  43786. * @return the found node or null if not found at all
  43787. */
  43788. getLastEntryByID(id: string): Nullable<Node>;
  43789. /**
  43790. * Gets a node (Mesh, Camera, Light) using a given id
  43791. * @param id defines the id to search for
  43792. * @return the found node or null if not found at all
  43793. */
  43794. getNodeByID(id: string): Nullable<Node>;
  43795. /**
  43796. * Gets a node (Mesh, Camera, Light) using a given name
  43797. * @param name defines the name to search for
  43798. * @return the found node or null if not found at all.
  43799. */
  43800. getNodeByName(name: string): Nullable<Node>;
  43801. /**
  43802. * Gets a mesh using a given name
  43803. * @param name defines the name to search for
  43804. * @return the found mesh or null if not found at all.
  43805. */
  43806. getMeshByName(name: string): Nullable<AbstractMesh>;
  43807. /**
  43808. * Gets a transform node using a given name
  43809. * @param name defines the name to search for
  43810. * @return the found transform node or null if not found at all.
  43811. */
  43812. getTransformNodeByName(name: string): Nullable<TransformNode>;
  43813. /**
  43814. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  43815. * @param id defines the id to search for
  43816. * @return the found skeleton or null if not found at all.
  43817. */
  43818. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  43819. /**
  43820. * Gets a skeleton using a given auto generated unique id
  43821. * @param uniqueId defines the unique id to search for
  43822. * @return the found skeleton or null if not found at all.
  43823. */
  43824. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  43825. /**
  43826. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  43827. * @param id defines the id to search for
  43828. * @return the found skeleton or null if not found at all.
  43829. */
  43830. getSkeletonById(id: string): Nullable<Skeleton>;
  43831. /**
  43832. * Gets a skeleton using a given name
  43833. * @param name defines the name to search for
  43834. * @return the found skeleton or null if not found at all.
  43835. */
  43836. getSkeletonByName(name: string): Nullable<Skeleton>;
  43837. /**
  43838. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  43839. * @param id defines the id to search for
  43840. * @return the found morph target manager or null if not found at all.
  43841. */
  43842. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  43843. /**
  43844. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  43845. * @param id defines the id to search for
  43846. * @return the found morph target or null if not found at all.
  43847. */
  43848. getMorphTargetById(id: string): Nullable<MorphTarget>;
  43849. /**
  43850. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  43851. * @param name defines the name to search for
  43852. * @return the found morph target or null if not found at all.
  43853. */
  43854. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  43855. /**
  43856. * Gets a post process using a given name (if many are found, this function will pick the first one)
  43857. * @param name defines the name to search for
  43858. * @return the found post process or null if not found at all.
  43859. */
  43860. getPostProcessByName(name: string): Nullable<PostProcess>;
  43861. /**
  43862. * Gets a boolean indicating if the given mesh is active
  43863. * @param mesh defines the mesh to look for
  43864. * @returns true if the mesh is in the active list
  43865. */
  43866. isActiveMesh(mesh: AbstractMesh): boolean;
  43867. /**
  43868. * Return a unique id as a string which can serve as an identifier for the scene
  43869. */
  43870. get uid(): string;
  43871. /**
  43872. * Add an externaly attached data from its key.
  43873. * This method call will fail and return false, if such key already exists.
  43874. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  43875. * @param key the unique key that identifies the data
  43876. * @param data the data object to associate to the key for this Engine instance
  43877. * @return true if no such key were already present and the data was added successfully, false otherwise
  43878. */
  43879. addExternalData<T>(key: string, data: T): boolean;
  43880. /**
  43881. * Get an externaly attached data from its key
  43882. * @param key the unique key that identifies the data
  43883. * @return the associated data, if present (can be null), or undefined if not present
  43884. */
  43885. getExternalData<T>(key: string): Nullable<T>;
  43886. /**
  43887. * Get an externaly attached data from its key, create it using a factory if it's not already present
  43888. * @param key the unique key that identifies the data
  43889. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  43890. * @return the associated data, can be null if the factory returned null.
  43891. */
  43892. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  43893. /**
  43894. * Remove an externaly attached data from the Engine instance
  43895. * @param key the unique key that identifies the data
  43896. * @return true if the data was successfully removed, false if it doesn't exist
  43897. */
  43898. removeExternalData(key: string): boolean;
  43899. private _evaluateSubMesh;
  43900. /**
  43901. * Clear the processed materials smart array preventing retention point in material dispose.
  43902. */
  43903. freeProcessedMaterials(): void;
  43904. private _preventFreeActiveMeshesAndRenderingGroups;
  43905. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  43906. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  43907. * when disposing several meshes in a row or a hierarchy of meshes.
  43908. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  43909. */
  43910. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  43911. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  43912. /**
  43913. * Clear the active meshes smart array preventing retention point in mesh dispose.
  43914. */
  43915. freeActiveMeshes(): void;
  43916. /**
  43917. * Clear the info related to rendering groups preventing retention points during dispose.
  43918. */
  43919. freeRenderingGroups(): void;
  43920. /** @hidden */
  43921. _isInIntermediateRendering(): boolean;
  43922. /**
  43923. * Lambda returning the list of potentially active meshes.
  43924. */
  43925. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  43926. /**
  43927. * Lambda returning the list of potentially active sub meshes.
  43928. */
  43929. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  43930. /**
  43931. * Lambda returning the list of potentially intersecting sub meshes.
  43932. */
  43933. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  43934. /**
  43935. * Lambda returning the list of potentially colliding sub meshes.
  43936. */
  43937. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  43938. private _activeMeshesFrozen;
  43939. private _skipEvaluateActiveMeshesCompletely;
  43940. /**
  43941. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  43942. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  43943. * @param onSuccess optional success callback
  43944. * @param onError optional error callback
  43945. * @returns the current scene
  43946. */
  43947. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean, onSuccess?: () => void, onError?: (message: string) => void): Scene;
  43948. /**
  43949. * Use this function to restart evaluating active meshes on every frame
  43950. * @returns the current scene
  43951. */
  43952. unfreezeActiveMeshes(): Scene;
  43953. private _evaluateActiveMeshes;
  43954. private _activeMesh;
  43955. /**
  43956. * Update the transform matrix to update from the current active camera
  43957. * @param force defines a boolean used to force the update even if cache is up to date
  43958. */
  43959. updateTransformMatrix(force?: boolean): void;
  43960. private _bindFrameBuffer;
  43961. /** @hidden */
  43962. _allowPostProcessClearColor: boolean;
  43963. /** @hidden */
  43964. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  43965. private _processSubCameras;
  43966. private _checkIntersections;
  43967. /** @hidden */
  43968. _advancePhysicsEngineStep(step: number): void;
  43969. /**
  43970. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  43971. */
  43972. getDeterministicFrameTime: () => number;
  43973. /** @hidden */
  43974. _animate(): void;
  43975. /** Execute all animations (for a frame) */
  43976. animate(): void;
  43977. /**
  43978. * Render the scene
  43979. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  43980. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  43981. */
  43982. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  43983. /**
  43984. * Freeze all materials
  43985. * A frozen material will not be updatable but should be faster to render
  43986. */
  43987. freezeMaterials(): void;
  43988. /**
  43989. * Unfreeze all materials
  43990. * A frozen material will not be updatable but should be faster to render
  43991. */
  43992. unfreezeMaterials(): void;
  43993. /**
  43994. * Releases all held ressources
  43995. */
  43996. dispose(): void;
  43997. /**
  43998. * Gets if the scene is already disposed
  43999. */
  44000. get isDisposed(): boolean;
  44001. /**
  44002. * Call this function to reduce memory footprint of the scene.
  44003. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  44004. */
  44005. clearCachedVertexData(): void;
  44006. /**
  44007. * This function will remove the local cached buffer data from texture.
  44008. * It will save memory but will prevent the texture from being rebuilt
  44009. */
  44010. cleanCachedTextureBuffer(): void;
  44011. /**
  44012. * Get the world extend vectors with an optional filter
  44013. *
  44014. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  44015. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  44016. */
  44017. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  44018. min: Vector3;
  44019. max: Vector3;
  44020. };
  44021. /**
  44022. * Creates a ray that can be used to pick in the scene
  44023. * @param x defines the x coordinate of the origin (on-screen)
  44024. * @param y defines the y coordinate of the origin (on-screen)
  44025. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  44026. * @param camera defines the camera to use for the picking
  44027. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  44028. * @returns a Ray
  44029. */
  44030. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  44031. /**
  44032. * Creates a ray that can be used to pick in the scene
  44033. * @param x defines the x coordinate of the origin (on-screen)
  44034. * @param y defines the y coordinate of the origin (on-screen)
  44035. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  44036. * @param result defines the ray where to store the picking ray
  44037. * @param camera defines the camera to use for the picking
  44038. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  44039. * @returns the current scene
  44040. */
  44041. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  44042. /**
  44043. * Creates a ray that can be used to pick in the scene
  44044. * @param x defines the x coordinate of the origin (on-screen)
  44045. * @param y defines the y coordinate of the origin (on-screen)
  44046. * @param camera defines the camera to use for the picking
  44047. * @returns a Ray
  44048. */
  44049. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  44050. /**
  44051. * Creates a ray that can be used to pick in the scene
  44052. * @param x defines the x coordinate of the origin (on-screen)
  44053. * @param y defines the y coordinate of the origin (on-screen)
  44054. * @param result defines the ray where to store the picking ray
  44055. * @param camera defines the camera to use for the picking
  44056. * @returns the current scene
  44057. */
  44058. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  44059. /** Launch a ray to try to pick a mesh in the scene
  44060. * @param x position on screen
  44061. * @param y position on screen
  44062. * @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
  44063. * @param fastCheck defines if the first intersection will be used (and not the closest)
  44064. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  44065. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  44066. * @returns a PickingInfo
  44067. */
  44068. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  44069. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  44070. * @param x position on screen
  44071. * @param y position on screen
  44072. * @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
  44073. * @param fastCheck defines if the first intersection will be used (and not the closest)
  44074. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  44075. * @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)
  44076. */
  44077. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  44078. /** Use the given ray to pick a mesh in the scene
  44079. * @param ray The ray to use to pick meshes
  44080. * @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
  44081. * @param fastCheck defines if the first intersection will be used (and not the closest)
  44082. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  44083. * @returns a PickingInfo
  44084. */
  44085. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  44086. /**
  44087. * Launch a ray to try to pick a mesh in the scene
  44088. * @param x X position on screen
  44089. * @param y Y position on screen
  44090. * @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
  44091. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  44092. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  44093. * @returns an array of PickingInfo
  44094. */
  44095. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  44096. /**
  44097. * Launch a ray to try to pick a mesh in the scene
  44098. * @param ray Ray to use
  44099. * @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
  44100. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  44101. * @returns an array of PickingInfo
  44102. */
  44103. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  44104. /**
  44105. * Force the value of meshUnderPointer
  44106. * @param mesh defines the mesh to use
  44107. * @param pointerId optional pointer id when using more than one pointer
  44108. */
  44109. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  44110. /**
  44111. * Gets the mesh under the pointer
  44112. * @returns a Mesh or null if no mesh is under the pointer
  44113. */
  44114. getPointerOverMesh(): Nullable<AbstractMesh>;
  44115. /** @hidden */
  44116. _rebuildGeometries(): void;
  44117. /** @hidden */
  44118. _rebuildTextures(): void;
  44119. private _getByTags;
  44120. /**
  44121. * Get a list of meshes by tags
  44122. * @param tagsQuery defines the tags query to use
  44123. * @param forEach defines a predicate used to filter results
  44124. * @returns an array of Mesh
  44125. */
  44126. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  44127. /**
  44128. * Get a list of cameras by tags
  44129. * @param tagsQuery defines the tags query to use
  44130. * @param forEach defines a predicate used to filter results
  44131. * @returns an array of Camera
  44132. */
  44133. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  44134. /**
  44135. * Get a list of lights by tags
  44136. * @param tagsQuery defines the tags query to use
  44137. * @param forEach defines a predicate used to filter results
  44138. * @returns an array of Light
  44139. */
  44140. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  44141. /**
  44142. * Get a list of materials by tags
  44143. * @param tagsQuery defines the tags query to use
  44144. * @param forEach defines a predicate used to filter results
  44145. * @returns an array of Material
  44146. */
  44147. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  44148. /**
  44149. * Get a list of transform nodes by tags
  44150. * @param tagsQuery defines the tags query to use
  44151. * @param forEach defines a predicate used to filter results
  44152. * @returns an array of TransformNode
  44153. */
  44154. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  44155. /**
  44156. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  44157. * This allowed control for front to back rendering or reversly depending of the special needs.
  44158. *
  44159. * @param renderingGroupId The rendering group id corresponding to its index
  44160. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  44161. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  44162. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  44163. */
  44164. 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;
  44165. /**
  44166. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  44167. *
  44168. * @param renderingGroupId The rendering group id corresponding to its index
  44169. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  44170. * @param depth Automatically clears depth between groups if true and autoClear is true.
  44171. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  44172. */
  44173. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  44174. /**
  44175. * Gets the current auto clear configuration for one rendering group of the rendering
  44176. * manager.
  44177. * @param index the rendering group index to get the information for
  44178. * @returns The auto clear setup for the requested rendering group
  44179. */
  44180. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  44181. private _blockMaterialDirtyMechanism;
  44182. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  44183. get blockMaterialDirtyMechanism(): boolean;
  44184. set blockMaterialDirtyMechanism(value: boolean);
  44185. /**
  44186. * Will flag all materials as dirty to trigger new shader compilation
  44187. * @param flag defines the flag used to specify which material part must be marked as dirty
  44188. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  44189. */
  44190. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  44191. /** @hidden */
  44192. _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;
  44193. /** @hidden */
  44194. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  44195. /** @hidden */
  44196. _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;
  44197. /** @hidden */
  44198. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  44199. /** @hidden */
  44200. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  44201. /** @hidden */
  44202. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  44203. }
  44204. }
  44205. declare module BABYLON {
  44206. /**
  44207. * Set of assets to keep when moving a scene into an asset container.
  44208. */
  44209. export class KeepAssets extends AbstractScene {
  44210. }
  44211. /**
  44212. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  44213. */
  44214. export class InstantiatedEntries {
  44215. /**
  44216. * List of new root nodes (eg. nodes with no parent)
  44217. */
  44218. rootNodes: TransformNode[];
  44219. /**
  44220. * List of new skeletons
  44221. */
  44222. skeletons: Skeleton[];
  44223. /**
  44224. * List of new animation groups
  44225. */
  44226. animationGroups: AnimationGroup[];
  44227. }
  44228. /**
  44229. * Container with a set of assets that can be added or removed from a scene.
  44230. */
  44231. export class AssetContainer extends AbstractScene {
  44232. private _wasAddedToScene;
  44233. /**
  44234. * The scene the AssetContainer belongs to.
  44235. */
  44236. scene: Scene;
  44237. /**
  44238. * Instantiates an AssetContainer.
  44239. * @param scene The scene the AssetContainer belongs to.
  44240. */
  44241. constructor(scene: Scene);
  44242. /**
  44243. * Instantiate or clone all meshes and add the new ones to the scene.
  44244. * Skeletons and animation groups will all be cloned
  44245. * @param nameFunction defines an optional function used to get new names for clones
  44246. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  44247. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  44248. */
  44249. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  44250. /**
  44251. * Adds all the assets from the container to the scene.
  44252. */
  44253. addAllToScene(): void;
  44254. /**
  44255. * Removes all the assets in the container from the scene
  44256. */
  44257. removeAllFromScene(): void;
  44258. /**
  44259. * Disposes all the assets in the container
  44260. */
  44261. dispose(): void;
  44262. private _moveAssets;
  44263. /**
  44264. * Removes all the assets contained in the scene and adds them to the container.
  44265. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  44266. */
  44267. moveAllFromScene(keepAssets?: KeepAssets): void;
  44268. /**
  44269. * 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.
  44270. * @returns the root mesh
  44271. */
  44272. createRootMesh(): Mesh;
  44273. /**
  44274. * Merge animations (direct and animation groups) from this asset container into a scene
  44275. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  44276. * @param animatables set of animatables to retarget to a node from the scene
  44277. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  44278. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  44279. */
  44280. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  44281. }
  44282. }
  44283. declare module BABYLON {
  44284. /**
  44285. * Defines how the parser contract is defined.
  44286. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  44287. */
  44288. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  44289. /**
  44290. * Defines how the individual parser contract is defined.
  44291. * These parser can parse an individual asset
  44292. */
  44293. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  44294. /**
  44295. * Base class of the scene acting as a container for the different elements composing a scene.
  44296. * This class is dynamically extended by the different components of the scene increasing
  44297. * flexibility and reducing coupling
  44298. */
  44299. export abstract class AbstractScene {
  44300. /**
  44301. * Stores the list of available parsers in the application.
  44302. */
  44303. private static _BabylonFileParsers;
  44304. /**
  44305. * Stores the list of available individual parsers in the application.
  44306. */
  44307. private static _IndividualBabylonFileParsers;
  44308. /**
  44309. * Adds a parser in the list of available ones
  44310. * @param name Defines the name of the parser
  44311. * @param parser Defines the parser to add
  44312. */
  44313. static AddParser(name: string, parser: BabylonFileParser): void;
  44314. /**
  44315. * Gets a general parser from the list of avaialble ones
  44316. * @param name Defines the name of the parser
  44317. * @returns the requested parser or null
  44318. */
  44319. static GetParser(name: string): Nullable<BabylonFileParser>;
  44320. /**
  44321. * Adds n individual parser in the list of available ones
  44322. * @param name Defines the name of the parser
  44323. * @param parser Defines the parser to add
  44324. */
  44325. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  44326. /**
  44327. * Gets an individual parser from the list of avaialble ones
  44328. * @param name Defines the name of the parser
  44329. * @returns the requested parser or null
  44330. */
  44331. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  44332. /**
  44333. * Parser json data and populate both a scene and its associated container object
  44334. * @param jsonData Defines the data to parse
  44335. * @param scene Defines the scene to parse the data for
  44336. * @param container Defines the container attached to the parsing sequence
  44337. * @param rootUrl Defines the root url of the data
  44338. */
  44339. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  44340. /**
  44341. * Gets the list of root nodes (ie. nodes with no parent)
  44342. */
  44343. rootNodes: Node[];
  44344. /** All of the cameras added to this scene
  44345. * @see https://doc.babylonjs.com/babylon101/cameras
  44346. */
  44347. cameras: Camera[];
  44348. /**
  44349. * All of the lights added to this scene
  44350. * @see https://doc.babylonjs.com/babylon101/lights
  44351. */
  44352. lights: Light[];
  44353. /**
  44354. * All of the (abstract) meshes added to this scene
  44355. */
  44356. meshes: AbstractMesh[];
  44357. /**
  44358. * The list of skeletons added to the scene
  44359. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  44360. */
  44361. skeletons: Skeleton[];
  44362. /**
  44363. * All of the particle systems added to this scene
  44364. * @see https://doc.babylonjs.com/babylon101/particles
  44365. */
  44366. particleSystems: IParticleSystem[];
  44367. /**
  44368. * Gets a list of Animations associated with the scene
  44369. */
  44370. animations: Animation[];
  44371. /**
  44372. * All of the animation groups added to this scene
  44373. * @see https://doc.babylonjs.com/how_to/group
  44374. */
  44375. animationGroups: AnimationGroup[];
  44376. /**
  44377. * All of the multi-materials added to this scene
  44378. * @see https://doc.babylonjs.com/how_to/multi_materials
  44379. */
  44380. multiMaterials: MultiMaterial[];
  44381. /**
  44382. * All of the materials added to this scene
  44383. * In the context of a Scene, it is not supposed to be modified manually.
  44384. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  44385. * Note also that the order of the Material within the array is not significant and might change.
  44386. * @see https://doc.babylonjs.com/babylon101/materials
  44387. */
  44388. materials: Material[];
  44389. /**
  44390. * The list of morph target managers added to the scene
  44391. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  44392. */
  44393. morphTargetManagers: MorphTargetManager[];
  44394. /**
  44395. * The list of geometries used in the scene.
  44396. */
  44397. geometries: Geometry[];
  44398. /**
  44399. * All of the tranform nodes added to this scene
  44400. * In the context of a Scene, it is not supposed to be modified manually.
  44401. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  44402. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  44403. * @see https://doc.babylonjs.com/how_to/transformnode
  44404. */
  44405. transformNodes: TransformNode[];
  44406. /**
  44407. * ActionManagers available on the scene.
  44408. */
  44409. actionManagers: AbstractActionManager[];
  44410. /**
  44411. * Textures to keep.
  44412. */
  44413. textures: BaseTexture[];
  44414. /** @hidden */
  44415. protected _environmentTexture: Nullable<BaseTexture>;
  44416. /**
  44417. * Texture used in all pbr material as the reflection texture.
  44418. * As in the majority of the scene they are the same (exception for multi room and so on),
  44419. * this is easier to reference from here than from all the materials.
  44420. */
  44421. get environmentTexture(): Nullable<BaseTexture>;
  44422. set environmentTexture(value: Nullable<BaseTexture>);
  44423. /**
  44424. * The list of postprocesses added to the scene
  44425. */
  44426. postProcesses: PostProcess[];
  44427. /**
  44428. * @returns all meshes, lights, cameras, transformNodes and bones
  44429. */
  44430. getNodes(): Array<Node>;
  44431. }
  44432. }
  44433. declare module BABYLON {
  44434. /**
  44435. * Interface used to define options for Sound class
  44436. */
  44437. export interface ISoundOptions {
  44438. /**
  44439. * Does the sound autoplay once loaded.
  44440. */
  44441. autoplay?: boolean;
  44442. /**
  44443. * Does the sound loop after it finishes playing once.
  44444. */
  44445. loop?: boolean;
  44446. /**
  44447. * Sound's volume
  44448. */
  44449. volume?: number;
  44450. /**
  44451. * Is it a spatial sound?
  44452. */
  44453. spatialSound?: boolean;
  44454. /**
  44455. * Maximum distance to hear that sound
  44456. */
  44457. maxDistance?: number;
  44458. /**
  44459. * Uses user defined attenuation function
  44460. */
  44461. useCustomAttenuation?: boolean;
  44462. /**
  44463. * Define the roll off factor of spatial sounds.
  44464. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44465. */
  44466. rolloffFactor?: number;
  44467. /**
  44468. * Define the reference distance the sound should be heard perfectly.
  44469. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44470. */
  44471. refDistance?: number;
  44472. /**
  44473. * Define the distance attenuation model the sound will follow.
  44474. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44475. */
  44476. distanceModel?: string;
  44477. /**
  44478. * Defines the playback speed (1 by default)
  44479. */
  44480. playbackRate?: number;
  44481. /**
  44482. * Defines if the sound is from a streaming source
  44483. */
  44484. streaming?: boolean;
  44485. /**
  44486. * Defines an optional length (in seconds) inside the sound file
  44487. */
  44488. length?: number;
  44489. /**
  44490. * Defines an optional offset (in seconds) inside the sound file
  44491. */
  44492. offset?: number;
  44493. /**
  44494. * If true, URLs will not be required to state the audio file codec to use.
  44495. */
  44496. skipCodecCheck?: boolean;
  44497. }
  44498. /**
  44499. * Defines a sound that can be played in the application.
  44500. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  44501. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  44502. */
  44503. export class Sound {
  44504. /**
  44505. * The name of the sound in the scene.
  44506. */
  44507. name: string;
  44508. /**
  44509. * Does the sound autoplay once loaded.
  44510. */
  44511. autoplay: boolean;
  44512. /**
  44513. * Does the sound loop after it finishes playing once.
  44514. */
  44515. loop: boolean;
  44516. /**
  44517. * Does the sound use a custom attenuation curve to simulate the falloff
  44518. * happening when the source gets further away from the camera.
  44519. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  44520. */
  44521. useCustomAttenuation: boolean;
  44522. /**
  44523. * The sound track id this sound belongs to.
  44524. */
  44525. soundTrackId: number;
  44526. /**
  44527. * Is this sound currently played.
  44528. */
  44529. isPlaying: boolean;
  44530. /**
  44531. * Is this sound currently paused.
  44532. */
  44533. isPaused: boolean;
  44534. /**
  44535. * Does this sound enables spatial sound.
  44536. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44537. */
  44538. spatialSound: boolean;
  44539. /**
  44540. * Define the reference distance the sound should be heard perfectly.
  44541. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44542. */
  44543. refDistance: number;
  44544. /**
  44545. * Define the roll off factor of spatial sounds.
  44546. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44547. */
  44548. rolloffFactor: number;
  44549. /**
  44550. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  44551. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44552. */
  44553. maxDistance: number;
  44554. /**
  44555. * Define the distance attenuation model the sound will follow.
  44556. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44557. */
  44558. distanceModel: string;
  44559. /**
  44560. * @hidden
  44561. * Back Compat
  44562. **/
  44563. onended: () => any;
  44564. /**
  44565. * Gets or sets an object used to store user defined information for the sound.
  44566. */
  44567. metadata: any;
  44568. /**
  44569. * Observable event when the current playing sound finishes.
  44570. */
  44571. onEndedObservable: Observable<Sound>;
  44572. private _panningModel;
  44573. private _playbackRate;
  44574. private _streaming;
  44575. private _startTime;
  44576. private _startOffset;
  44577. private _position;
  44578. /** @hidden */
  44579. _positionInEmitterSpace: boolean;
  44580. private _localDirection;
  44581. private _volume;
  44582. private _isReadyToPlay;
  44583. private _isDirectional;
  44584. private _readyToPlayCallback;
  44585. private _audioBuffer;
  44586. private _soundSource;
  44587. private _streamingSource;
  44588. private _soundPanner;
  44589. private _soundGain;
  44590. private _inputAudioNode;
  44591. private _outputAudioNode;
  44592. private _coneInnerAngle;
  44593. private _coneOuterAngle;
  44594. private _coneOuterGain;
  44595. private _scene;
  44596. private _connectedTransformNode;
  44597. private _customAttenuationFunction;
  44598. private _registerFunc;
  44599. private _isOutputConnected;
  44600. private _htmlAudioElement;
  44601. private _urlType;
  44602. private _length?;
  44603. private _offset?;
  44604. /** @hidden */
  44605. static _SceneComponentInitialization: (scene: Scene) => void;
  44606. /**
  44607. * Create a sound and attach it to a scene
  44608. * @param name Name of your sound
  44609. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  44610. * @param scene defines the scene the sound belongs to
  44611. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  44612. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  44613. */
  44614. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  44615. /**
  44616. * Release the sound and its associated resources
  44617. */
  44618. dispose(): void;
  44619. /**
  44620. * Gets if the sounds is ready to be played or not.
  44621. * @returns true if ready, otherwise false
  44622. */
  44623. isReady(): boolean;
  44624. private _soundLoaded;
  44625. /**
  44626. * Sets the data of the sound from an audiobuffer
  44627. * @param audioBuffer The audioBuffer containing the data
  44628. */
  44629. setAudioBuffer(audioBuffer: AudioBuffer): void;
  44630. /**
  44631. * Updates the current sounds options such as maxdistance, loop...
  44632. * @param options A JSON object containing values named as the object properties
  44633. */
  44634. updateOptions(options: ISoundOptions): void;
  44635. private _createSpatialParameters;
  44636. private _updateSpatialParameters;
  44637. /**
  44638. * Switch the panning model to HRTF:
  44639. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  44640. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44641. */
  44642. switchPanningModelToHRTF(): void;
  44643. /**
  44644. * Switch the panning model to Equal Power:
  44645. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  44646. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44647. */
  44648. switchPanningModelToEqualPower(): void;
  44649. private _switchPanningModel;
  44650. /**
  44651. * Connect this sound to a sound track audio node like gain...
  44652. * @param soundTrackAudioNode the sound track audio node to connect to
  44653. */
  44654. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  44655. /**
  44656. * Transform this sound into a directional source
  44657. * @param coneInnerAngle Size of the inner cone in degree
  44658. * @param coneOuterAngle Size of the outer cone in degree
  44659. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  44660. */
  44661. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  44662. /**
  44663. * Gets or sets the inner angle for the directional cone.
  44664. */
  44665. get directionalConeInnerAngle(): number;
  44666. /**
  44667. * Gets or sets the inner angle for the directional cone.
  44668. */
  44669. set directionalConeInnerAngle(value: number);
  44670. /**
  44671. * Gets or sets the outer angle for the directional cone.
  44672. */
  44673. get directionalConeOuterAngle(): number;
  44674. /**
  44675. * Gets or sets the outer angle for the directional cone.
  44676. */
  44677. set directionalConeOuterAngle(value: number);
  44678. /**
  44679. * Sets the position of the emitter if spatial sound is enabled
  44680. * @param newPosition Defines the new posisiton
  44681. */
  44682. setPosition(newPosition: Vector3): void;
  44683. /**
  44684. * Sets the local direction of the emitter if spatial sound is enabled
  44685. * @param newLocalDirection Defines the new local direction
  44686. */
  44687. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  44688. private _updateDirection;
  44689. /** @hidden */
  44690. updateDistanceFromListener(): void;
  44691. /**
  44692. * Sets a new custom attenuation function for the sound.
  44693. * @param callback Defines the function used for the attenuation
  44694. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  44695. */
  44696. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  44697. /**
  44698. * Play the sound
  44699. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  44700. * @param offset (optional) Start the sound at a specific time in seconds
  44701. * @param length (optional) Sound duration (in seconds)
  44702. */
  44703. play(time?: number, offset?: number, length?: number): void;
  44704. private _onended;
  44705. /**
  44706. * Stop the sound
  44707. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  44708. */
  44709. stop(time?: number): void;
  44710. /**
  44711. * Put the sound in pause
  44712. */
  44713. pause(): void;
  44714. /**
  44715. * Sets a dedicated volume for this sounds
  44716. * @param newVolume Define the new volume of the sound
  44717. * @param time Define time for gradual change to new volume
  44718. */
  44719. setVolume(newVolume: number, time?: number): void;
  44720. /**
  44721. * Set the sound play back rate
  44722. * @param newPlaybackRate Define the playback rate the sound should be played at
  44723. */
  44724. setPlaybackRate(newPlaybackRate: number): void;
  44725. /**
  44726. * Gets the volume of the sound.
  44727. * @returns the volume of the sound
  44728. */
  44729. getVolume(): number;
  44730. /**
  44731. * Attach the sound to a dedicated mesh
  44732. * @param transformNode The transform node to connect the sound with
  44733. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  44734. */
  44735. attachToMesh(transformNode: TransformNode): void;
  44736. /**
  44737. * Detach the sound from the previously attached mesh
  44738. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  44739. */
  44740. detachFromMesh(): void;
  44741. private _onRegisterAfterWorldMatrixUpdate;
  44742. /**
  44743. * Clone the current sound in the scene.
  44744. * @returns the new sound clone
  44745. */
  44746. clone(): Nullable<Sound>;
  44747. /**
  44748. * Gets the current underlying audio buffer containing the data
  44749. * @returns the audio buffer
  44750. */
  44751. getAudioBuffer(): Nullable<AudioBuffer>;
  44752. /**
  44753. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  44754. * @returns the source node
  44755. */
  44756. getSoundSource(): Nullable<AudioBufferSourceNode>;
  44757. /**
  44758. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  44759. * @returns the gain node
  44760. */
  44761. getSoundGain(): Nullable<GainNode>;
  44762. /**
  44763. * Serializes the Sound in a JSON representation
  44764. * @returns the JSON representation of the sound
  44765. */
  44766. serialize(): any;
  44767. /**
  44768. * Parse a JSON representation of a sound to innstantiate in a given scene
  44769. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  44770. * @param scene Define the scene the new parsed sound should be created in
  44771. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  44772. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  44773. * @returns the newly parsed sound
  44774. */
  44775. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  44776. }
  44777. }
  44778. declare module BABYLON {
  44779. /**
  44780. * This defines an action helpful to play a defined sound on a triggered action.
  44781. */
  44782. export class PlaySoundAction extends Action {
  44783. private _sound;
  44784. /**
  44785. * Instantiate the action
  44786. * @param triggerOptions defines the trigger options
  44787. * @param sound defines the sound to play
  44788. * @param condition defines the trigger related conditions
  44789. */
  44790. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  44791. /** @hidden */
  44792. _prepare(): void;
  44793. /**
  44794. * Execute the action and play the sound.
  44795. */
  44796. execute(): void;
  44797. /**
  44798. * Serializes the actions and its related information.
  44799. * @param parent defines the object to serialize in
  44800. * @returns the serialized object
  44801. */
  44802. serialize(parent: any): any;
  44803. }
  44804. /**
  44805. * This defines an action helpful to stop a defined sound on a triggered action.
  44806. */
  44807. export class StopSoundAction extends Action {
  44808. private _sound;
  44809. /**
  44810. * Instantiate the action
  44811. * @param triggerOptions defines the trigger options
  44812. * @param sound defines the sound to stop
  44813. * @param condition defines the trigger related conditions
  44814. */
  44815. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  44816. /** @hidden */
  44817. _prepare(): void;
  44818. /**
  44819. * Execute the action and stop the sound.
  44820. */
  44821. execute(): void;
  44822. /**
  44823. * Serializes the actions and its related information.
  44824. * @param parent defines the object to serialize in
  44825. * @returns the serialized object
  44826. */
  44827. serialize(parent: any): any;
  44828. }
  44829. }
  44830. declare module BABYLON {
  44831. /**
  44832. * This defines an action responsible to change the value of a property
  44833. * by interpolating between its current value and the newly set one once triggered.
  44834. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  44835. */
  44836. export class InterpolateValueAction extends Action {
  44837. /**
  44838. * Defines the path of the property where the value should be interpolated
  44839. */
  44840. propertyPath: string;
  44841. /**
  44842. * Defines the target value at the end of the interpolation.
  44843. */
  44844. value: any;
  44845. /**
  44846. * Defines the time it will take for the property to interpolate to the value.
  44847. */
  44848. duration: number;
  44849. /**
  44850. * Defines if the other scene animations should be stopped when the action has been triggered
  44851. */
  44852. stopOtherAnimations?: boolean;
  44853. /**
  44854. * Defines a callback raised once the interpolation animation has been done.
  44855. */
  44856. onInterpolationDone?: () => void;
  44857. /**
  44858. * Observable triggered once the interpolation animation has been done.
  44859. */
  44860. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  44861. private _target;
  44862. private _effectiveTarget;
  44863. private _property;
  44864. /**
  44865. * Instantiate the action
  44866. * @param triggerOptions defines the trigger options
  44867. * @param target defines the object containing the value to interpolate
  44868. * @param propertyPath defines the path to the property in the target object
  44869. * @param value defines the target value at the end of the interpolation
  44870. * @param duration deines the time it will take for the property to interpolate to the value.
  44871. * @param condition defines the trigger related conditions
  44872. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  44873. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  44874. */
  44875. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  44876. /** @hidden */
  44877. _prepare(): void;
  44878. /**
  44879. * Execute the action starts the value interpolation.
  44880. */
  44881. execute(): void;
  44882. /**
  44883. * Serializes the actions and its related information.
  44884. * @param parent defines the object to serialize in
  44885. * @returns the serialized object
  44886. */
  44887. serialize(parent: any): any;
  44888. }
  44889. }
  44890. declare module BABYLON {
  44891. /**
  44892. * Options allowed during the creation of a sound track.
  44893. */
  44894. export interface ISoundTrackOptions {
  44895. /**
  44896. * The volume the sound track should take during creation
  44897. */
  44898. volume?: number;
  44899. /**
  44900. * Define if the sound track is the main sound track of the scene
  44901. */
  44902. mainTrack?: boolean;
  44903. }
  44904. /**
  44905. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  44906. * It will be also used in a future release to apply effects on a specific track.
  44907. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  44908. */
  44909. export class SoundTrack {
  44910. /**
  44911. * The unique identifier of the sound track in the scene.
  44912. */
  44913. id: number;
  44914. /**
  44915. * The list of sounds included in the sound track.
  44916. */
  44917. soundCollection: Array<Sound>;
  44918. private _outputAudioNode;
  44919. private _scene;
  44920. private _connectedAnalyser;
  44921. private _options;
  44922. private _isInitialized;
  44923. /**
  44924. * Creates a new sound track.
  44925. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  44926. * @param scene Define the scene the sound track belongs to
  44927. * @param options
  44928. */
  44929. constructor(scene: Scene, options?: ISoundTrackOptions);
  44930. private _initializeSoundTrackAudioGraph;
  44931. /**
  44932. * Release the sound track and its associated resources
  44933. */
  44934. dispose(): void;
  44935. /**
  44936. * Adds a sound to this sound track
  44937. * @param sound define the cound to add
  44938. * @ignoreNaming
  44939. */
  44940. AddSound(sound: Sound): void;
  44941. /**
  44942. * Removes a sound to this sound track
  44943. * @param sound define the cound to remove
  44944. * @ignoreNaming
  44945. */
  44946. RemoveSound(sound: Sound): void;
  44947. /**
  44948. * Set a global volume for the full sound track.
  44949. * @param newVolume Define the new volume of the sound track
  44950. */
  44951. setVolume(newVolume: number): void;
  44952. /**
  44953. * Switch the panning model to HRTF:
  44954. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  44955. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44956. */
  44957. switchPanningModelToHRTF(): void;
  44958. /**
  44959. * Switch the panning model to Equal Power:
  44960. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  44961. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  44962. */
  44963. switchPanningModelToEqualPower(): void;
  44964. /**
  44965. * Connect the sound track to an audio analyser allowing some amazing
  44966. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  44967. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  44968. * @param analyser The analyser to connect to the engine
  44969. */
  44970. connectToAnalyser(analyser: Analyser): void;
  44971. }
  44972. }
  44973. declare module BABYLON {
  44974. interface AbstractScene {
  44975. /**
  44976. * The list of sounds used in the scene.
  44977. */
  44978. sounds: Nullable<Array<Sound>>;
  44979. }
  44980. interface Scene {
  44981. /**
  44982. * @hidden
  44983. * Backing field
  44984. */
  44985. _mainSoundTrack: SoundTrack;
  44986. /**
  44987. * The main sound track played by the scene.
  44988. * It cotains your primary collection of sounds.
  44989. */
  44990. mainSoundTrack: SoundTrack;
  44991. /**
  44992. * The list of sound tracks added to the scene
  44993. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  44994. */
  44995. soundTracks: Nullable<Array<SoundTrack>>;
  44996. /**
  44997. * Gets a sound using a given name
  44998. * @param name defines the name to search for
  44999. * @return the found sound or null if not found at all.
  45000. */
  45001. getSoundByName(name: string): Nullable<Sound>;
  45002. /**
  45003. * Gets or sets if audio support is enabled
  45004. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45005. */
  45006. audioEnabled: boolean;
  45007. /**
  45008. * Gets or sets if audio will be output to headphones
  45009. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45010. */
  45011. headphone: boolean;
  45012. /**
  45013. * Gets or sets custom audio listener position provider
  45014. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  45015. */
  45016. audioListenerPositionProvider: Nullable<() => Vector3>;
  45017. /**
  45018. * Gets or sets a refresh rate when using 3D audio positioning
  45019. */
  45020. audioPositioningRefreshRate: number;
  45021. }
  45022. /**
  45023. * Defines the sound scene component responsible to manage any sounds
  45024. * in a given scene.
  45025. */
  45026. export class AudioSceneComponent implements ISceneSerializableComponent {
  45027. private static _CameraDirectionLH;
  45028. private static _CameraDirectionRH;
  45029. /**
  45030. * The component name helpfull to identify the component in the list of scene components.
  45031. */
  45032. readonly name: string;
  45033. /**
  45034. * The scene the component belongs to.
  45035. */
  45036. scene: Scene;
  45037. private _audioEnabled;
  45038. /**
  45039. * Gets whether audio is enabled or not.
  45040. * Please use related enable/disable method to switch state.
  45041. */
  45042. get audioEnabled(): boolean;
  45043. private _headphone;
  45044. /**
  45045. * Gets whether audio is outputing to headphone or not.
  45046. * Please use the according Switch methods to change output.
  45047. */
  45048. get headphone(): boolean;
  45049. /**
  45050. * Gets or sets a refresh rate when using 3D audio positioning
  45051. */
  45052. audioPositioningRefreshRate: number;
  45053. private _audioListenerPositionProvider;
  45054. /**
  45055. * Gets the current audio listener position provider
  45056. */
  45057. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  45058. /**
  45059. * Sets a custom listener position for all sounds in the scene
  45060. * By default, this is the position of the first active camera
  45061. */
  45062. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  45063. /**
  45064. * Creates a new instance of the component for the given scene
  45065. * @param scene Defines the scene to register the component in
  45066. */
  45067. constructor(scene: Scene);
  45068. /**
  45069. * Registers the component in a given scene
  45070. */
  45071. register(): void;
  45072. /**
  45073. * Rebuilds the elements related to this component in case of
  45074. * context lost for instance.
  45075. */
  45076. rebuild(): void;
  45077. /**
  45078. * Serializes the component data to the specified json object
  45079. * @param serializationObject The object to serialize to
  45080. */
  45081. serialize(serializationObject: any): void;
  45082. /**
  45083. * Adds all the elements from the container to the scene
  45084. * @param container the container holding the elements
  45085. */
  45086. addFromContainer(container: AbstractScene): void;
  45087. /**
  45088. * Removes all the elements in the container from the scene
  45089. * @param container contains the elements to remove
  45090. * @param dispose if the removed element should be disposed (default: false)
  45091. */
  45092. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  45093. /**
  45094. * Disposes the component and the associated ressources.
  45095. */
  45096. dispose(): void;
  45097. /**
  45098. * Disables audio in the associated scene.
  45099. */
  45100. disableAudio(): void;
  45101. /**
  45102. * Enables audio in the associated scene.
  45103. */
  45104. enableAudio(): void;
  45105. /**
  45106. * Switch audio to headphone output.
  45107. */
  45108. switchAudioModeForHeadphones(): void;
  45109. /**
  45110. * Switch audio to normal speakers.
  45111. */
  45112. switchAudioModeForNormalSpeakers(): void;
  45113. private _cachedCameraDirection;
  45114. private _cachedCameraPosition;
  45115. private _lastCheck;
  45116. private _afterRender;
  45117. }
  45118. }
  45119. declare module BABYLON {
  45120. /**
  45121. * Wraps one or more Sound objects and selects one with random weight for playback.
  45122. */
  45123. export class WeightedSound {
  45124. /** When true a Sound will be selected and played when the current playing Sound completes. */
  45125. loop: boolean;
  45126. private _coneInnerAngle;
  45127. private _coneOuterAngle;
  45128. private _volume;
  45129. /** A Sound is currently playing. */
  45130. isPlaying: boolean;
  45131. /** A Sound is currently paused. */
  45132. isPaused: boolean;
  45133. private _sounds;
  45134. private _weights;
  45135. private _currentIndex?;
  45136. /**
  45137. * Creates a new WeightedSound from the list of sounds given.
  45138. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  45139. * @param sounds Array of Sounds that will be selected from.
  45140. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  45141. */
  45142. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  45143. /**
  45144. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  45145. */
  45146. get directionalConeInnerAngle(): number;
  45147. /**
  45148. * The size of cone in degress for a directional sound in which there will be no attenuation.
  45149. */
  45150. set directionalConeInnerAngle(value: number);
  45151. /**
  45152. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  45153. * Listener angles between innerAngle and outerAngle will falloff linearly.
  45154. */
  45155. get directionalConeOuterAngle(): number;
  45156. /**
  45157. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  45158. * Listener angles between innerAngle and outerAngle will falloff linearly.
  45159. */
  45160. set directionalConeOuterAngle(value: number);
  45161. /**
  45162. * Playback volume.
  45163. */
  45164. get volume(): number;
  45165. /**
  45166. * Playback volume.
  45167. */
  45168. set volume(value: number);
  45169. private _onended;
  45170. /**
  45171. * Suspend playback
  45172. */
  45173. pause(): void;
  45174. /**
  45175. * Stop playback
  45176. */
  45177. stop(): void;
  45178. /**
  45179. * Start playback.
  45180. * @param startOffset Position the clip head at a specific time in seconds.
  45181. */
  45182. play(startOffset?: number): void;
  45183. }
  45184. }
  45185. declare module BABYLON {
  45186. /**
  45187. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  45188. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  45189. */
  45190. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  45191. /**
  45192. * Gets the name of the behavior.
  45193. */
  45194. get name(): string;
  45195. /**
  45196. * The easing function used by animations
  45197. */
  45198. static EasingFunction: BackEase;
  45199. /**
  45200. * The easing mode used by animations
  45201. */
  45202. static EasingMode: number;
  45203. /**
  45204. * The duration of the animation, in milliseconds
  45205. */
  45206. transitionDuration: number;
  45207. /**
  45208. * Length of the distance animated by the transition when lower radius is reached
  45209. */
  45210. lowerRadiusTransitionRange: number;
  45211. /**
  45212. * Length of the distance animated by the transition when upper radius is reached
  45213. */
  45214. upperRadiusTransitionRange: number;
  45215. private _autoTransitionRange;
  45216. /**
  45217. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  45218. */
  45219. get autoTransitionRange(): boolean;
  45220. /**
  45221. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  45222. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  45223. */
  45224. set autoTransitionRange(value: boolean);
  45225. private _attachedCamera;
  45226. private _onAfterCheckInputsObserver;
  45227. private _onMeshTargetChangedObserver;
  45228. /**
  45229. * Initializes the behavior.
  45230. */
  45231. init(): void;
  45232. /**
  45233. * Attaches the behavior to its arc rotate camera.
  45234. * @param camera Defines the camera to attach the behavior to
  45235. */
  45236. attach(camera: ArcRotateCamera): void;
  45237. /**
  45238. * Detaches the behavior from its current arc rotate camera.
  45239. */
  45240. detach(): void;
  45241. private _radiusIsAnimating;
  45242. private _radiusBounceTransition;
  45243. private _animatables;
  45244. private _cachedWheelPrecision;
  45245. /**
  45246. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  45247. * @param radiusLimit The limit to check against.
  45248. * @return Bool to indicate if at limit.
  45249. */
  45250. private _isRadiusAtLimit;
  45251. /**
  45252. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  45253. * @param radiusDelta The delta by which to animate to. Can be negative.
  45254. */
  45255. private _applyBoundRadiusAnimation;
  45256. /**
  45257. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  45258. */
  45259. protected _clearAnimationLocks(): void;
  45260. /**
  45261. * Stops and removes all animations that have been applied to the camera
  45262. */
  45263. stopAllAnimations(): void;
  45264. }
  45265. }
  45266. declare module BABYLON {
  45267. /**
  45268. * 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.
  45269. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  45270. */
  45271. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  45272. /**
  45273. * Gets the name of the behavior.
  45274. */
  45275. get name(): string;
  45276. private _mode;
  45277. private _radiusScale;
  45278. private _positionScale;
  45279. private _defaultElevation;
  45280. private _elevationReturnTime;
  45281. private _elevationReturnWaitTime;
  45282. private _zoomStopsAnimation;
  45283. private _framingTime;
  45284. /**
  45285. * The easing function used by animations
  45286. */
  45287. static EasingFunction: ExponentialEase;
  45288. /**
  45289. * The easing mode used by animations
  45290. */
  45291. static EasingMode: number;
  45292. /**
  45293. * Sets the current mode used by the behavior
  45294. */
  45295. set mode(mode: number);
  45296. /**
  45297. * Gets current mode used by the behavior.
  45298. */
  45299. get mode(): number;
  45300. /**
  45301. * Sets the scale applied to the radius (1 by default)
  45302. */
  45303. set radiusScale(radius: number);
  45304. /**
  45305. * Gets the scale applied to the radius
  45306. */
  45307. get radiusScale(): number;
  45308. /**
  45309. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  45310. */
  45311. set positionScale(scale: number);
  45312. /**
  45313. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  45314. */
  45315. get positionScale(): number;
  45316. /**
  45317. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  45318. * behaviour is triggered, in radians.
  45319. */
  45320. set defaultElevation(elevation: number);
  45321. /**
  45322. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  45323. * behaviour is triggered, in radians.
  45324. */
  45325. get defaultElevation(): number;
  45326. /**
  45327. * Sets the time (in milliseconds) taken to return to the default beta position.
  45328. * Negative value indicates camera should not return to default.
  45329. */
  45330. set elevationReturnTime(speed: number);
  45331. /**
  45332. * Gets the time (in milliseconds) taken to return to the default beta position.
  45333. * Negative value indicates camera should not return to default.
  45334. */
  45335. get elevationReturnTime(): number;
  45336. /**
  45337. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  45338. */
  45339. set elevationReturnWaitTime(time: number);
  45340. /**
  45341. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  45342. */
  45343. get elevationReturnWaitTime(): number;
  45344. /**
  45345. * Sets the flag that indicates if user zooming should stop animation.
  45346. */
  45347. set zoomStopsAnimation(flag: boolean);
  45348. /**
  45349. * Gets the flag that indicates if user zooming should stop animation.
  45350. */
  45351. get zoomStopsAnimation(): boolean;
  45352. /**
  45353. * Sets the transition time when framing the mesh, in milliseconds
  45354. */
  45355. set framingTime(time: number);
  45356. /**
  45357. * Gets the transition time when framing the mesh, in milliseconds
  45358. */
  45359. get framingTime(): number;
  45360. /**
  45361. * Define if the behavior should automatically change the configured
  45362. * camera limits and sensibilities.
  45363. */
  45364. autoCorrectCameraLimitsAndSensibility: boolean;
  45365. private _onPrePointerObservableObserver;
  45366. private _onAfterCheckInputsObserver;
  45367. private _onMeshTargetChangedObserver;
  45368. private _attachedCamera;
  45369. private _isPointerDown;
  45370. private _lastInteractionTime;
  45371. /**
  45372. * Initializes the behavior.
  45373. */
  45374. init(): void;
  45375. /**
  45376. * Attaches the behavior to its arc rotate camera.
  45377. * @param camera Defines the camera to attach the behavior to
  45378. */
  45379. attach(camera: ArcRotateCamera): void;
  45380. /**
  45381. * Detaches the behavior from its current arc rotate camera.
  45382. */
  45383. detach(): void;
  45384. private _animatables;
  45385. private _betaIsAnimating;
  45386. private _betaTransition;
  45387. private _radiusTransition;
  45388. private _vectorTransition;
  45389. /**
  45390. * Targets the given mesh and updates zoom level accordingly.
  45391. * @param mesh The mesh to target.
  45392. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  45393. * @param onAnimationEnd Callback triggered at the end of the framing animation
  45394. */
  45395. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  45396. /**
  45397. * Targets the given mesh with its children and updates zoom level accordingly.
  45398. * @param mesh The mesh to target.
  45399. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  45400. * @param onAnimationEnd Callback triggered at the end of the framing animation
  45401. */
  45402. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  45403. /**
  45404. * Targets the given meshes with their children and updates zoom level accordingly.
  45405. * @param meshes The mesh to target.
  45406. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  45407. * @param onAnimationEnd Callback triggered at the end of the framing animation
  45408. */
  45409. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  45410. /**
  45411. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  45412. * @param minimumWorld Determines the smaller position of the bounding box extend
  45413. * @param maximumWorld Determines the bigger position of the bounding box extend
  45414. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  45415. * @param onAnimationEnd Callback triggered at the end of the framing animation
  45416. */
  45417. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  45418. /**
  45419. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  45420. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  45421. * frustum width.
  45422. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  45423. * to fully enclose the mesh in the viewing frustum.
  45424. */
  45425. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  45426. /**
  45427. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  45428. * is automatically returned to its default position (expected to be above ground plane).
  45429. */
  45430. private _maintainCameraAboveGround;
  45431. /**
  45432. * Returns the frustum slope based on the canvas ratio and camera FOV
  45433. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  45434. */
  45435. private _getFrustumSlope;
  45436. /**
  45437. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  45438. */
  45439. private _clearAnimationLocks;
  45440. /**
  45441. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  45442. */
  45443. private _applyUserInteraction;
  45444. /**
  45445. * Stops and removes all animations that have been applied to the camera
  45446. */
  45447. stopAllAnimations(): void;
  45448. /**
  45449. * Gets a value indicating if the user is moving the camera
  45450. */
  45451. get isUserIsMoving(): boolean;
  45452. /**
  45453. * The camera can move all the way towards the mesh.
  45454. */
  45455. static IgnoreBoundsSizeMode: number;
  45456. /**
  45457. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  45458. */
  45459. static FitFrustumSidesMode: number;
  45460. }
  45461. }
  45462. declare module BABYLON {
  45463. /**
  45464. * Base class for Camera Pointer Inputs.
  45465. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  45466. * for example usage.
  45467. */
  45468. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  45469. /**
  45470. * Defines the camera the input is attached to.
  45471. */
  45472. abstract camera: Camera;
  45473. /**
  45474. * Whether keyboard modifier keys are pressed at time of last mouse event.
  45475. */
  45476. protected _altKey: boolean;
  45477. protected _ctrlKey: boolean;
  45478. protected _metaKey: boolean;
  45479. protected _shiftKey: boolean;
  45480. /**
  45481. * Which mouse buttons were pressed at time of last mouse event.
  45482. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  45483. */
  45484. protected _buttonsPressed: number;
  45485. /**
  45486. * Defines the buttons associated with the input to handle camera move.
  45487. */
  45488. buttons: number[];
  45489. /**
  45490. * Attach the input controls to a specific dom element to get the input from.
  45491. * @param element Defines the element the controls should be listened from
  45492. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45493. */
  45494. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45495. /**
  45496. * Detach the current controls from the specified dom element.
  45497. * @param element Defines the element to stop listening the inputs from
  45498. */
  45499. detachControl(element: Nullable<HTMLElement>): void;
  45500. /**
  45501. * Gets the class name of the current input.
  45502. * @returns the class name
  45503. */
  45504. getClassName(): string;
  45505. /**
  45506. * Get the friendly name associated with the input class.
  45507. * @returns the input friendly name
  45508. */
  45509. getSimpleName(): string;
  45510. /**
  45511. * Called on pointer POINTERDOUBLETAP event.
  45512. * Override this method to provide functionality on POINTERDOUBLETAP event.
  45513. */
  45514. protected onDoubleTap(type: string): void;
  45515. /**
  45516. * Called on pointer POINTERMOVE event if only a single touch is active.
  45517. * Override this method to provide functionality.
  45518. */
  45519. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  45520. /**
  45521. * Called on pointer POINTERMOVE event if multiple touches are active.
  45522. * Override this method to provide functionality.
  45523. */
  45524. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  45525. /**
  45526. * Called on JS contextmenu event.
  45527. * Override this method to provide functionality.
  45528. */
  45529. protected onContextMenu(evt: PointerEvent): void;
  45530. /**
  45531. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  45532. * press.
  45533. * Override this method to provide functionality.
  45534. */
  45535. protected onButtonDown(evt: PointerEvent): void;
  45536. /**
  45537. * Called each time a new POINTERUP event occurs. Ie, for each button
  45538. * release.
  45539. * Override this method to provide functionality.
  45540. */
  45541. protected onButtonUp(evt: PointerEvent): void;
  45542. /**
  45543. * Called when window becomes inactive.
  45544. * Override this method to provide functionality.
  45545. */
  45546. protected onLostFocus(): void;
  45547. private _pointerInput;
  45548. private _observer;
  45549. private _onLostFocus;
  45550. private pointA;
  45551. private pointB;
  45552. }
  45553. }
  45554. declare module BABYLON {
  45555. /**
  45556. * Manage the pointers inputs to control an arc rotate camera.
  45557. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45558. */
  45559. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  45560. /**
  45561. * Defines the camera the input is attached to.
  45562. */
  45563. camera: ArcRotateCamera;
  45564. /**
  45565. * Gets the class name of the current input.
  45566. * @returns the class name
  45567. */
  45568. getClassName(): string;
  45569. /**
  45570. * Defines the buttons associated with the input to handle camera move.
  45571. */
  45572. buttons: number[];
  45573. /**
  45574. * Defines the pointer angular sensibility along the X axis or how fast is
  45575. * the camera rotating.
  45576. */
  45577. angularSensibilityX: number;
  45578. /**
  45579. * Defines the pointer angular sensibility along the Y axis or how fast is
  45580. * the camera rotating.
  45581. */
  45582. angularSensibilityY: number;
  45583. /**
  45584. * Defines the pointer pinch precision or how fast is the camera zooming.
  45585. */
  45586. pinchPrecision: number;
  45587. /**
  45588. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  45589. * from 0.
  45590. * It defines the percentage of current camera.radius to use as delta when
  45591. * pinch zoom is used.
  45592. */
  45593. pinchDeltaPercentage: number;
  45594. /**
  45595. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  45596. * that any object in the plane at the camera's target point will scale
  45597. * perfectly with finger motion.
  45598. * Overrides pinchDeltaPercentage and pinchPrecision.
  45599. */
  45600. useNaturalPinchZoom: boolean;
  45601. /**
  45602. * Defines the pointer panning sensibility or how fast is the camera moving.
  45603. */
  45604. panningSensibility: number;
  45605. /**
  45606. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  45607. */
  45608. multiTouchPanning: boolean;
  45609. /**
  45610. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  45611. * zoom (pinch) through multitouch.
  45612. */
  45613. multiTouchPanAndZoom: boolean;
  45614. /**
  45615. * Revers pinch action direction.
  45616. */
  45617. pinchInwards: boolean;
  45618. private _isPanClick;
  45619. private _twoFingerActivityCount;
  45620. private _isPinching;
  45621. /**
  45622. * Called on pointer POINTERMOVE event if only a single touch is active.
  45623. */
  45624. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  45625. /**
  45626. * Called on pointer POINTERDOUBLETAP event.
  45627. */
  45628. protected onDoubleTap(type: string): void;
  45629. /**
  45630. * Called on pointer POINTERMOVE event if multiple touches are active.
  45631. */
  45632. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  45633. /**
  45634. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  45635. * press.
  45636. */
  45637. protected onButtonDown(evt: PointerEvent): void;
  45638. /**
  45639. * Called each time a new POINTERUP event occurs. Ie, for each button
  45640. * release.
  45641. */
  45642. protected onButtonUp(evt: PointerEvent): void;
  45643. /**
  45644. * Called when window becomes inactive.
  45645. */
  45646. protected onLostFocus(): void;
  45647. }
  45648. }
  45649. declare module BABYLON {
  45650. /**
  45651. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  45652. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45653. */
  45654. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  45655. /**
  45656. * Defines the camera the input is attached to.
  45657. */
  45658. camera: ArcRotateCamera;
  45659. /**
  45660. * Defines the list of key codes associated with the up action (increase alpha)
  45661. */
  45662. keysUp: number[];
  45663. /**
  45664. * Defines the list of key codes associated with the down action (decrease alpha)
  45665. */
  45666. keysDown: number[];
  45667. /**
  45668. * Defines the list of key codes associated with the left action (increase beta)
  45669. */
  45670. keysLeft: number[];
  45671. /**
  45672. * Defines the list of key codes associated with the right action (decrease beta)
  45673. */
  45674. keysRight: number[];
  45675. /**
  45676. * Defines the list of key codes associated with the reset action.
  45677. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  45678. */
  45679. keysReset: number[];
  45680. /**
  45681. * Defines the panning sensibility of the inputs.
  45682. * (How fast is the camera panning)
  45683. */
  45684. panningSensibility: number;
  45685. /**
  45686. * Defines the zooming sensibility of the inputs.
  45687. * (How fast is the camera zooming)
  45688. */
  45689. zoomingSensibility: number;
  45690. /**
  45691. * Defines whether maintaining the alt key down switch the movement mode from
  45692. * orientation to zoom.
  45693. */
  45694. useAltToZoom: boolean;
  45695. /**
  45696. * Rotation speed of the camera
  45697. */
  45698. angularSpeed: number;
  45699. private _keys;
  45700. private _ctrlPressed;
  45701. private _altPressed;
  45702. private _onCanvasBlurObserver;
  45703. private _onKeyboardObserver;
  45704. private _engine;
  45705. private _scene;
  45706. /**
  45707. * Attach the input controls to a specific dom element to get the input from.
  45708. * @param element Defines the element the controls should be listened from
  45709. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45710. */
  45711. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45712. /**
  45713. * Detach the current controls from the specified dom element.
  45714. * @param element Defines the element to stop listening the inputs from
  45715. */
  45716. detachControl(element: Nullable<HTMLElement>): void;
  45717. /**
  45718. * Update the current camera state depending on the inputs that have been used this frame.
  45719. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45720. */
  45721. checkInputs(): void;
  45722. /**
  45723. * Gets the class name of the current intput.
  45724. * @returns the class name
  45725. */
  45726. getClassName(): string;
  45727. /**
  45728. * Get the friendly name associated with the input class.
  45729. * @returns the input friendly name
  45730. */
  45731. getSimpleName(): string;
  45732. }
  45733. }
  45734. declare module BABYLON {
  45735. /**
  45736. * Manage the mouse wheel inputs to control an arc rotate camera.
  45737. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45738. */
  45739. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  45740. /**
  45741. * Defines the camera the input is attached to.
  45742. */
  45743. camera: ArcRotateCamera;
  45744. /**
  45745. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  45746. */
  45747. wheelPrecision: number;
  45748. /**
  45749. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  45750. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  45751. */
  45752. wheelDeltaPercentage: number;
  45753. private _wheel;
  45754. private _observer;
  45755. private computeDeltaFromMouseWheelLegacyEvent;
  45756. /**
  45757. * Attach the input controls to a specific dom element to get the input from.
  45758. * @param element Defines the element the controls should be listened from
  45759. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45760. */
  45761. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45762. /**
  45763. * Detach the current controls from the specified dom element.
  45764. * @param element Defines the element to stop listening the inputs from
  45765. */
  45766. detachControl(element: Nullable<HTMLElement>): void;
  45767. /**
  45768. * Gets the class name of the current intput.
  45769. * @returns the class name
  45770. */
  45771. getClassName(): string;
  45772. /**
  45773. * Get the friendly name associated with the input class.
  45774. * @returns the input friendly name
  45775. */
  45776. getSimpleName(): string;
  45777. }
  45778. }
  45779. declare module BABYLON {
  45780. /**
  45781. * Default Inputs manager for the ArcRotateCamera.
  45782. * It groups all the default supported inputs for ease of use.
  45783. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45784. */
  45785. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  45786. /**
  45787. * Instantiates a new ArcRotateCameraInputsManager.
  45788. * @param camera Defines the camera the inputs belong to
  45789. */
  45790. constructor(camera: ArcRotateCamera);
  45791. /**
  45792. * Add mouse wheel input support to the input manager.
  45793. * @returns the current input manager
  45794. */
  45795. addMouseWheel(): ArcRotateCameraInputsManager;
  45796. /**
  45797. * Add pointers input support to the input manager.
  45798. * @returns the current input manager
  45799. */
  45800. addPointers(): ArcRotateCameraInputsManager;
  45801. /**
  45802. * Add keyboard input support to the input manager.
  45803. * @returns the current input manager
  45804. */
  45805. addKeyboard(): ArcRotateCameraInputsManager;
  45806. }
  45807. }
  45808. declare module BABYLON {
  45809. /**
  45810. * This represents an orbital type of camera.
  45811. *
  45812. * 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.
  45813. * 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.
  45814. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  45815. */
  45816. export class ArcRotateCamera extends TargetCamera {
  45817. /**
  45818. * Defines the rotation angle of the camera along the longitudinal axis.
  45819. */
  45820. alpha: number;
  45821. /**
  45822. * Defines the rotation angle of the camera along the latitudinal axis.
  45823. */
  45824. beta: number;
  45825. /**
  45826. * Defines the radius of the camera from it s target point.
  45827. */
  45828. radius: number;
  45829. protected _target: Vector3;
  45830. protected _targetHost: Nullable<AbstractMesh>;
  45831. /**
  45832. * Defines the target point of the camera.
  45833. * The camera looks towards it form the radius distance.
  45834. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  45835. */
  45836. get target(): Vector3;
  45837. set target(value: Vector3);
  45838. /**
  45839. * Define the current local position of the camera in the scene
  45840. */
  45841. get position(): Vector3;
  45842. set position(newPosition: Vector3);
  45843. protected _upToYMatrix: Matrix;
  45844. protected _YToUpMatrix: Matrix;
  45845. /**
  45846. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  45847. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  45848. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  45849. */
  45850. set upVector(vec: Vector3);
  45851. get upVector(): Vector3;
  45852. /**
  45853. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  45854. */
  45855. setMatUp(): void;
  45856. /**
  45857. * Current inertia value on the longitudinal axis.
  45858. * The bigger this number the longer it will take for the camera to stop.
  45859. */
  45860. inertialAlphaOffset: number;
  45861. /**
  45862. * Current inertia value on the latitudinal axis.
  45863. * The bigger this number the longer it will take for the camera to stop.
  45864. */
  45865. inertialBetaOffset: number;
  45866. /**
  45867. * Current inertia value on the radius axis.
  45868. * The bigger this number the longer it will take for the camera to stop.
  45869. */
  45870. inertialRadiusOffset: number;
  45871. /**
  45872. * Minimum allowed angle on the longitudinal axis.
  45873. * This can help limiting how the Camera is able to move in the scene.
  45874. */
  45875. lowerAlphaLimit: Nullable<number>;
  45876. /**
  45877. * Maximum allowed angle on the longitudinal axis.
  45878. * This can help limiting how the Camera is able to move in the scene.
  45879. */
  45880. upperAlphaLimit: Nullable<number>;
  45881. /**
  45882. * Minimum allowed angle on the latitudinal axis.
  45883. * This can help limiting how the Camera is able to move in the scene.
  45884. */
  45885. lowerBetaLimit: number;
  45886. /**
  45887. * Maximum allowed angle on the latitudinal axis.
  45888. * This can help limiting how the Camera is able to move in the scene.
  45889. */
  45890. upperBetaLimit: number;
  45891. /**
  45892. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  45893. * This can help limiting how the Camera is able to move in the scene.
  45894. */
  45895. lowerRadiusLimit: Nullable<number>;
  45896. /**
  45897. * Maximum allowed distance of the camera to the target (The camera can not get further).
  45898. * This can help limiting how the Camera is able to move in the scene.
  45899. */
  45900. upperRadiusLimit: Nullable<number>;
  45901. /**
  45902. * Defines the current inertia value used during panning of the camera along the X axis.
  45903. */
  45904. inertialPanningX: number;
  45905. /**
  45906. * Defines the current inertia value used during panning of the camera along the Y axis.
  45907. */
  45908. inertialPanningY: number;
  45909. /**
  45910. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  45911. * Basically if your fingers moves away from more than this distance you will be considered
  45912. * in pinch mode.
  45913. */
  45914. pinchToPanMaxDistance: number;
  45915. /**
  45916. * Defines the maximum distance the camera can pan.
  45917. * This could help keeping the cammera always in your scene.
  45918. */
  45919. panningDistanceLimit: Nullable<number>;
  45920. /**
  45921. * Defines the target of the camera before paning.
  45922. */
  45923. panningOriginTarget: Vector3;
  45924. /**
  45925. * Defines the value of the inertia used during panning.
  45926. * 0 would mean stop inertia and one would mean no decelleration at all.
  45927. */
  45928. panningInertia: number;
  45929. /**
  45930. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  45931. */
  45932. get angularSensibilityX(): number;
  45933. set angularSensibilityX(value: number);
  45934. /**
  45935. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  45936. */
  45937. get angularSensibilityY(): number;
  45938. set angularSensibilityY(value: number);
  45939. /**
  45940. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  45941. */
  45942. get pinchPrecision(): number;
  45943. set pinchPrecision(value: number);
  45944. /**
  45945. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  45946. * It will be used instead of pinchDeltaPrecision if different from 0.
  45947. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  45948. */
  45949. get pinchDeltaPercentage(): number;
  45950. set pinchDeltaPercentage(value: number);
  45951. /**
  45952. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  45953. * and pinch delta percentage.
  45954. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  45955. * that any object in the plane at the camera's target point will scale
  45956. * perfectly with finger motion.
  45957. */
  45958. get useNaturalPinchZoom(): boolean;
  45959. set useNaturalPinchZoom(value: boolean);
  45960. /**
  45961. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  45962. */
  45963. get panningSensibility(): number;
  45964. set panningSensibility(value: number);
  45965. /**
  45966. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  45967. */
  45968. get keysUp(): number[];
  45969. set keysUp(value: number[]);
  45970. /**
  45971. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  45972. */
  45973. get keysDown(): number[];
  45974. set keysDown(value: number[]);
  45975. /**
  45976. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  45977. */
  45978. get keysLeft(): number[];
  45979. set keysLeft(value: number[]);
  45980. /**
  45981. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  45982. */
  45983. get keysRight(): number[];
  45984. set keysRight(value: number[]);
  45985. /**
  45986. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  45987. */
  45988. get wheelPrecision(): number;
  45989. set wheelPrecision(value: number);
  45990. /**
  45991. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  45992. * It will be used instead of pinchDeltaPrecision if different from 0.
  45993. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  45994. */
  45995. get wheelDeltaPercentage(): number;
  45996. set wheelDeltaPercentage(value: number);
  45997. /**
  45998. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  45999. */
  46000. zoomOnFactor: number;
  46001. /**
  46002. * Defines a screen offset for the camera position.
  46003. */
  46004. targetScreenOffset: Vector2;
  46005. /**
  46006. * Allows the camera to be completely reversed.
  46007. * If false the camera can not arrive upside down.
  46008. */
  46009. allowUpsideDown: boolean;
  46010. /**
  46011. * Define if double tap/click is used to restore the previously saved state of the camera.
  46012. */
  46013. useInputToRestoreState: boolean;
  46014. /** @hidden */
  46015. _viewMatrix: Matrix;
  46016. /** @hidden */
  46017. _useCtrlForPanning: boolean;
  46018. /** @hidden */
  46019. _panningMouseButton: number;
  46020. /**
  46021. * Defines the input associated to the camera.
  46022. */
  46023. inputs: ArcRotateCameraInputsManager;
  46024. /** @hidden */
  46025. _reset: () => void;
  46026. /**
  46027. * Defines the allowed panning axis.
  46028. */
  46029. panningAxis: Vector3;
  46030. protected _localDirection: Vector3;
  46031. protected _transformedDirection: Vector3;
  46032. private _bouncingBehavior;
  46033. /**
  46034. * Gets the bouncing behavior of the camera if it has been enabled.
  46035. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  46036. */
  46037. get bouncingBehavior(): Nullable<BouncingBehavior>;
  46038. /**
  46039. * Defines if the bouncing behavior of the camera is enabled on the camera.
  46040. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  46041. */
  46042. get useBouncingBehavior(): boolean;
  46043. set useBouncingBehavior(value: boolean);
  46044. private _framingBehavior;
  46045. /**
  46046. * Gets the framing behavior of the camera if it has been enabled.
  46047. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  46048. */
  46049. get framingBehavior(): Nullable<FramingBehavior>;
  46050. /**
  46051. * Defines if the framing behavior of the camera is enabled on the camera.
  46052. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  46053. */
  46054. get useFramingBehavior(): boolean;
  46055. set useFramingBehavior(value: boolean);
  46056. private _autoRotationBehavior;
  46057. /**
  46058. * Gets the auto rotation behavior of the camera if it has been enabled.
  46059. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  46060. */
  46061. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  46062. /**
  46063. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  46064. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  46065. */
  46066. get useAutoRotationBehavior(): boolean;
  46067. set useAutoRotationBehavior(value: boolean);
  46068. /**
  46069. * Observable triggered when the mesh target has been changed on the camera.
  46070. */
  46071. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  46072. /**
  46073. * Event raised when the camera is colliding with a mesh.
  46074. */
  46075. onCollide: (collidedMesh: AbstractMesh) => void;
  46076. /**
  46077. * Defines whether the camera should check collision with the objects oh the scene.
  46078. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  46079. */
  46080. checkCollisions: boolean;
  46081. /**
  46082. * Defines the collision radius of the camera.
  46083. * This simulates a sphere around the camera.
  46084. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  46085. */
  46086. collisionRadius: Vector3;
  46087. protected _collider: Collider;
  46088. protected _previousPosition: Vector3;
  46089. protected _collisionVelocity: Vector3;
  46090. protected _newPosition: Vector3;
  46091. protected _previousAlpha: number;
  46092. protected _previousBeta: number;
  46093. protected _previousRadius: number;
  46094. protected _collisionTriggered: boolean;
  46095. protected _targetBoundingCenter: Nullable<Vector3>;
  46096. private _computationVector;
  46097. /**
  46098. * Instantiates a new ArcRotateCamera in a given scene
  46099. * @param name Defines the name of the camera
  46100. * @param alpha Defines the camera rotation along the logitudinal axis
  46101. * @param beta Defines the camera rotation along the latitudinal axis
  46102. * @param radius Defines the camera distance from its target
  46103. * @param target Defines the camera target
  46104. * @param scene Defines the scene the camera belongs to
  46105. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  46106. */
  46107. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  46108. /** @hidden */
  46109. _initCache(): void;
  46110. /** @hidden */
  46111. _updateCache(ignoreParentClass?: boolean): void;
  46112. protected _getTargetPosition(): Vector3;
  46113. private _storedAlpha;
  46114. private _storedBeta;
  46115. private _storedRadius;
  46116. private _storedTarget;
  46117. private _storedTargetScreenOffset;
  46118. /**
  46119. * Stores the current state of the camera (alpha, beta, radius and target)
  46120. * @returns the camera itself
  46121. */
  46122. storeState(): Camera;
  46123. /**
  46124. * @hidden
  46125. * Restored camera state. You must call storeState() first
  46126. */
  46127. _restoreStateValues(): boolean;
  46128. /** @hidden */
  46129. _isSynchronizedViewMatrix(): boolean;
  46130. /**
  46131. * Attached controls to the current camera.
  46132. * @param element Defines the element the controls should be listened from
  46133. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46134. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  46135. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  46136. */
  46137. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  46138. /**
  46139. * Detach the current controls from the camera.
  46140. * The camera will stop reacting to inputs.
  46141. * @param element Defines the element to stop listening the inputs from
  46142. */
  46143. detachControl(element: HTMLElement): void;
  46144. /** @hidden */
  46145. _checkInputs(): void;
  46146. protected _checkLimits(): void;
  46147. /**
  46148. * Rebuilds angles (alpha, beta) and radius from the give position and target
  46149. */
  46150. rebuildAnglesAndRadius(): void;
  46151. /**
  46152. * Use a position to define the current camera related information like alpha, beta and radius
  46153. * @param position Defines the position to set the camera at
  46154. */
  46155. setPosition(position: Vector3): void;
  46156. /**
  46157. * Defines the target the camera should look at.
  46158. * This will automatically adapt alpha beta and radius to fit within the new target.
  46159. * @param target Defines the new target as a Vector or a mesh
  46160. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  46161. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  46162. */
  46163. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  46164. /** @hidden */
  46165. _getViewMatrix(): Matrix;
  46166. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  46167. /**
  46168. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  46169. * @param meshes Defines the mesh to zoom on
  46170. * @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)
  46171. */
  46172. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  46173. /**
  46174. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  46175. * The target will be changed but the radius
  46176. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  46177. * @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)
  46178. */
  46179. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  46180. min: Vector3;
  46181. max: Vector3;
  46182. distance: number;
  46183. }, doNotUpdateMaxZ?: boolean): void;
  46184. /**
  46185. * @override
  46186. * Override Camera.createRigCamera
  46187. */
  46188. createRigCamera(name: string, cameraIndex: number): Camera;
  46189. /**
  46190. * @hidden
  46191. * @override
  46192. * Override Camera._updateRigCameras
  46193. */
  46194. _updateRigCameras(): void;
  46195. /**
  46196. * Destroy the camera and release the current resources hold by it.
  46197. */
  46198. dispose(): void;
  46199. /**
  46200. * Gets the current object class name.
  46201. * @return the class name
  46202. */
  46203. getClassName(): string;
  46204. }
  46205. }
  46206. declare module BABYLON {
  46207. /**
  46208. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  46209. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  46210. */
  46211. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  46212. /**
  46213. * Gets the name of the behavior.
  46214. */
  46215. get name(): string;
  46216. private _zoomStopsAnimation;
  46217. private _idleRotationSpeed;
  46218. private _idleRotationWaitTime;
  46219. private _idleRotationSpinupTime;
  46220. /**
  46221. * Sets the flag that indicates if user zooming should stop animation.
  46222. */
  46223. set zoomStopsAnimation(flag: boolean);
  46224. /**
  46225. * Gets the flag that indicates if user zooming should stop animation.
  46226. */
  46227. get zoomStopsAnimation(): boolean;
  46228. /**
  46229. * Sets the default speed at which the camera rotates around the model.
  46230. */
  46231. set idleRotationSpeed(speed: number);
  46232. /**
  46233. * Gets the default speed at which the camera rotates around the model.
  46234. */
  46235. get idleRotationSpeed(): number;
  46236. /**
  46237. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  46238. */
  46239. set idleRotationWaitTime(time: number);
  46240. /**
  46241. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  46242. */
  46243. get idleRotationWaitTime(): number;
  46244. /**
  46245. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  46246. */
  46247. set idleRotationSpinupTime(time: number);
  46248. /**
  46249. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  46250. */
  46251. get idleRotationSpinupTime(): number;
  46252. /**
  46253. * Gets a value indicating if the camera is currently rotating because of this behavior
  46254. */
  46255. get rotationInProgress(): boolean;
  46256. private _onPrePointerObservableObserver;
  46257. private _onAfterCheckInputsObserver;
  46258. private _attachedCamera;
  46259. private _isPointerDown;
  46260. private _lastFrameTime;
  46261. private _lastInteractionTime;
  46262. private _cameraRotationSpeed;
  46263. /**
  46264. * Initializes the behavior.
  46265. */
  46266. init(): void;
  46267. /**
  46268. * Attaches the behavior to its arc rotate camera.
  46269. * @param camera Defines the camera to attach the behavior to
  46270. */
  46271. attach(camera: ArcRotateCamera): void;
  46272. /**
  46273. * Detaches the behavior from its current arc rotate camera.
  46274. */
  46275. detach(): void;
  46276. /**
  46277. * Returns true if user is scrolling.
  46278. * @return true if user is scrolling.
  46279. */
  46280. private _userIsZooming;
  46281. private _lastFrameRadius;
  46282. private _shouldAnimationStopForInteraction;
  46283. /**
  46284. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  46285. */
  46286. private _applyUserInteraction;
  46287. private _userIsMoving;
  46288. }
  46289. }
  46290. declare module BABYLON {
  46291. /**
  46292. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  46293. */
  46294. export class AttachToBoxBehavior implements Behavior<Mesh> {
  46295. private ui;
  46296. /**
  46297. * The name of the behavior
  46298. */
  46299. name: string;
  46300. /**
  46301. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  46302. */
  46303. distanceAwayFromFace: number;
  46304. /**
  46305. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  46306. */
  46307. distanceAwayFromBottomOfFace: number;
  46308. private _faceVectors;
  46309. private _target;
  46310. private _scene;
  46311. private _onRenderObserver;
  46312. private _tmpMatrix;
  46313. private _tmpVector;
  46314. /**
  46315. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  46316. * @param ui The transform node that should be attched to the mesh
  46317. */
  46318. constructor(ui: TransformNode);
  46319. /**
  46320. * Initializes the behavior
  46321. */
  46322. init(): void;
  46323. private _closestFace;
  46324. private _zeroVector;
  46325. private _lookAtTmpMatrix;
  46326. private _lookAtToRef;
  46327. /**
  46328. * Attaches the AttachToBoxBehavior to the passed in mesh
  46329. * @param target The mesh that the specified node will be attached to
  46330. */
  46331. attach(target: Mesh): void;
  46332. /**
  46333. * Detaches the behavior from the mesh
  46334. */
  46335. detach(): void;
  46336. }
  46337. }
  46338. declare module BABYLON {
  46339. /**
  46340. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  46341. */
  46342. export class FadeInOutBehavior implements Behavior<Mesh> {
  46343. /**
  46344. * Time in milliseconds to delay before fading in (Default: 0)
  46345. */
  46346. delay: number;
  46347. /**
  46348. * Time in milliseconds for the mesh to fade in (Default: 300)
  46349. */
  46350. fadeInTime: number;
  46351. private _millisecondsPerFrame;
  46352. private _hovered;
  46353. private _hoverValue;
  46354. private _ownerNode;
  46355. /**
  46356. * Instatiates the FadeInOutBehavior
  46357. */
  46358. constructor();
  46359. /**
  46360. * The name of the behavior
  46361. */
  46362. get name(): string;
  46363. /**
  46364. * Initializes the behavior
  46365. */
  46366. init(): void;
  46367. /**
  46368. * Attaches the fade behavior on the passed in mesh
  46369. * @param ownerNode The mesh that will be faded in/out once attached
  46370. */
  46371. attach(ownerNode: Mesh): void;
  46372. /**
  46373. * Detaches the behavior from the mesh
  46374. */
  46375. detach(): void;
  46376. /**
  46377. * Triggers the mesh to begin fading in or out
  46378. * @param value if the object should fade in or out (true to fade in)
  46379. */
  46380. fadeIn(value: boolean): void;
  46381. private _update;
  46382. private _setAllVisibility;
  46383. }
  46384. }
  46385. declare module BABYLON {
  46386. /**
  46387. * Class containing a set of static utilities functions for managing Pivots
  46388. * @hidden
  46389. */
  46390. export class PivotTools {
  46391. private static _PivotCached;
  46392. private static _OldPivotPoint;
  46393. private static _PivotTranslation;
  46394. private static _PivotTmpVector;
  46395. private static _PivotPostMultiplyPivotMatrix;
  46396. /** @hidden */
  46397. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  46398. /** @hidden */
  46399. static _RestorePivotPoint(mesh: AbstractMesh): void;
  46400. }
  46401. }
  46402. declare module BABYLON {
  46403. /**
  46404. * Class containing static functions to help procedurally build meshes
  46405. */
  46406. export class PlaneBuilder {
  46407. /**
  46408. * Creates a plane mesh
  46409. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  46410. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  46411. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  46412. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46413. * * 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
  46414. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46415. * @param name defines the name of the mesh
  46416. * @param options defines the options used to create the mesh
  46417. * @param scene defines the hosting scene
  46418. * @returns the plane mesh
  46419. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  46420. */
  46421. static CreatePlane(name: string, options: {
  46422. size?: number;
  46423. width?: number;
  46424. height?: number;
  46425. sideOrientation?: number;
  46426. frontUVs?: Vector4;
  46427. backUVs?: Vector4;
  46428. updatable?: boolean;
  46429. sourcePlane?: Plane;
  46430. }, scene?: Nullable<Scene>): Mesh;
  46431. }
  46432. }
  46433. declare module BABYLON {
  46434. /**
  46435. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  46436. */
  46437. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  46438. private static _AnyMouseID;
  46439. /**
  46440. * Abstract mesh the behavior is set on
  46441. */
  46442. attachedNode: AbstractMesh;
  46443. private _dragPlane;
  46444. private _scene;
  46445. private _pointerObserver;
  46446. private _beforeRenderObserver;
  46447. private static _planeScene;
  46448. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  46449. /**
  46450. * 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)
  46451. */
  46452. maxDragAngle: number;
  46453. /**
  46454. * @hidden
  46455. */
  46456. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  46457. /**
  46458. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  46459. */
  46460. currentDraggingPointerID: number;
  46461. /**
  46462. * The last position where the pointer hit the drag plane in world space
  46463. */
  46464. lastDragPosition: Vector3;
  46465. /**
  46466. * If the behavior is currently in a dragging state
  46467. */
  46468. dragging: boolean;
  46469. /**
  46470. * 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)
  46471. */
  46472. dragDeltaRatio: number;
  46473. /**
  46474. * If the drag plane orientation should be updated during the dragging (Default: true)
  46475. */
  46476. updateDragPlane: boolean;
  46477. private _debugMode;
  46478. private _moving;
  46479. /**
  46480. * Fires each time the attached mesh is dragged with the pointer
  46481. * * delta between last drag position and current drag position in world space
  46482. * * dragDistance along the drag axis
  46483. * * dragPlaneNormal normal of the current drag plane used during the drag
  46484. * * dragPlanePoint in world space where the drag intersects the drag plane
  46485. */
  46486. onDragObservable: Observable<{
  46487. delta: Vector3;
  46488. dragPlanePoint: Vector3;
  46489. dragPlaneNormal: Vector3;
  46490. dragDistance: number;
  46491. pointerId: number;
  46492. }>;
  46493. /**
  46494. * Fires each time a drag begins (eg. mouse down on mesh)
  46495. */
  46496. onDragStartObservable: Observable<{
  46497. dragPlanePoint: Vector3;
  46498. pointerId: number;
  46499. }>;
  46500. /**
  46501. * Fires each time a drag ends (eg. mouse release after drag)
  46502. */
  46503. onDragEndObservable: Observable<{
  46504. dragPlanePoint: Vector3;
  46505. pointerId: number;
  46506. }>;
  46507. /**
  46508. * If the attached mesh should be moved when dragged
  46509. */
  46510. moveAttached: boolean;
  46511. /**
  46512. * If the drag behavior will react to drag events (Default: true)
  46513. */
  46514. enabled: boolean;
  46515. /**
  46516. * If pointer events should start and release the drag (Default: true)
  46517. */
  46518. startAndReleaseDragOnPointerEvents: boolean;
  46519. /**
  46520. * If camera controls should be detached during the drag
  46521. */
  46522. detachCameraControls: boolean;
  46523. /**
  46524. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  46525. */
  46526. useObjectOrientationForDragging: boolean;
  46527. private _options;
  46528. /**
  46529. * Gets the options used by the behavior
  46530. */
  46531. get options(): {
  46532. dragAxis?: Vector3;
  46533. dragPlaneNormal?: Vector3;
  46534. };
  46535. /**
  46536. * Sets the options used by the behavior
  46537. */
  46538. set options(options: {
  46539. dragAxis?: Vector3;
  46540. dragPlaneNormal?: Vector3;
  46541. });
  46542. /**
  46543. * Creates a pointer drag behavior that can be attached to a mesh
  46544. * @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)
  46545. */
  46546. constructor(options?: {
  46547. dragAxis?: Vector3;
  46548. dragPlaneNormal?: Vector3;
  46549. });
  46550. /**
  46551. * Predicate to determine if it is valid to move the object to a new position when it is moved
  46552. */
  46553. validateDrag: (targetPosition: Vector3) => boolean;
  46554. /**
  46555. * The name of the behavior
  46556. */
  46557. get name(): string;
  46558. /**
  46559. * Initializes the behavior
  46560. */
  46561. init(): void;
  46562. private _tmpVector;
  46563. private _alternatePickedPoint;
  46564. private _worldDragAxis;
  46565. private _targetPosition;
  46566. private _attachedElement;
  46567. /**
  46568. * Attaches the drag behavior the passed in mesh
  46569. * @param ownerNode The mesh that will be dragged around once attached
  46570. * @param predicate Predicate to use for pick filtering
  46571. */
  46572. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  46573. /**
  46574. * Force relase the drag action by code.
  46575. */
  46576. releaseDrag(): void;
  46577. private _startDragRay;
  46578. private _lastPointerRay;
  46579. /**
  46580. * Simulates the start of a pointer drag event on the behavior
  46581. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  46582. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  46583. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  46584. */
  46585. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  46586. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  46587. private _dragDelta;
  46588. protected _moveDrag(ray: Ray): void;
  46589. private _pickWithRayOnDragPlane;
  46590. private _pointA;
  46591. private _pointC;
  46592. private _localAxis;
  46593. private _lookAt;
  46594. private _updateDragPlanePosition;
  46595. /**
  46596. * Detaches the behavior from the mesh
  46597. */
  46598. detach(): void;
  46599. }
  46600. }
  46601. declare module BABYLON {
  46602. /**
  46603. * A behavior that when attached to a mesh will allow the mesh to be scaled
  46604. */
  46605. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  46606. private _dragBehaviorA;
  46607. private _dragBehaviorB;
  46608. private _startDistance;
  46609. private _initialScale;
  46610. private _targetScale;
  46611. private _ownerNode;
  46612. private _sceneRenderObserver;
  46613. /**
  46614. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  46615. */
  46616. constructor();
  46617. /**
  46618. * The name of the behavior
  46619. */
  46620. get name(): string;
  46621. /**
  46622. * Initializes the behavior
  46623. */
  46624. init(): void;
  46625. private _getCurrentDistance;
  46626. /**
  46627. * Attaches the scale behavior the passed in mesh
  46628. * @param ownerNode The mesh that will be scaled around once attached
  46629. */
  46630. attach(ownerNode: Mesh): void;
  46631. /**
  46632. * Detaches the behavior from the mesh
  46633. */
  46634. detach(): void;
  46635. }
  46636. }
  46637. declare module BABYLON {
  46638. /**
  46639. * 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
  46640. */
  46641. export class SixDofDragBehavior implements Behavior<Mesh> {
  46642. private static _virtualScene;
  46643. private _ownerNode;
  46644. private _sceneRenderObserver;
  46645. private _scene;
  46646. private _targetPosition;
  46647. private _virtualOriginMesh;
  46648. private _virtualDragMesh;
  46649. private _pointerObserver;
  46650. private _moving;
  46651. private _startingOrientation;
  46652. private _attachedElement;
  46653. /**
  46654. * 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)
  46655. */
  46656. private zDragFactor;
  46657. /**
  46658. * If the object should rotate to face the drag origin
  46659. */
  46660. rotateDraggedObject: boolean;
  46661. /**
  46662. * If the behavior is currently in a dragging state
  46663. */
  46664. dragging: boolean;
  46665. /**
  46666. * 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)
  46667. */
  46668. dragDeltaRatio: number;
  46669. /**
  46670. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  46671. */
  46672. currentDraggingPointerID: number;
  46673. /**
  46674. * If camera controls should be detached during the drag
  46675. */
  46676. detachCameraControls: boolean;
  46677. /**
  46678. * Fires each time a drag starts
  46679. */
  46680. onDragStartObservable: Observable<{}>;
  46681. /**
  46682. * Fires each time a drag ends (eg. mouse release after drag)
  46683. */
  46684. onDragEndObservable: Observable<{}>;
  46685. /**
  46686. * 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
  46687. */
  46688. constructor();
  46689. /**
  46690. * The name of the behavior
  46691. */
  46692. get name(): string;
  46693. /**
  46694. * Initializes the behavior
  46695. */
  46696. init(): void;
  46697. /**
  46698. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  46699. */
  46700. private get _pointerCamera();
  46701. /**
  46702. * Attaches the scale behavior the passed in mesh
  46703. * @param ownerNode The mesh that will be scaled around once attached
  46704. */
  46705. attach(ownerNode: Mesh): void;
  46706. /**
  46707. * Detaches the behavior from the mesh
  46708. */
  46709. detach(): void;
  46710. }
  46711. }
  46712. declare module BABYLON {
  46713. /**
  46714. * Class used to apply inverse kinematics to bones
  46715. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  46716. */
  46717. export class BoneIKController {
  46718. private static _tmpVecs;
  46719. private static _tmpQuat;
  46720. private static _tmpMats;
  46721. /**
  46722. * Gets or sets the target mesh
  46723. */
  46724. targetMesh: AbstractMesh;
  46725. /** Gets or sets the mesh used as pole */
  46726. poleTargetMesh: AbstractMesh;
  46727. /**
  46728. * Gets or sets the bone used as pole
  46729. */
  46730. poleTargetBone: Nullable<Bone>;
  46731. /**
  46732. * Gets or sets the target position
  46733. */
  46734. targetPosition: Vector3;
  46735. /**
  46736. * Gets or sets the pole target position
  46737. */
  46738. poleTargetPosition: Vector3;
  46739. /**
  46740. * Gets or sets the pole target local offset
  46741. */
  46742. poleTargetLocalOffset: Vector3;
  46743. /**
  46744. * Gets or sets the pole angle
  46745. */
  46746. poleAngle: number;
  46747. /**
  46748. * Gets or sets the mesh associated with the controller
  46749. */
  46750. mesh: AbstractMesh;
  46751. /**
  46752. * 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)
  46753. */
  46754. slerpAmount: number;
  46755. private _bone1Quat;
  46756. private _bone1Mat;
  46757. private _bone2Ang;
  46758. private _bone1;
  46759. private _bone2;
  46760. private _bone1Length;
  46761. private _bone2Length;
  46762. private _maxAngle;
  46763. private _maxReach;
  46764. private _rightHandedSystem;
  46765. private _bendAxis;
  46766. private _slerping;
  46767. private _adjustRoll;
  46768. /**
  46769. * Gets or sets maximum allowed angle
  46770. */
  46771. get maxAngle(): number;
  46772. set maxAngle(value: number);
  46773. /**
  46774. * Creates a new BoneIKController
  46775. * @param mesh defines the mesh to control
  46776. * @param bone defines the bone to control
  46777. * @param options defines options to set up the controller
  46778. */
  46779. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  46780. targetMesh?: AbstractMesh;
  46781. poleTargetMesh?: AbstractMesh;
  46782. poleTargetBone?: Bone;
  46783. poleTargetLocalOffset?: Vector3;
  46784. poleAngle?: number;
  46785. bendAxis?: Vector3;
  46786. maxAngle?: number;
  46787. slerpAmount?: number;
  46788. });
  46789. private _setMaxAngle;
  46790. /**
  46791. * Force the controller to update the bones
  46792. */
  46793. update(): void;
  46794. }
  46795. }
  46796. declare module BABYLON {
  46797. /**
  46798. * Class used to make a bone look toward a point in space
  46799. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  46800. */
  46801. export class BoneLookController {
  46802. private static _tmpVecs;
  46803. private static _tmpQuat;
  46804. private static _tmpMats;
  46805. /**
  46806. * The target Vector3 that the bone will look at
  46807. */
  46808. target: Vector3;
  46809. /**
  46810. * The mesh that the bone is attached to
  46811. */
  46812. mesh: AbstractMesh;
  46813. /**
  46814. * The bone that will be looking to the target
  46815. */
  46816. bone: Bone;
  46817. /**
  46818. * The up axis of the coordinate system that is used when the bone is rotated
  46819. */
  46820. upAxis: Vector3;
  46821. /**
  46822. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  46823. */
  46824. upAxisSpace: Space;
  46825. /**
  46826. * Used to make an adjustment to the yaw of the bone
  46827. */
  46828. adjustYaw: number;
  46829. /**
  46830. * Used to make an adjustment to the pitch of the bone
  46831. */
  46832. adjustPitch: number;
  46833. /**
  46834. * Used to make an adjustment to the roll of the bone
  46835. */
  46836. adjustRoll: number;
  46837. /**
  46838. * 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)
  46839. */
  46840. slerpAmount: number;
  46841. private _minYaw;
  46842. private _maxYaw;
  46843. private _minPitch;
  46844. private _maxPitch;
  46845. private _minYawSin;
  46846. private _minYawCos;
  46847. private _maxYawSin;
  46848. private _maxYawCos;
  46849. private _midYawConstraint;
  46850. private _minPitchTan;
  46851. private _maxPitchTan;
  46852. private _boneQuat;
  46853. private _slerping;
  46854. private _transformYawPitch;
  46855. private _transformYawPitchInv;
  46856. private _firstFrameSkipped;
  46857. private _yawRange;
  46858. private _fowardAxis;
  46859. /**
  46860. * Gets or sets the minimum yaw angle that the bone can look to
  46861. */
  46862. get minYaw(): number;
  46863. set minYaw(value: number);
  46864. /**
  46865. * Gets or sets the maximum yaw angle that the bone can look to
  46866. */
  46867. get maxYaw(): number;
  46868. set maxYaw(value: number);
  46869. /**
  46870. * Gets or sets the minimum pitch angle that the bone can look to
  46871. */
  46872. get minPitch(): number;
  46873. set minPitch(value: number);
  46874. /**
  46875. * Gets or sets the maximum pitch angle that the bone can look to
  46876. */
  46877. get maxPitch(): number;
  46878. set maxPitch(value: number);
  46879. /**
  46880. * Create a BoneLookController
  46881. * @param mesh the mesh that the bone belongs to
  46882. * @param bone the bone that will be looking to the target
  46883. * @param target the target Vector3 to look at
  46884. * @param options optional settings:
  46885. * * maxYaw: the maximum angle the bone will yaw to
  46886. * * minYaw: the minimum angle the bone will yaw to
  46887. * * maxPitch: the maximum angle the bone will pitch to
  46888. * * minPitch: the minimum angle the bone will yaw to
  46889. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  46890. * * upAxis: the up axis of the coordinate system
  46891. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  46892. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  46893. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  46894. * * adjustYaw: used to make an adjustment to the yaw of the bone
  46895. * * adjustPitch: used to make an adjustment to the pitch of the bone
  46896. * * adjustRoll: used to make an adjustment to the roll of the bone
  46897. **/
  46898. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  46899. maxYaw?: number;
  46900. minYaw?: number;
  46901. maxPitch?: number;
  46902. minPitch?: number;
  46903. slerpAmount?: number;
  46904. upAxis?: Vector3;
  46905. upAxisSpace?: Space;
  46906. yawAxis?: Vector3;
  46907. pitchAxis?: Vector3;
  46908. adjustYaw?: number;
  46909. adjustPitch?: number;
  46910. adjustRoll?: number;
  46911. });
  46912. /**
  46913. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  46914. */
  46915. update(): void;
  46916. private _getAngleDiff;
  46917. private _getAngleBetween;
  46918. private _isAngleBetween;
  46919. }
  46920. }
  46921. declare module BABYLON {
  46922. /**
  46923. * Manage the gamepad inputs to control an arc rotate camera.
  46924. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46925. */
  46926. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  46927. /**
  46928. * Defines the camera the input is attached to.
  46929. */
  46930. camera: ArcRotateCamera;
  46931. /**
  46932. * Defines the gamepad the input is gathering event from.
  46933. */
  46934. gamepad: Nullable<Gamepad>;
  46935. /**
  46936. * Defines the gamepad rotation sensiblity.
  46937. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  46938. */
  46939. gamepadRotationSensibility: number;
  46940. /**
  46941. * Defines the gamepad move sensiblity.
  46942. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  46943. */
  46944. gamepadMoveSensibility: number;
  46945. private _yAxisScale;
  46946. /**
  46947. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  46948. */
  46949. get invertYAxis(): boolean;
  46950. set invertYAxis(value: boolean);
  46951. private _onGamepadConnectedObserver;
  46952. private _onGamepadDisconnectedObserver;
  46953. /**
  46954. * Attach the input controls to a specific dom element to get the input from.
  46955. * @param element Defines the element the controls should be listened from
  46956. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46957. */
  46958. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46959. /**
  46960. * Detach the current controls from the specified dom element.
  46961. * @param element Defines the element to stop listening the inputs from
  46962. */
  46963. detachControl(element: Nullable<HTMLElement>): void;
  46964. /**
  46965. * Update the current camera state depending on the inputs that have been used this frame.
  46966. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46967. */
  46968. checkInputs(): void;
  46969. /**
  46970. * Gets the class name of the current intput.
  46971. * @returns the class name
  46972. */
  46973. getClassName(): string;
  46974. /**
  46975. * Get the friendly name associated with the input class.
  46976. * @returns the input friendly name
  46977. */
  46978. getSimpleName(): string;
  46979. }
  46980. }
  46981. declare module BABYLON {
  46982. interface ArcRotateCameraInputsManager {
  46983. /**
  46984. * Add orientation input support to the input manager.
  46985. * @returns the current input manager
  46986. */
  46987. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  46988. }
  46989. /**
  46990. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  46991. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46992. */
  46993. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  46994. /**
  46995. * Defines the camera the input is attached to.
  46996. */
  46997. camera: ArcRotateCamera;
  46998. /**
  46999. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  47000. */
  47001. alphaCorrection: number;
  47002. /**
  47003. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  47004. */
  47005. gammaCorrection: number;
  47006. private _alpha;
  47007. private _gamma;
  47008. private _dirty;
  47009. private _deviceOrientationHandler;
  47010. /**
  47011. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  47012. */
  47013. constructor();
  47014. /**
  47015. * Attach the input controls to a specific dom element to get the input from.
  47016. * @param element Defines the element the controls should be listened from
  47017. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47018. */
  47019. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  47020. /** @hidden */
  47021. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  47022. /**
  47023. * Update the current camera state depending on the inputs that have been used this frame.
  47024. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  47025. */
  47026. checkInputs(): void;
  47027. /**
  47028. * Detach the current controls from the specified dom element.
  47029. * @param element Defines the element to stop listening the inputs from
  47030. */
  47031. detachControl(element: Nullable<HTMLElement>): void;
  47032. /**
  47033. * Gets the class name of the current intput.
  47034. * @returns the class name
  47035. */
  47036. getClassName(): string;
  47037. /**
  47038. * Get the friendly name associated with the input class.
  47039. * @returns the input friendly name
  47040. */
  47041. getSimpleName(): string;
  47042. }
  47043. }
  47044. declare module BABYLON {
  47045. /**
  47046. * Listen to mouse events to control the camera.
  47047. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47048. */
  47049. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  47050. /**
  47051. * Defines the camera the input is attached to.
  47052. */
  47053. camera: FlyCamera;
  47054. /**
  47055. * Defines if touch is enabled. (Default is true.)
  47056. */
  47057. touchEnabled: boolean;
  47058. /**
  47059. * Defines the buttons associated with the input to handle camera rotation.
  47060. */
  47061. buttons: number[];
  47062. /**
  47063. * Assign buttons for Yaw control.
  47064. */
  47065. buttonsYaw: number[];
  47066. /**
  47067. * Assign buttons for Pitch control.
  47068. */
  47069. buttonsPitch: number[];
  47070. /**
  47071. * Assign buttons for Roll control.
  47072. */
  47073. buttonsRoll: number[];
  47074. /**
  47075. * Detect if any button is being pressed while mouse is moved.
  47076. * -1 = Mouse locked.
  47077. * 0 = Left button.
  47078. * 1 = Middle Button.
  47079. * 2 = Right Button.
  47080. */
  47081. activeButton: number;
  47082. /**
  47083. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  47084. * Higher values reduce its sensitivity.
  47085. */
  47086. angularSensibility: number;
  47087. private _observer;
  47088. private _rollObserver;
  47089. private previousPosition;
  47090. private noPreventDefault;
  47091. private element;
  47092. /**
  47093. * Listen to mouse events to control the camera.
  47094. * @param touchEnabled Define if touch is enabled. (Default is true.)
  47095. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47096. */
  47097. constructor(touchEnabled?: boolean);
  47098. /**
  47099. * Attach the mouse control to the HTML DOM element.
  47100. * @param element Defines the element that listens to the input events.
  47101. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  47102. */
  47103. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  47104. /**
  47105. * Detach the current controls from the specified dom element.
  47106. * @param element Defines the element to stop listening the inputs from
  47107. */
  47108. detachControl(element: Nullable<HTMLElement>): void;
  47109. /**
  47110. * Gets the class name of the current input.
  47111. * @returns the class name.
  47112. */
  47113. getClassName(): string;
  47114. /**
  47115. * Get the friendly name associated with the input class.
  47116. * @returns the input's friendly name.
  47117. */
  47118. getSimpleName(): string;
  47119. private _pointerInput;
  47120. private _onMouseMove;
  47121. /**
  47122. * Rotate camera by mouse offset.
  47123. */
  47124. private rotateCamera;
  47125. }
  47126. }
  47127. declare module BABYLON {
  47128. /**
  47129. * Default Inputs manager for the FlyCamera.
  47130. * It groups all the default supported inputs for ease of use.
  47131. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47132. */
  47133. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  47134. /**
  47135. * Instantiates a new FlyCameraInputsManager.
  47136. * @param camera Defines the camera the inputs belong to.
  47137. */
  47138. constructor(camera: FlyCamera);
  47139. /**
  47140. * Add keyboard input support to the input manager.
  47141. * @returns the new FlyCameraKeyboardMoveInput().
  47142. */
  47143. addKeyboard(): FlyCameraInputsManager;
  47144. /**
  47145. * Add mouse input support to the input manager.
  47146. * @param touchEnabled Enable touch screen support.
  47147. * @returns the new FlyCameraMouseInput().
  47148. */
  47149. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  47150. }
  47151. }
  47152. declare module BABYLON {
  47153. /**
  47154. * This is a flying camera, designed for 3D movement and rotation in all directions,
  47155. * such as in a 3D Space Shooter or a Flight Simulator.
  47156. */
  47157. export class FlyCamera extends TargetCamera {
  47158. /**
  47159. * Define the collision ellipsoid of the camera.
  47160. * This is helpful for simulating a camera body, like a player's body.
  47161. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  47162. */
  47163. ellipsoid: Vector3;
  47164. /**
  47165. * Define an offset for the position of the ellipsoid around the camera.
  47166. * This can be helpful if the camera is attached away from the player's body center,
  47167. * such as at its head.
  47168. */
  47169. ellipsoidOffset: Vector3;
  47170. /**
  47171. * Enable or disable collisions of the camera with the rest of the scene objects.
  47172. */
  47173. checkCollisions: boolean;
  47174. /**
  47175. * Enable or disable gravity on the camera.
  47176. */
  47177. applyGravity: boolean;
  47178. /**
  47179. * Define the current direction the camera is moving to.
  47180. */
  47181. cameraDirection: Vector3;
  47182. /**
  47183. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  47184. * This overrides and empties cameraRotation.
  47185. */
  47186. rotationQuaternion: Quaternion;
  47187. /**
  47188. * Track Roll to maintain the wanted Rolling when looking around.
  47189. */
  47190. _trackRoll: number;
  47191. /**
  47192. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  47193. */
  47194. rollCorrect: number;
  47195. /**
  47196. * Mimic a banked turn, Rolling the camera when Yawing.
  47197. * It's recommended to use rollCorrect = 10 for faster banking correction.
  47198. */
  47199. bankedTurn: boolean;
  47200. /**
  47201. * Limit in radians for how much Roll banking will add. (Default: 90°)
  47202. */
  47203. bankedTurnLimit: number;
  47204. /**
  47205. * Value of 0 disables the banked Roll.
  47206. * Value of 1 is equal to the Yaw angle in radians.
  47207. */
  47208. bankedTurnMultiplier: number;
  47209. /**
  47210. * The inputs manager loads all the input sources, such as keyboard and mouse.
  47211. */
  47212. inputs: FlyCameraInputsManager;
  47213. /**
  47214. * Gets the input sensibility for mouse input.
  47215. * Higher values reduce sensitivity.
  47216. */
  47217. get angularSensibility(): number;
  47218. /**
  47219. * Sets the input sensibility for a mouse input.
  47220. * Higher values reduce sensitivity.
  47221. */
  47222. set angularSensibility(value: number);
  47223. /**
  47224. * Get the keys for camera movement forward.
  47225. */
  47226. get keysForward(): number[];
  47227. /**
  47228. * Set the keys for camera movement forward.
  47229. */
  47230. set keysForward(value: number[]);
  47231. /**
  47232. * Get the keys for camera movement backward.
  47233. */
  47234. get keysBackward(): number[];
  47235. set keysBackward(value: number[]);
  47236. /**
  47237. * Get the keys for camera movement up.
  47238. */
  47239. get keysUp(): number[];
  47240. /**
  47241. * Set the keys for camera movement up.
  47242. */
  47243. set keysUp(value: number[]);
  47244. /**
  47245. * Get the keys for camera movement down.
  47246. */
  47247. get keysDown(): number[];
  47248. /**
  47249. * Set the keys for camera movement down.
  47250. */
  47251. set keysDown(value: number[]);
  47252. /**
  47253. * Get the keys for camera movement left.
  47254. */
  47255. get keysLeft(): number[];
  47256. /**
  47257. * Set the keys for camera movement left.
  47258. */
  47259. set keysLeft(value: number[]);
  47260. /**
  47261. * Set the keys for camera movement right.
  47262. */
  47263. get keysRight(): number[];
  47264. /**
  47265. * Set the keys for camera movement right.
  47266. */
  47267. set keysRight(value: number[]);
  47268. /**
  47269. * Event raised when the camera collides with a mesh in the scene.
  47270. */
  47271. onCollide: (collidedMesh: AbstractMesh) => void;
  47272. private _collider;
  47273. private _needMoveForGravity;
  47274. private _oldPosition;
  47275. private _diffPosition;
  47276. private _newPosition;
  47277. /** @hidden */
  47278. _localDirection: Vector3;
  47279. /** @hidden */
  47280. _transformedDirection: Vector3;
  47281. /**
  47282. * Instantiates a FlyCamera.
  47283. * This is a flying camera, designed for 3D movement and rotation in all directions,
  47284. * such as in a 3D Space Shooter or a Flight Simulator.
  47285. * @param name Define the name of the camera in the scene.
  47286. * @param position Define the starting position of the camera in the scene.
  47287. * @param scene Define the scene the camera belongs to.
  47288. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  47289. */
  47290. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  47291. /**
  47292. * Attach a control to the HTML DOM element.
  47293. * @param element Defines the element that listens to the input events.
  47294. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  47295. */
  47296. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  47297. /**
  47298. * Detach a control from the HTML DOM element.
  47299. * The camera will stop reacting to that input.
  47300. * @param element Defines the element that listens to the input events.
  47301. */
  47302. detachControl(element: HTMLElement): void;
  47303. private _collisionMask;
  47304. /**
  47305. * Get the mask that the camera ignores in collision events.
  47306. */
  47307. get collisionMask(): number;
  47308. /**
  47309. * Set the mask that the camera ignores in collision events.
  47310. */
  47311. set collisionMask(mask: number);
  47312. /** @hidden */
  47313. _collideWithWorld(displacement: Vector3): void;
  47314. /** @hidden */
  47315. private _onCollisionPositionChange;
  47316. /** @hidden */
  47317. _checkInputs(): void;
  47318. /** @hidden */
  47319. _decideIfNeedsToMove(): boolean;
  47320. /** @hidden */
  47321. _updatePosition(): void;
  47322. /**
  47323. * Restore the Roll to its target value at the rate specified.
  47324. * @param rate - Higher means slower restoring.
  47325. * @hidden
  47326. */
  47327. restoreRoll(rate: number): void;
  47328. /**
  47329. * Destroy the camera and release the current resources held by it.
  47330. */
  47331. dispose(): void;
  47332. /**
  47333. * Get the current object class name.
  47334. * @returns the class name.
  47335. */
  47336. getClassName(): string;
  47337. }
  47338. }
  47339. declare module BABYLON {
  47340. /**
  47341. * Listen to keyboard events to control the camera.
  47342. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47343. */
  47344. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  47345. /**
  47346. * Defines the camera the input is attached to.
  47347. */
  47348. camera: FlyCamera;
  47349. /**
  47350. * The list of keyboard keys used to control the forward move of the camera.
  47351. */
  47352. keysForward: number[];
  47353. /**
  47354. * The list of keyboard keys used to control the backward move of the camera.
  47355. */
  47356. keysBackward: number[];
  47357. /**
  47358. * The list of keyboard keys used to control the forward move of the camera.
  47359. */
  47360. keysUp: number[];
  47361. /**
  47362. * The list of keyboard keys used to control the backward move of the camera.
  47363. */
  47364. keysDown: number[];
  47365. /**
  47366. * The list of keyboard keys used to control the right strafe move of the camera.
  47367. */
  47368. keysRight: number[];
  47369. /**
  47370. * The list of keyboard keys used to control the left strafe move of the camera.
  47371. */
  47372. keysLeft: number[];
  47373. private _keys;
  47374. private _onCanvasBlurObserver;
  47375. private _onKeyboardObserver;
  47376. private _engine;
  47377. private _scene;
  47378. /**
  47379. * Attach the input controls to a specific dom element to get the input from.
  47380. * @param element Defines the element the controls should be listened from
  47381. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47382. */
  47383. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  47384. /**
  47385. * Detach the current controls from the specified dom element.
  47386. * @param element Defines the element to stop listening the inputs from
  47387. */
  47388. detachControl(element: Nullable<HTMLElement>): void;
  47389. /**
  47390. * Gets the class name of the current intput.
  47391. * @returns the class name
  47392. */
  47393. getClassName(): string;
  47394. /** @hidden */
  47395. _onLostFocus(e: FocusEvent): void;
  47396. /**
  47397. * Get the friendly name associated with the input class.
  47398. * @returns the input friendly name
  47399. */
  47400. getSimpleName(): string;
  47401. /**
  47402. * Update the current camera state depending on the inputs that have been used this frame.
  47403. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  47404. */
  47405. checkInputs(): void;
  47406. }
  47407. }
  47408. declare module BABYLON {
  47409. /**
  47410. * Manage the mouse wheel inputs to control a follow camera.
  47411. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47412. */
  47413. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  47414. /**
  47415. * Defines the camera the input is attached to.
  47416. */
  47417. camera: FollowCamera;
  47418. /**
  47419. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  47420. */
  47421. axisControlRadius: boolean;
  47422. /**
  47423. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  47424. */
  47425. axisControlHeight: boolean;
  47426. /**
  47427. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  47428. */
  47429. axisControlRotation: boolean;
  47430. /**
  47431. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  47432. * relation to mouseWheel events.
  47433. */
  47434. wheelPrecision: number;
  47435. /**
  47436. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  47437. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  47438. */
  47439. wheelDeltaPercentage: number;
  47440. private _wheel;
  47441. private _observer;
  47442. /**
  47443. * Attach the input controls to a specific dom element to get the input from.
  47444. * @param element Defines the element the controls should be listened from
  47445. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47446. */
  47447. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  47448. /**
  47449. * Detach the current controls from the specified dom element.
  47450. * @param element Defines the element to stop listening the inputs from
  47451. */
  47452. detachControl(element: Nullable<HTMLElement>): void;
  47453. /**
  47454. * Gets the class name of the current intput.
  47455. * @returns the class name
  47456. */
  47457. getClassName(): string;
  47458. /**
  47459. * Get the friendly name associated with the input class.
  47460. * @returns the input friendly name
  47461. */
  47462. getSimpleName(): string;
  47463. }
  47464. }
  47465. declare module BABYLON {
  47466. /**
  47467. * Manage the pointers inputs to control an follow camera.
  47468. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47469. */
  47470. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  47471. /**
  47472. * Defines the camera the input is attached to.
  47473. */
  47474. camera: FollowCamera;
  47475. /**
  47476. * Gets the class name of the current input.
  47477. * @returns the class name
  47478. */
  47479. getClassName(): string;
  47480. /**
  47481. * Defines the pointer angular sensibility along the X axis or how fast is
  47482. * the camera rotating.
  47483. * A negative number will reverse the axis direction.
  47484. */
  47485. angularSensibilityX: number;
  47486. /**
  47487. * Defines the pointer angular sensibility along the Y axis or how fast is
  47488. * the camera rotating.
  47489. * A negative number will reverse the axis direction.
  47490. */
  47491. angularSensibilityY: number;
  47492. /**
  47493. * Defines the pointer pinch precision or how fast is the camera zooming.
  47494. * A negative number will reverse the axis direction.
  47495. */
  47496. pinchPrecision: number;
  47497. /**
  47498. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  47499. * from 0.
  47500. * It defines the percentage of current camera.radius to use as delta when
  47501. * pinch zoom is used.
  47502. */
  47503. pinchDeltaPercentage: number;
  47504. /**
  47505. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  47506. */
  47507. axisXControlRadius: boolean;
  47508. /**
  47509. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  47510. */
  47511. axisXControlHeight: boolean;
  47512. /**
  47513. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  47514. */
  47515. axisXControlRotation: boolean;
  47516. /**
  47517. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  47518. */
  47519. axisYControlRadius: boolean;
  47520. /**
  47521. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  47522. */
  47523. axisYControlHeight: boolean;
  47524. /**
  47525. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  47526. */
  47527. axisYControlRotation: boolean;
  47528. /**
  47529. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  47530. */
  47531. axisPinchControlRadius: boolean;
  47532. /**
  47533. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  47534. */
  47535. axisPinchControlHeight: boolean;
  47536. /**
  47537. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  47538. */
  47539. axisPinchControlRotation: boolean;
  47540. /**
  47541. * Log error messages if basic misconfiguration has occurred.
  47542. */
  47543. warningEnable: boolean;
  47544. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  47545. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  47546. private _warningCounter;
  47547. private _warning;
  47548. }
  47549. }
  47550. declare module BABYLON {
  47551. /**
  47552. * Default Inputs manager for the FollowCamera.
  47553. * It groups all the default supported inputs for ease of use.
  47554. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47555. */
  47556. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  47557. /**
  47558. * Instantiates a new FollowCameraInputsManager.
  47559. * @param camera Defines the camera the inputs belong to
  47560. */
  47561. constructor(camera: FollowCamera);
  47562. /**
  47563. * Add keyboard input support to the input manager.
  47564. * @returns the current input manager
  47565. */
  47566. addKeyboard(): FollowCameraInputsManager;
  47567. /**
  47568. * Add mouse wheel input support to the input manager.
  47569. * @returns the current input manager
  47570. */
  47571. addMouseWheel(): FollowCameraInputsManager;
  47572. /**
  47573. * Add pointers input support to the input manager.
  47574. * @returns the current input manager
  47575. */
  47576. addPointers(): FollowCameraInputsManager;
  47577. /**
  47578. * Add orientation input support to the input manager.
  47579. * @returns the current input manager
  47580. */
  47581. addVRDeviceOrientation(): FollowCameraInputsManager;
  47582. }
  47583. }
  47584. declare module BABYLON {
  47585. /**
  47586. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  47587. * an arc rotate version arcFollowCamera are available.
  47588. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  47589. */
  47590. export class FollowCamera extends TargetCamera {
  47591. /**
  47592. * Distance the follow camera should follow an object at
  47593. */
  47594. radius: number;
  47595. /**
  47596. * Minimum allowed distance of the camera to the axis of rotation
  47597. * (The camera can not get closer).
  47598. * This can help limiting how the Camera is able to move in the scene.
  47599. */
  47600. lowerRadiusLimit: Nullable<number>;
  47601. /**
  47602. * Maximum allowed distance of the camera to the axis of rotation
  47603. * (The camera can not get further).
  47604. * This can help limiting how the Camera is able to move in the scene.
  47605. */
  47606. upperRadiusLimit: Nullable<number>;
  47607. /**
  47608. * Define a rotation offset between the camera and the object it follows
  47609. */
  47610. rotationOffset: number;
  47611. /**
  47612. * Minimum allowed angle to camera position relative to target object.
  47613. * This can help limiting how the Camera is able to move in the scene.
  47614. */
  47615. lowerRotationOffsetLimit: Nullable<number>;
  47616. /**
  47617. * Maximum allowed angle to camera position relative to target object.
  47618. * This can help limiting how the Camera is able to move in the scene.
  47619. */
  47620. upperRotationOffsetLimit: Nullable<number>;
  47621. /**
  47622. * Define a height offset between the camera and the object it follows.
  47623. * It can help following an object from the top (like a car chaing a plane)
  47624. */
  47625. heightOffset: number;
  47626. /**
  47627. * Minimum allowed height of camera position relative to target object.
  47628. * This can help limiting how the Camera is able to move in the scene.
  47629. */
  47630. lowerHeightOffsetLimit: Nullable<number>;
  47631. /**
  47632. * Maximum allowed height of camera position relative to target object.
  47633. * This can help limiting how the Camera is able to move in the scene.
  47634. */
  47635. upperHeightOffsetLimit: Nullable<number>;
  47636. /**
  47637. * Define how fast the camera can accelerate to follow it s target.
  47638. */
  47639. cameraAcceleration: number;
  47640. /**
  47641. * Define the speed limit of the camera following an object.
  47642. */
  47643. maxCameraSpeed: number;
  47644. /**
  47645. * Define the target of the camera.
  47646. */
  47647. lockedTarget: Nullable<AbstractMesh>;
  47648. /**
  47649. * Defines the input associated with the camera.
  47650. */
  47651. inputs: FollowCameraInputsManager;
  47652. /**
  47653. * Instantiates the follow camera.
  47654. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  47655. * @param name Define the name of the camera in the scene
  47656. * @param position Define the position of the camera
  47657. * @param scene Define the scene the camera belong to
  47658. * @param lockedTarget Define the target of the camera
  47659. */
  47660. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  47661. private _follow;
  47662. /**
  47663. * Attached controls to the current camera.
  47664. * @param element Defines the element the controls should be listened from
  47665. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47666. */
  47667. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  47668. /**
  47669. * Detach the current controls from the camera.
  47670. * The camera will stop reacting to inputs.
  47671. * @param element Defines the element to stop listening the inputs from
  47672. */
  47673. detachControl(element: HTMLElement): void;
  47674. /** @hidden */
  47675. _checkInputs(): void;
  47676. private _checkLimits;
  47677. /**
  47678. * Gets the camera class name.
  47679. * @returns the class name
  47680. */
  47681. getClassName(): string;
  47682. }
  47683. /**
  47684. * Arc Rotate version of the follow camera.
  47685. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  47686. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  47687. */
  47688. export class ArcFollowCamera extends TargetCamera {
  47689. /** The longitudinal angle of the camera */
  47690. alpha: number;
  47691. /** The latitudinal angle of the camera */
  47692. beta: number;
  47693. /** The radius of the camera from its target */
  47694. radius: number;
  47695. private _cartesianCoordinates;
  47696. /** Define the camera target (the mesh it should follow) */
  47697. private _meshTarget;
  47698. /**
  47699. * Instantiates a new ArcFollowCamera
  47700. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  47701. * @param name Define the name of the camera
  47702. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  47703. * @param beta Define the rotation angle of the camera around the elevation axis
  47704. * @param radius Define the radius of the camera from its target point
  47705. * @param target Define the target of the camera
  47706. * @param scene Define the scene the camera belongs to
  47707. */
  47708. constructor(name: string,
  47709. /** The longitudinal angle of the camera */
  47710. alpha: number,
  47711. /** The latitudinal angle of the camera */
  47712. beta: number,
  47713. /** The radius of the camera from its target */
  47714. radius: number,
  47715. /** Define the camera target (the mesh it should follow) */
  47716. target: Nullable<AbstractMesh>, scene: Scene);
  47717. private _follow;
  47718. /** @hidden */
  47719. _checkInputs(): void;
  47720. /**
  47721. * Returns the class name of the object.
  47722. * It is mostly used internally for serialization purposes.
  47723. */
  47724. getClassName(): string;
  47725. }
  47726. }
  47727. declare module BABYLON {
  47728. /**
  47729. * Manage the keyboard inputs to control the movement of a follow camera.
  47730. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47731. */
  47732. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  47733. /**
  47734. * Defines the camera the input is attached to.
  47735. */
  47736. camera: FollowCamera;
  47737. /**
  47738. * Defines the list of key codes associated with the up action (increase heightOffset)
  47739. */
  47740. keysHeightOffsetIncr: number[];
  47741. /**
  47742. * Defines the list of key codes associated with the down action (decrease heightOffset)
  47743. */
  47744. keysHeightOffsetDecr: number[];
  47745. /**
  47746. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  47747. */
  47748. keysHeightOffsetModifierAlt: boolean;
  47749. /**
  47750. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  47751. */
  47752. keysHeightOffsetModifierCtrl: boolean;
  47753. /**
  47754. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  47755. */
  47756. keysHeightOffsetModifierShift: boolean;
  47757. /**
  47758. * Defines the list of key codes associated with the left action (increase rotationOffset)
  47759. */
  47760. keysRotationOffsetIncr: number[];
  47761. /**
  47762. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  47763. */
  47764. keysRotationOffsetDecr: number[];
  47765. /**
  47766. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  47767. */
  47768. keysRotationOffsetModifierAlt: boolean;
  47769. /**
  47770. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  47771. */
  47772. keysRotationOffsetModifierCtrl: boolean;
  47773. /**
  47774. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  47775. */
  47776. keysRotationOffsetModifierShift: boolean;
  47777. /**
  47778. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  47779. */
  47780. keysRadiusIncr: number[];
  47781. /**
  47782. * Defines the list of key codes associated with the zoom-out action (increase radius)
  47783. */
  47784. keysRadiusDecr: number[];
  47785. /**
  47786. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  47787. */
  47788. keysRadiusModifierAlt: boolean;
  47789. /**
  47790. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  47791. */
  47792. keysRadiusModifierCtrl: boolean;
  47793. /**
  47794. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  47795. */
  47796. keysRadiusModifierShift: boolean;
  47797. /**
  47798. * Defines the rate of change of heightOffset.
  47799. */
  47800. heightSensibility: number;
  47801. /**
  47802. * Defines the rate of change of rotationOffset.
  47803. */
  47804. rotationSensibility: number;
  47805. /**
  47806. * Defines the rate of change of radius.
  47807. */
  47808. radiusSensibility: number;
  47809. private _keys;
  47810. private _ctrlPressed;
  47811. private _altPressed;
  47812. private _shiftPressed;
  47813. private _onCanvasBlurObserver;
  47814. private _onKeyboardObserver;
  47815. private _engine;
  47816. private _scene;
  47817. /**
  47818. * Attach the input controls to a specific dom element to get the input from.
  47819. * @param element Defines the element the controls should be listened from
  47820. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47821. */
  47822. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  47823. /**
  47824. * Detach the current controls from the specified dom element.
  47825. * @param element Defines the element to stop listening the inputs from
  47826. */
  47827. detachControl(element: Nullable<HTMLElement>): void;
  47828. /**
  47829. * Update the current camera state depending on the inputs that have been used this frame.
  47830. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  47831. */
  47832. checkInputs(): void;
  47833. /**
  47834. * Gets the class name of the current input.
  47835. * @returns the class name
  47836. */
  47837. getClassName(): string;
  47838. /**
  47839. * Get the friendly name associated with the input class.
  47840. * @returns the input friendly name
  47841. */
  47842. getSimpleName(): string;
  47843. /**
  47844. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  47845. * allow modification of the heightOffset value.
  47846. */
  47847. private _modifierHeightOffset;
  47848. /**
  47849. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  47850. * allow modification of the rotationOffset value.
  47851. */
  47852. private _modifierRotationOffset;
  47853. /**
  47854. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  47855. * allow modification of the radius value.
  47856. */
  47857. private _modifierRadius;
  47858. }
  47859. }
  47860. declare module BABYLON {
  47861. interface FreeCameraInputsManager {
  47862. /**
  47863. * @hidden
  47864. */
  47865. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  47866. /**
  47867. * Add orientation input support to the input manager.
  47868. * @returns the current input manager
  47869. */
  47870. addDeviceOrientation(): FreeCameraInputsManager;
  47871. }
  47872. /**
  47873. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  47874. * Screen rotation is taken into account.
  47875. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47876. */
  47877. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  47878. private _camera;
  47879. private _screenOrientationAngle;
  47880. private _constantTranform;
  47881. private _screenQuaternion;
  47882. private _alpha;
  47883. private _beta;
  47884. private _gamma;
  47885. /**
  47886. * Can be used to detect if a device orientation sensor is available on a device
  47887. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  47888. * @returns a promise that will resolve on orientation change
  47889. */
  47890. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  47891. /**
  47892. * @hidden
  47893. */
  47894. _onDeviceOrientationChangedObservable: Observable<void>;
  47895. /**
  47896. * Instantiates a new input
  47897. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47898. */
  47899. constructor();
  47900. /**
  47901. * Define the camera controlled by the input.
  47902. */
  47903. get camera(): FreeCamera;
  47904. set camera(camera: FreeCamera);
  47905. /**
  47906. * Attach the input controls to a specific dom element to get the input from.
  47907. * @param element Defines the element the controls should be listened from
  47908. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47909. */
  47910. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  47911. private _orientationChanged;
  47912. private _deviceOrientation;
  47913. /**
  47914. * Detach the current controls from the specified dom element.
  47915. * @param element Defines the element to stop listening the inputs from
  47916. */
  47917. detachControl(element: Nullable<HTMLElement>): void;
  47918. /**
  47919. * Update the current camera state depending on the inputs that have been used this frame.
  47920. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  47921. */
  47922. checkInputs(): void;
  47923. /**
  47924. * Gets the class name of the current intput.
  47925. * @returns the class name
  47926. */
  47927. getClassName(): string;
  47928. /**
  47929. * Get the friendly name associated with the input class.
  47930. * @returns the input friendly name
  47931. */
  47932. getSimpleName(): string;
  47933. }
  47934. }
  47935. declare module BABYLON {
  47936. /**
  47937. * Manage the gamepad inputs to control a free camera.
  47938. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47939. */
  47940. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  47941. /**
  47942. * Define the camera the input is attached to.
  47943. */
  47944. camera: FreeCamera;
  47945. /**
  47946. * Define the Gamepad controlling the input
  47947. */
  47948. gamepad: Nullable<Gamepad>;
  47949. /**
  47950. * Defines the gamepad rotation sensiblity.
  47951. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  47952. */
  47953. gamepadAngularSensibility: number;
  47954. /**
  47955. * Defines the gamepad move sensiblity.
  47956. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  47957. */
  47958. gamepadMoveSensibility: number;
  47959. private _yAxisScale;
  47960. /**
  47961. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  47962. */
  47963. get invertYAxis(): boolean;
  47964. set invertYAxis(value: boolean);
  47965. private _onGamepadConnectedObserver;
  47966. private _onGamepadDisconnectedObserver;
  47967. private _cameraTransform;
  47968. private _deltaTransform;
  47969. private _vector3;
  47970. private _vector2;
  47971. /**
  47972. * Attach the input controls to a specific dom element to get the input from.
  47973. * @param element Defines the element the controls should be listened from
  47974. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47975. */
  47976. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  47977. /**
  47978. * Detach the current controls from the specified dom element.
  47979. * @param element Defines the element to stop listening the inputs from
  47980. */
  47981. detachControl(element: Nullable<HTMLElement>): void;
  47982. /**
  47983. * Update the current camera state depending on the inputs that have been used this frame.
  47984. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  47985. */
  47986. checkInputs(): void;
  47987. /**
  47988. * Gets the class name of the current intput.
  47989. * @returns the class name
  47990. */
  47991. getClassName(): string;
  47992. /**
  47993. * Get the friendly name associated with the input class.
  47994. * @returns the input friendly name
  47995. */
  47996. getSimpleName(): string;
  47997. }
  47998. }
  47999. declare module BABYLON {
  48000. /**
  48001. * Defines the potential axis of a Joystick
  48002. */
  48003. export enum JoystickAxis {
  48004. /** X axis */
  48005. X = 0,
  48006. /** Y axis */
  48007. Y = 1,
  48008. /** Z axis */
  48009. Z = 2
  48010. }
  48011. /**
  48012. * Represents the different customization options available
  48013. * for VirtualJoystick
  48014. */
  48015. interface VirtualJoystickCustomizations {
  48016. /**
  48017. * Size of the joystick's puck
  48018. */
  48019. puckSize: number;
  48020. /**
  48021. * Size of the joystick's container
  48022. */
  48023. containerSize: number;
  48024. /**
  48025. * Color of the joystick && puck
  48026. */
  48027. color: string;
  48028. /**
  48029. * Image URL for the joystick's puck
  48030. */
  48031. puckImage?: string;
  48032. /**
  48033. * Image URL for the joystick's container
  48034. */
  48035. containerImage?: string;
  48036. /**
  48037. * Defines the unmoving position of the joystick container
  48038. */
  48039. position?: {
  48040. x: number;
  48041. y: number;
  48042. };
  48043. /**
  48044. * Defines whether or not the joystick container is always visible
  48045. */
  48046. alwaysVisible: boolean;
  48047. /**
  48048. * Defines whether or not to limit the movement of the puck to the joystick's container
  48049. */
  48050. limitToContainer: boolean;
  48051. }
  48052. /**
  48053. * Class used to define virtual joystick (used in touch mode)
  48054. */
  48055. export class VirtualJoystick {
  48056. /**
  48057. * Gets or sets a boolean indicating that left and right values must be inverted
  48058. */
  48059. reverseLeftRight: boolean;
  48060. /**
  48061. * Gets or sets a boolean indicating that up and down values must be inverted
  48062. */
  48063. reverseUpDown: boolean;
  48064. /**
  48065. * Gets the offset value for the position (ie. the change of the position value)
  48066. */
  48067. deltaPosition: Vector3;
  48068. /**
  48069. * Gets a boolean indicating if the virtual joystick was pressed
  48070. */
  48071. pressed: boolean;
  48072. /**
  48073. * Canvas the virtual joystick will render onto, default z-index of this is 5
  48074. */
  48075. static Canvas: Nullable<HTMLCanvasElement>;
  48076. /**
  48077. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  48078. */
  48079. limitToContainer: boolean;
  48080. private static _globalJoystickIndex;
  48081. private static _alwaysVisibleSticks;
  48082. private static vjCanvasContext;
  48083. private static vjCanvasWidth;
  48084. private static vjCanvasHeight;
  48085. private static halfWidth;
  48086. private static _GetDefaultOptions;
  48087. private _action;
  48088. private _axisTargetedByLeftAndRight;
  48089. private _axisTargetedByUpAndDown;
  48090. private _joystickSensibility;
  48091. private _inversedSensibility;
  48092. private _joystickPointerID;
  48093. private _joystickColor;
  48094. private _joystickPointerPos;
  48095. private _joystickPreviousPointerPos;
  48096. private _joystickPointerStartPos;
  48097. private _deltaJoystickVector;
  48098. private _leftJoystick;
  48099. private _touches;
  48100. private _joystickPosition;
  48101. private _alwaysVisible;
  48102. private _puckImage;
  48103. private _containerImage;
  48104. private _joystickPuckSize;
  48105. private _joystickContainerSize;
  48106. private _clearPuckSize;
  48107. private _clearContainerSize;
  48108. private _clearPuckSizeOffset;
  48109. private _clearContainerSizeOffset;
  48110. private _onPointerDownHandlerRef;
  48111. private _onPointerMoveHandlerRef;
  48112. private _onPointerUpHandlerRef;
  48113. private _onResize;
  48114. /**
  48115. * Creates a new virtual joystick
  48116. * @param leftJoystick defines that the joystick is for left hand (false by default)
  48117. * @param customizations Defines the options we want to customize the VirtualJoystick
  48118. */
  48119. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  48120. /**
  48121. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  48122. * @param newJoystickSensibility defines the new sensibility
  48123. */
  48124. setJoystickSensibility(newJoystickSensibility: number): void;
  48125. private _onPointerDown;
  48126. private _onPointerMove;
  48127. private _onPointerUp;
  48128. /**
  48129. * Change the color of the virtual joystick
  48130. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  48131. */
  48132. setJoystickColor(newColor: string): void;
  48133. /**
  48134. * Size of the joystick's container
  48135. */
  48136. set containerSize(newSize: number);
  48137. get containerSize(): number;
  48138. /**
  48139. * Size of the joystick's puck
  48140. */
  48141. set puckSize(newSize: number);
  48142. get puckSize(): number;
  48143. /**
  48144. * Clears the set position of the joystick
  48145. */
  48146. clearPosition(): void;
  48147. /**
  48148. * Defines whether or not the joystick container is always visible
  48149. */
  48150. set alwaysVisible(value: boolean);
  48151. get alwaysVisible(): boolean;
  48152. /**
  48153. * Sets the constant position of the Joystick container
  48154. * @param x X axis coordinate
  48155. * @param y Y axis coordinate
  48156. */
  48157. setPosition(x: number, y: number): void;
  48158. /**
  48159. * Defines a callback to call when the joystick is touched
  48160. * @param action defines the callback
  48161. */
  48162. setActionOnTouch(action: () => any): void;
  48163. /**
  48164. * Defines which axis you'd like to control for left & right
  48165. * @param axis defines the axis to use
  48166. */
  48167. setAxisForLeftRight(axis: JoystickAxis): void;
  48168. /**
  48169. * Defines which axis you'd like to control for up & down
  48170. * @param axis defines the axis to use
  48171. */
  48172. setAxisForUpDown(axis: JoystickAxis): void;
  48173. /**
  48174. * Clears the canvas from the previous puck / container draw
  48175. */
  48176. private _clearPreviousDraw;
  48177. /**
  48178. * Loads `urlPath` to be used for the container's image
  48179. * @param urlPath defines the urlPath of an image to use
  48180. */
  48181. setContainerImage(urlPath: string): void;
  48182. /**
  48183. * Loads `urlPath` to be used for the puck's image
  48184. * @param urlPath defines the urlPath of an image to use
  48185. */
  48186. setPuckImage(urlPath: string): void;
  48187. /**
  48188. * Draws the Virtual Joystick's container
  48189. */
  48190. private _drawContainer;
  48191. /**
  48192. * Draws the Virtual Joystick's puck
  48193. */
  48194. private _drawPuck;
  48195. private _drawVirtualJoystick;
  48196. /**
  48197. * Release internal HTML canvas
  48198. */
  48199. releaseCanvas(): void;
  48200. }
  48201. }
  48202. declare module BABYLON {
  48203. interface FreeCameraInputsManager {
  48204. /**
  48205. * Add virtual joystick input support to the input manager.
  48206. * @returns the current input manager
  48207. */
  48208. addVirtualJoystick(): FreeCameraInputsManager;
  48209. }
  48210. /**
  48211. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  48212. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  48213. */
  48214. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  48215. /**
  48216. * Defines the camera the input is attached to.
  48217. */
  48218. camera: FreeCamera;
  48219. private _leftjoystick;
  48220. private _rightjoystick;
  48221. /**
  48222. * Gets the left stick of the virtual joystick.
  48223. * @returns The virtual Joystick
  48224. */
  48225. getLeftJoystick(): VirtualJoystick;
  48226. /**
  48227. * Gets the right stick of the virtual joystick.
  48228. * @returns The virtual Joystick
  48229. */
  48230. getRightJoystick(): VirtualJoystick;
  48231. /**
  48232. * Update the current camera state depending on the inputs that have been used this frame.
  48233. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  48234. */
  48235. checkInputs(): void;
  48236. /**
  48237. * Attach the input controls to a specific dom element to get the input from.
  48238. * @param element Defines the element the controls should be listened from
  48239. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  48240. */
  48241. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  48242. /**
  48243. * Detach the current controls from the specified dom element.
  48244. * @param element Defines the element to stop listening the inputs from
  48245. */
  48246. detachControl(element: Nullable<HTMLElement>): void;
  48247. /**
  48248. * Gets the class name of the current intput.
  48249. * @returns the class name
  48250. */
  48251. getClassName(): string;
  48252. /**
  48253. * Get the friendly name associated with the input class.
  48254. * @returns the input friendly name
  48255. */
  48256. getSimpleName(): string;
  48257. }
  48258. }
  48259. declare module BABYLON {
  48260. /**
  48261. * This represents a FPS type of camera controlled by touch.
  48262. * This is like a universal camera minus the Gamepad controls.
  48263. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  48264. */
  48265. export class TouchCamera extends FreeCamera {
  48266. /**
  48267. * Defines the touch sensibility for rotation.
  48268. * The higher the faster.
  48269. */
  48270. get touchAngularSensibility(): number;
  48271. set touchAngularSensibility(value: number);
  48272. /**
  48273. * Defines the touch sensibility for move.
  48274. * The higher the faster.
  48275. */
  48276. get touchMoveSensibility(): number;
  48277. set touchMoveSensibility(value: number);
  48278. /**
  48279. * Instantiates a new touch camera.
  48280. * This represents a FPS type of camera controlled by touch.
  48281. * This is like a universal camera minus the Gamepad controls.
  48282. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  48283. * @param name Define the name of the camera in the scene
  48284. * @param position Define the start position of the camera in the scene
  48285. * @param scene Define the scene the camera belongs to
  48286. */
  48287. constructor(name: string, position: Vector3, scene: Scene);
  48288. /**
  48289. * Gets the current object class name.
  48290. * @return the class name
  48291. */
  48292. getClassName(): string;
  48293. /** @hidden */
  48294. _setupInputs(): void;
  48295. }
  48296. }
  48297. declare module BABYLON {
  48298. /**
  48299. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  48300. * being tilted forward or back and left or right.
  48301. */
  48302. export class DeviceOrientationCamera extends FreeCamera {
  48303. private _initialQuaternion;
  48304. private _quaternionCache;
  48305. private _tmpDragQuaternion;
  48306. private _disablePointerInputWhenUsingDeviceOrientation;
  48307. /**
  48308. * Creates a new device orientation camera
  48309. * @param name The name of the camera
  48310. * @param position The start position camera
  48311. * @param scene The scene the camera belongs to
  48312. */
  48313. constructor(name: string, position: Vector3, scene: Scene);
  48314. /**
  48315. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  48316. */
  48317. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  48318. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  48319. private _dragFactor;
  48320. /**
  48321. * Enabled turning on the y axis when the orientation sensor is active
  48322. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  48323. */
  48324. enableHorizontalDragging(dragFactor?: number): void;
  48325. /**
  48326. * Gets the current instance class name ("DeviceOrientationCamera").
  48327. * This helps avoiding instanceof at run time.
  48328. * @returns the class name
  48329. */
  48330. getClassName(): string;
  48331. /**
  48332. * @hidden
  48333. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  48334. */
  48335. _checkInputs(): void;
  48336. /**
  48337. * Reset the camera to its default orientation on the specified axis only.
  48338. * @param axis The axis to reset
  48339. */
  48340. resetToCurrentRotation(axis?: Axis): void;
  48341. }
  48342. }
  48343. declare module BABYLON {
  48344. /**
  48345. * Defines supported buttons for XBox360 compatible gamepads
  48346. */
  48347. export enum Xbox360Button {
  48348. /** A */
  48349. A = 0,
  48350. /** B */
  48351. B = 1,
  48352. /** X */
  48353. X = 2,
  48354. /** Y */
  48355. Y = 3,
  48356. /** Left button */
  48357. LB = 4,
  48358. /** Right button */
  48359. RB = 5,
  48360. /** Back */
  48361. Back = 8,
  48362. /** Start */
  48363. Start = 9,
  48364. /** Left stick */
  48365. LeftStick = 10,
  48366. /** Right stick */
  48367. RightStick = 11
  48368. }
  48369. /** Defines values for XBox360 DPad */
  48370. export enum Xbox360Dpad {
  48371. /** Up */
  48372. Up = 12,
  48373. /** Down */
  48374. Down = 13,
  48375. /** Left */
  48376. Left = 14,
  48377. /** Right */
  48378. Right = 15
  48379. }
  48380. /**
  48381. * Defines a XBox360 gamepad
  48382. */
  48383. export class Xbox360Pad extends Gamepad {
  48384. private _leftTrigger;
  48385. private _rightTrigger;
  48386. private _onlefttriggerchanged;
  48387. private _onrighttriggerchanged;
  48388. private _onbuttondown;
  48389. private _onbuttonup;
  48390. private _ondpaddown;
  48391. private _ondpadup;
  48392. /** Observable raised when a button is pressed */
  48393. onButtonDownObservable: Observable<Xbox360Button>;
  48394. /** Observable raised when a button is released */
  48395. onButtonUpObservable: Observable<Xbox360Button>;
  48396. /** Observable raised when a pad is pressed */
  48397. onPadDownObservable: Observable<Xbox360Dpad>;
  48398. /** Observable raised when a pad is released */
  48399. onPadUpObservable: Observable<Xbox360Dpad>;
  48400. private _buttonA;
  48401. private _buttonB;
  48402. private _buttonX;
  48403. private _buttonY;
  48404. private _buttonBack;
  48405. private _buttonStart;
  48406. private _buttonLB;
  48407. private _buttonRB;
  48408. private _buttonLeftStick;
  48409. private _buttonRightStick;
  48410. private _dPadUp;
  48411. private _dPadDown;
  48412. private _dPadLeft;
  48413. private _dPadRight;
  48414. private _isXboxOnePad;
  48415. /**
  48416. * Creates a new XBox360 gamepad object
  48417. * @param id defines the id of this gamepad
  48418. * @param index defines its index
  48419. * @param gamepad defines the internal HTML gamepad object
  48420. * @param xboxOne defines if it is a XBox One gamepad
  48421. */
  48422. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  48423. /**
  48424. * Defines the callback to call when left trigger is pressed
  48425. * @param callback defines the callback to use
  48426. */
  48427. onlefttriggerchanged(callback: (value: number) => void): void;
  48428. /**
  48429. * Defines the callback to call when right trigger is pressed
  48430. * @param callback defines the callback to use
  48431. */
  48432. onrighttriggerchanged(callback: (value: number) => void): void;
  48433. /**
  48434. * Gets the left trigger value
  48435. */
  48436. get leftTrigger(): number;
  48437. /**
  48438. * Sets the left trigger value
  48439. */
  48440. set leftTrigger(newValue: number);
  48441. /**
  48442. * Gets the right trigger value
  48443. */
  48444. get rightTrigger(): number;
  48445. /**
  48446. * Sets the right trigger value
  48447. */
  48448. set rightTrigger(newValue: number);
  48449. /**
  48450. * Defines the callback to call when a button is pressed
  48451. * @param callback defines the callback to use
  48452. */
  48453. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  48454. /**
  48455. * Defines the callback to call when a button is released
  48456. * @param callback defines the callback to use
  48457. */
  48458. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  48459. /**
  48460. * Defines the callback to call when a pad is pressed
  48461. * @param callback defines the callback to use
  48462. */
  48463. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  48464. /**
  48465. * Defines the callback to call when a pad is released
  48466. * @param callback defines the callback to use
  48467. */
  48468. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  48469. private _setButtonValue;
  48470. private _setDPadValue;
  48471. /**
  48472. * Gets the value of the `A` button
  48473. */
  48474. get buttonA(): number;
  48475. /**
  48476. * Sets the value of the `A` button
  48477. */
  48478. set buttonA(value: number);
  48479. /**
  48480. * Gets the value of the `B` button
  48481. */
  48482. get buttonB(): number;
  48483. /**
  48484. * Sets the value of the `B` button
  48485. */
  48486. set buttonB(value: number);
  48487. /**
  48488. * Gets the value of the `X` button
  48489. */
  48490. get buttonX(): number;
  48491. /**
  48492. * Sets the value of the `X` button
  48493. */
  48494. set buttonX(value: number);
  48495. /**
  48496. * Gets the value of the `Y` button
  48497. */
  48498. get buttonY(): number;
  48499. /**
  48500. * Sets the value of the `Y` button
  48501. */
  48502. set buttonY(value: number);
  48503. /**
  48504. * Gets the value of the `Start` button
  48505. */
  48506. get buttonStart(): number;
  48507. /**
  48508. * Sets the value of the `Start` button
  48509. */
  48510. set buttonStart(value: number);
  48511. /**
  48512. * Gets the value of the `Back` button
  48513. */
  48514. get buttonBack(): number;
  48515. /**
  48516. * Sets the value of the `Back` button
  48517. */
  48518. set buttonBack(value: number);
  48519. /**
  48520. * Gets the value of the `Left` button
  48521. */
  48522. get buttonLB(): number;
  48523. /**
  48524. * Sets the value of the `Left` button
  48525. */
  48526. set buttonLB(value: number);
  48527. /**
  48528. * Gets the value of the `Right` button
  48529. */
  48530. get buttonRB(): number;
  48531. /**
  48532. * Sets the value of the `Right` button
  48533. */
  48534. set buttonRB(value: number);
  48535. /**
  48536. * Gets the value of the Left joystick
  48537. */
  48538. get buttonLeftStick(): number;
  48539. /**
  48540. * Sets the value of the Left joystick
  48541. */
  48542. set buttonLeftStick(value: number);
  48543. /**
  48544. * Gets the value of the Right joystick
  48545. */
  48546. get buttonRightStick(): number;
  48547. /**
  48548. * Sets the value of the Right joystick
  48549. */
  48550. set buttonRightStick(value: number);
  48551. /**
  48552. * Gets the value of D-pad up
  48553. */
  48554. get dPadUp(): number;
  48555. /**
  48556. * Sets the value of D-pad up
  48557. */
  48558. set dPadUp(value: number);
  48559. /**
  48560. * Gets the value of D-pad down
  48561. */
  48562. get dPadDown(): number;
  48563. /**
  48564. * Sets the value of D-pad down
  48565. */
  48566. set dPadDown(value: number);
  48567. /**
  48568. * Gets the value of D-pad left
  48569. */
  48570. get dPadLeft(): number;
  48571. /**
  48572. * Sets the value of D-pad left
  48573. */
  48574. set dPadLeft(value: number);
  48575. /**
  48576. * Gets the value of D-pad right
  48577. */
  48578. get dPadRight(): number;
  48579. /**
  48580. * Sets the value of D-pad right
  48581. */
  48582. set dPadRight(value: number);
  48583. /**
  48584. * Force the gamepad to synchronize with device values
  48585. */
  48586. update(): void;
  48587. /**
  48588. * Disposes the gamepad
  48589. */
  48590. dispose(): void;
  48591. }
  48592. }
  48593. declare module BABYLON {
  48594. /**
  48595. * Defines supported buttons for DualShock compatible gamepads
  48596. */
  48597. export enum DualShockButton {
  48598. /** Cross */
  48599. Cross = 0,
  48600. /** Circle */
  48601. Circle = 1,
  48602. /** Square */
  48603. Square = 2,
  48604. /** Triangle */
  48605. Triangle = 3,
  48606. /** L1 */
  48607. L1 = 4,
  48608. /** R1 */
  48609. R1 = 5,
  48610. /** Share */
  48611. Share = 8,
  48612. /** Options */
  48613. Options = 9,
  48614. /** Left stick */
  48615. LeftStick = 10,
  48616. /** Right stick */
  48617. RightStick = 11
  48618. }
  48619. /** Defines values for DualShock DPad */
  48620. export enum DualShockDpad {
  48621. /** Up */
  48622. Up = 12,
  48623. /** Down */
  48624. Down = 13,
  48625. /** Left */
  48626. Left = 14,
  48627. /** Right */
  48628. Right = 15
  48629. }
  48630. /**
  48631. * Defines a DualShock gamepad
  48632. */
  48633. export class DualShockPad extends Gamepad {
  48634. private _leftTrigger;
  48635. private _rightTrigger;
  48636. private _onlefttriggerchanged;
  48637. private _onrighttriggerchanged;
  48638. private _onbuttondown;
  48639. private _onbuttonup;
  48640. private _ondpaddown;
  48641. private _ondpadup;
  48642. /** Observable raised when a button is pressed */
  48643. onButtonDownObservable: Observable<DualShockButton>;
  48644. /** Observable raised when a button is released */
  48645. onButtonUpObservable: Observable<DualShockButton>;
  48646. /** Observable raised when a pad is pressed */
  48647. onPadDownObservable: Observable<DualShockDpad>;
  48648. /** Observable raised when a pad is released */
  48649. onPadUpObservable: Observable<DualShockDpad>;
  48650. private _buttonCross;
  48651. private _buttonCircle;
  48652. private _buttonSquare;
  48653. private _buttonTriangle;
  48654. private _buttonShare;
  48655. private _buttonOptions;
  48656. private _buttonL1;
  48657. private _buttonR1;
  48658. private _buttonLeftStick;
  48659. private _buttonRightStick;
  48660. private _dPadUp;
  48661. private _dPadDown;
  48662. private _dPadLeft;
  48663. private _dPadRight;
  48664. /**
  48665. * Creates a new DualShock gamepad object
  48666. * @param id defines the id of this gamepad
  48667. * @param index defines its index
  48668. * @param gamepad defines the internal HTML gamepad object
  48669. */
  48670. constructor(id: string, index: number, gamepad: any);
  48671. /**
  48672. * Defines the callback to call when left trigger is pressed
  48673. * @param callback defines the callback to use
  48674. */
  48675. onlefttriggerchanged(callback: (value: number) => void): void;
  48676. /**
  48677. * Defines the callback to call when right trigger is pressed
  48678. * @param callback defines the callback to use
  48679. */
  48680. onrighttriggerchanged(callback: (value: number) => void): void;
  48681. /**
  48682. * Gets the left trigger value
  48683. */
  48684. get leftTrigger(): number;
  48685. /**
  48686. * Sets the left trigger value
  48687. */
  48688. set leftTrigger(newValue: number);
  48689. /**
  48690. * Gets the right trigger value
  48691. */
  48692. get rightTrigger(): number;
  48693. /**
  48694. * Sets the right trigger value
  48695. */
  48696. set rightTrigger(newValue: number);
  48697. /**
  48698. * Defines the callback to call when a button is pressed
  48699. * @param callback defines the callback to use
  48700. */
  48701. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  48702. /**
  48703. * Defines the callback to call when a button is released
  48704. * @param callback defines the callback to use
  48705. */
  48706. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  48707. /**
  48708. * Defines the callback to call when a pad is pressed
  48709. * @param callback defines the callback to use
  48710. */
  48711. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  48712. /**
  48713. * Defines the callback to call when a pad is released
  48714. * @param callback defines the callback to use
  48715. */
  48716. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  48717. private _setButtonValue;
  48718. private _setDPadValue;
  48719. /**
  48720. * Gets the value of the `Cross` button
  48721. */
  48722. get buttonCross(): number;
  48723. /**
  48724. * Sets the value of the `Cross` button
  48725. */
  48726. set buttonCross(value: number);
  48727. /**
  48728. * Gets the value of the `Circle` button
  48729. */
  48730. get buttonCircle(): number;
  48731. /**
  48732. * Sets the value of the `Circle` button
  48733. */
  48734. set buttonCircle(value: number);
  48735. /**
  48736. * Gets the value of the `Square` button
  48737. */
  48738. get buttonSquare(): number;
  48739. /**
  48740. * Sets the value of the `Square` button
  48741. */
  48742. set buttonSquare(value: number);
  48743. /**
  48744. * Gets the value of the `Triangle` button
  48745. */
  48746. get buttonTriangle(): number;
  48747. /**
  48748. * Sets the value of the `Triangle` button
  48749. */
  48750. set buttonTriangle(value: number);
  48751. /**
  48752. * Gets the value of the `Options` button
  48753. */
  48754. get buttonOptions(): number;
  48755. /**
  48756. * Sets the value of the `Options` button
  48757. */
  48758. set buttonOptions(value: number);
  48759. /**
  48760. * Gets the value of the `Share` button
  48761. */
  48762. get buttonShare(): number;
  48763. /**
  48764. * Sets the value of the `Share` button
  48765. */
  48766. set buttonShare(value: number);
  48767. /**
  48768. * Gets the value of the `L1` button
  48769. */
  48770. get buttonL1(): number;
  48771. /**
  48772. * Sets the value of the `L1` button
  48773. */
  48774. set buttonL1(value: number);
  48775. /**
  48776. * Gets the value of the `R1` button
  48777. */
  48778. get buttonR1(): number;
  48779. /**
  48780. * Sets the value of the `R1` button
  48781. */
  48782. set buttonR1(value: number);
  48783. /**
  48784. * Gets the value of the Left joystick
  48785. */
  48786. get buttonLeftStick(): number;
  48787. /**
  48788. * Sets the value of the Left joystick
  48789. */
  48790. set buttonLeftStick(value: number);
  48791. /**
  48792. * Gets the value of the Right joystick
  48793. */
  48794. get buttonRightStick(): number;
  48795. /**
  48796. * Sets the value of the Right joystick
  48797. */
  48798. set buttonRightStick(value: number);
  48799. /**
  48800. * Gets the value of D-pad up
  48801. */
  48802. get dPadUp(): number;
  48803. /**
  48804. * Sets the value of D-pad up
  48805. */
  48806. set dPadUp(value: number);
  48807. /**
  48808. * Gets the value of D-pad down
  48809. */
  48810. get dPadDown(): number;
  48811. /**
  48812. * Sets the value of D-pad down
  48813. */
  48814. set dPadDown(value: number);
  48815. /**
  48816. * Gets the value of D-pad left
  48817. */
  48818. get dPadLeft(): number;
  48819. /**
  48820. * Sets the value of D-pad left
  48821. */
  48822. set dPadLeft(value: number);
  48823. /**
  48824. * Gets the value of D-pad right
  48825. */
  48826. get dPadRight(): number;
  48827. /**
  48828. * Sets the value of D-pad right
  48829. */
  48830. set dPadRight(value: number);
  48831. /**
  48832. * Force the gamepad to synchronize with device values
  48833. */
  48834. update(): void;
  48835. /**
  48836. * Disposes the gamepad
  48837. */
  48838. dispose(): void;
  48839. }
  48840. }
  48841. declare module BABYLON {
  48842. /**
  48843. * Manager for handling gamepads
  48844. */
  48845. export class GamepadManager {
  48846. private _scene?;
  48847. private _babylonGamepads;
  48848. private _oneGamepadConnected;
  48849. /** @hidden */
  48850. _isMonitoring: boolean;
  48851. private _gamepadEventSupported;
  48852. private _gamepadSupport?;
  48853. /**
  48854. * observable to be triggered when the gamepad controller has been connected
  48855. */
  48856. onGamepadConnectedObservable: Observable<Gamepad>;
  48857. /**
  48858. * observable to be triggered when the gamepad controller has been disconnected
  48859. */
  48860. onGamepadDisconnectedObservable: Observable<Gamepad>;
  48861. private _onGamepadConnectedEvent;
  48862. private _onGamepadDisconnectedEvent;
  48863. /**
  48864. * Initializes the gamepad manager
  48865. * @param _scene BabylonJS scene
  48866. */
  48867. constructor(_scene?: Scene | undefined);
  48868. /**
  48869. * The gamepads in the game pad manager
  48870. */
  48871. get gamepads(): Gamepad[];
  48872. /**
  48873. * Get the gamepad controllers based on type
  48874. * @param type The type of gamepad controller
  48875. * @returns Nullable gamepad
  48876. */
  48877. getGamepadByType(type?: number): Nullable<Gamepad>;
  48878. /**
  48879. * Disposes the gamepad manager
  48880. */
  48881. dispose(): void;
  48882. private _addNewGamepad;
  48883. private _startMonitoringGamepads;
  48884. private _stopMonitoringGamepads;
  48885. /** @hidden */
  48886. _checkGamepadsStatus(): void;
  48887. private _updateGamepadObjects;
  48888. }
  48889. }
  48890. declare module BABYLON {
  48891. interface Scene {
  48892. /** @hidden */
  48893. _gamepadManager: Nullable<GamepadManager>;
  48894. /**
  48895. * Gets the gamepad manager associated with the scene
  48896. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  48897. */
  48898. gamepadManager: GamepadManager;
  48899. }
  48900. /**
  48901. * Interface representing a free camera inputs manager
  48902. */
  48903. interface FreeCameraInputsManager {
  48904. /**
  48905. * Adds gamepad input support to the FreeCameraInputsManager.
  48906. * @returns the FreeCameraInputsManager
  48907. */
  48908. addGamepad(): FreeCameraInputsManager;
  48909. }
  48910. /**
  48911. * Interface representing an arc rotate camera inputs manager
  48912. */
  48913. interface ArcRotateCameraInputsManager {
  48914. /**
  48915. * Adds gamepad input support to the ArcRotateCamera InputManager.
  48916. * @returns the camera inputs manager
  48917. */
  48918. addGamepad(): ArcRotateCameraInputsManager;
  48919. }
  48920. /**
  48921. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  48922. */
  48923. export class GamepadSystemSceneComponent implements ISceneComponent {
  48924. /**
  48925. * The component name helpfull to identify the component in the list of scene components.
  48926. */
  48927. readonly name: string;
  48928. /**
  48929. * The scene the component belongs to.
  48930. */
  48931. scene: Scene;
  48932. /**
  48933. * Creates a new instance of the component for the given scene
  48934. * @param scene Defines the scene to register the component in
  48935. */
  48936. constructor(scene: Scene);
  48937. /**
  48938. * Registers the component in a given scene
  48939. */
  48940. register(): void;
  48941. /**
  48942. * Rebuilds the elements related to this component in case of
  48943. * context lost for instance.
  48944. */
  48945. rebuild(): void;
  48946. /**
  48947. * Disposes the component and the associated ressources
  48948. */
  48949. dispose(): void;
  48950. private _beforeCameraUpdate;
  48951. }
  48952. }
  48953. declare module BABYLON {
  48954. /**
  48955. * 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,
  48956. * which still works and will still be found in many Playgrounds.
  48957. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  48958. */
  48959. export class UniversalCamera extends TouchCamera {
  48960. /**
  48961. * Defines the gamepad rotation sensiblity.
  48962. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  48963. */
  48964. get gamepadAngularSensibility(): number;
  48965. set gamepadAngularSensibility(value: number);
  48966. /**
  48967. * Defines the gamepad move sensiblity.
  48968. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  48969. */
  48970. get gamepadMoveSensibility(): number;
  48971. set gamepadMoveSensibility(value: number);
  48972. /**
  48973. * 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,
  48974. * which still works and will still be found in many Playgrounds.
  48975. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  48976. * @param name Define the name of the camera in the scene
  48977. * @param position Define the start position of the camera in the scene
  48978. * @param scene Define the scene the camera belongs to
  48979. */
  48980. constructor(name: string, position: Vector3, scene: Scene);
  48981. /**
  48982. * Gets the current object class name.
  48983. * @return the class name
  48984. */
  48985. getClassName(): string;
  48986. }
  48987. }
  48988. declare module BABYLON {
  48989. /**
  48990. * This represents a FPS type of camera. This is only here for back compat purpose.
  48991. * Please use the UniversalCamera instead as both are identical.
  48992. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  48993. */
  48994. export class GamepadCamera extends UniversalCamera {
  48995. /**
  48996. * Instantiates a new Gamepad Camera
  48997. * This represents a FPS type of camera. This is only here for back compat purpose.
  48998. * Please use the UniversalCamera instead as both are identical.
  48999. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  49000. * @param name Define the name of the camera in the scene
  49001. * @param position Define the start position of the camera in the scene
  49002. * @param scene Define the scene the camera belongs to
  49003. */
  49004. constructor(name: string, position: Vector3, scene: Scene);
  49005. /**
  49006. * Gets the current object class name.
  49007. * @return the class name
  49008. */
  49009. getClassName(): string;
  49010. }
  49011. }
  49012. declare module BABYLON {
  49013. /** @hidden */
  49014. export var passPixelShader: {
  49015. name: string;
  49016. shader: string;
  49017. };
  49018. }
  49019. declare module BABYLON {
  49020. /** @hidden */
  49021. export var passCubePixelShader: {
  49022. name: string;
  49023. shader: string;
  49024. };
  49025. }
  49026. declare module BABYLON {
  49027. /**
  49028. * PassPostProcess which produces an output the same as it's input
  49029. */
  49030. export class PassPostProcess extends PostProcess {
  49031. /**
  49032. * Gets a string identifying the name of the class
  49033. * @returns "PassPostProcess" string
  49034. */
  49035. getClassName(): string;
  49036. /**
  49037. * Creates the PassPostProcess
  49038. * @param name The name of the effect.
  49039. * @param options The required width/height ratio to downsize to before computing the render pass.
  49040. * @param camera The camera to apply the render pass to.
  49041. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49042. * @param engine The engine which the post process will be applied. (default: current engine)
  49043. * @param reusable If the post process can be reused on the same frame. (default: false)
  49044. * @param textureType The type of texture to be used when performing the post processing.
  49045. * @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)
  49046. */
  49047. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  49048. /** @hidden */
  49049. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  49050. }
  49051. /**
  49052. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  49053. */
  49054. export class PassCubePostProcess extends PostProcess {
  49055. private _face;
  49056. /**
  49057. * Gets or sets the cube face to display.
  49058. * * 0 is +X
  49059. * * 1 is -X
  49060. * * 2 is +Y
  49061. * * 3 is -Y
  49062. * * 4 is +Z
  49063. * * 5 is -Z
  49064. */
  49065. get face(): number;
  49066. set face(value: number);
  49067. /**
  49068. * Gets a string identifying the name of the class
  49069. * @returns "PassCubePostProcess" string
  49070. */
  49071. getClassName(): string;
  49072. /**
  49073. * Creates the PassCubePostProcess
  49074. * @param name The name of the effect.
  49075. * @param options The required width/height ratio to downsize to before computing the render pass.
  49076. * @param camera The camera to apply the render pass to.
  49077. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  49078. * @param engine The engine which the post process will be applied. (default: current engine)
  49079. * @param reusable If the post process can be reused on the same frame. (default: false)
  49080. * @param textureType The type of texture to be used when performing the post processing.
  49081. * @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)
  49082. */
  49083. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  49084. /** @hidden */
  49085. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  49086. }
  49087. }
  49088. declare module BABYLON {
  49089. /** @hidden */
  49090. export var anaglyphPixelShader: {
  49091. name: string;
  49092. shader: string;
  49093. };
  49094. }
  49095. declare module BABYLON {
  49096. /**
  49097. * Postprocess used to generate anaglyphic rendering
  49098. */
  49099. export class AnaglyphPostProcess extends PostProcess {
  49100. private _passedProcess;
  49101. /**
  49102. * Gets a string identifying the name of the class
  49103. * @returns "AnaglyphPostProcess" string
  49104. */
  49105. getClassName(): string;
  49106. /**
  49107. * Creates a new AnaglyphPostProcess
  49108. * @param name defines postprocess name
  49109. * @param options defines creation options or target ratio scale
  49110. * @param rigCameras defines cameras using this postprocess
  49111. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  49112. * @param engine defines hosting engine
  49113. * @param reusable defines if the postprocess will be reused multiple times per frame
  49114. */
  49115. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  49116. }
  49117. }
  49118. declare module BABYLON {
  49119. /**
  49120. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  49121. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  49122. */
  49123. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  49124. /**
  49125. * Creates a new AnaglyphArcRotateCamera
  49126. * @param name defines camera name
  49127. * @param alpha defines alpha angle (in radians)
  49128. * @param beta defines beta angle (in radians)
  49129. * @param radius defines radius
  49130. * @param target defines camera target
  49131. * @param interaxialDistance defines distance between each color axis
  49132. * @param scene defines the hosting scene
  49133. */
  49134. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  49135. /**
  49136. * Gets camera class name
  49137. * @returns AnaglyphArcRotateCamera
  49138. */
  49139. getClassName(): string;
  49140. }
  49141. }
  49142. declare module BABYLON {
  49143. /**
  49144. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  49145. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  49146. */
  49147. export class AnaglyphFreeCamera extends FreeCamera {
  49148. /**
  49149. * Creates a new AnaglyphFreeCamera
  49150. * @param name defines camera name
  49151. * @param position defines initial position
  49152. * @param interaxialDistance defines distance between each color axis
  49153. * @param scene defines the hosting scene
  49154. */
  49155. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  49156. /**
  49157. * Gets camera class name
  49158. * @returns AnaglyphFreeCamera
  49159. */
  49160. getClassName(): string;
  49161. }
  49162. }
  49163. declare module BABYLON {
  49164. /**
  49165. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  49166. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  49167. */
  49168. export class AnaglyphGamepadCamera extends GamepadCamera {
  49169. /**
  49170. * Creates a new AnaglyphGamepadCamera
  49171. * @param name defines camera name
  49172. * @param position defines initial position
  49173. * @param interaxialDistance defines distance between each color axis
  49174. * @param scene defines the hosting scene
  49175. */
  49176. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  49177. /**
  49178. * Gets camera class name
  49179. * @returns AnaglyphGamepadCamera
  49180. */
  49181. getClassName(): string;
  49182. }
  49183. }
  49184. declare module BABYLON {
  49185. /**
  49186. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  49187. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  49188. */
  49189. export class AnaglyphUniversalCamera extends UniversalCamera {
  49190. /**
  49191. * Creates a new AnaglyphUniversalCamera
  49192. * @param name defines camera name
  49193. * @param position defines initial position
  49194. * @param interaxialDistance defines distance between each color axis
  49195. * @param scene defines the hosting scene
  49196. */
  49197. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  49198. /**
  49199. * Gets camera class name
  49200. * @returns AnaglyphUniversalCamera
  49201. */
  49202. getClassName(): string;
  49203. }
  49204. }
  49205. declare module BABYLON {
  49206. /**
  49207. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  49208. * @see https://doc.babylonjs.com/features/cameras
  49209. */
  49210. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  49211. /**
  49212. * Creates a new StereoscopicArcRotateCamera
  49213. * @param name defines camera name
  49214. * @param alpha defines alpha angle (in radians)
  49215. * @param beta defines beta angle (in radians)
  49216. * @param radius defines radius
  49217. * @param target defines camera target
  49218. * @param interaxialDistance defines distance between each color axis
  49219. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  49220. * @param scene defines the hosting scene
  49221. */
  49222. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  49223. /**
  49224. * Gets camera class name
  49225. * @returns StereoscopicArcRotateCamera
  49226. */
  49227. getClassName(): string;
  49228. }
  49229. }
  49230. declare module BABYLON {
  49231. /**
  49232. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  49233. * @see https://doc.babylonjs.com/features/cameras
  49234. */
  49235. export class StereoscopicFreeCamera extends FreeCamera {
  49236. /**
  49237. * Creates a new StereoscopicFreeCamera
  49238. * @param name defines camera name
  49239. * @param position defines initial position
  49240. * @param interaxialDistance defines distance between each color axis
  49241. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  49242. * @param scene defines the hosting scene
  49243. */
  49244. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  49245. /**
  49246. * Gets camera class name
  49247. * @returns StereoscopicFreeCamera
  49248. */
  49249. getClassName(): string;
  49250. }
  49251. }
  49252. declare module BABYLON {
  49253. /**
  49254. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  49255. * @see https://doc.babylonjs.com/features/cameras
  49256. */
  49257. export class StereoscopicGamepadCamera extends GamepadCamera {
  49258. /**
  49259. * Creates a new StereoscopicGamepadCamera
  49260. * @param name defines camera name
  49261. * @param position defines initial position
  49262. * @param interaxialDistance defines distance between each color axis
  49263. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  49264. * @param scene defines the hosting scene
  49265. */
  49266. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  49267. /**
  49268. * Gets camera class name
  49269. * @returns StereoscopicGamepadCamera
  49270. */
  49271. getClassName(): string;
  49272. }
  49273. }
  49274. declare module BABYLON {
  49275. /**
  49276. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  49277. * @see https://doc.babylonjs.com/features/cameras
  49278. */
  49279. export class StereoscopicUniversalCamera extends UniversalCamera {
  49280. /**
  49281. * Creates a new StereoscopicUniversalCamera
  49282. * @param name defines camera name
  49283. * @param position defines initial position
  49284. * @param interaxialDistance defines distance between each color axis
  49285. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  49286. * @param scene defines the hosting scene
  49287. */
  49288. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  49289. /**
  49290. * Gets camera class name
  49291. * @returns StereoscopicUniversalCamera
  49292. */
  49293. getClassName(): string;
  49294. }
  49295. }
  49296. declare module BABYLON {
  49297. /**
  49298. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  49299. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  49300. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  49301. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  49302. */
  49303. export class VirtualJoysticksCamera extends FreeCamera {
  49304. /**
  49305. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  49306. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  49307. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  49308. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  49309. * @param name Define the name of the camera in the scene
  49310. * @param position Define the start position of the camera in the scene
  49311. * @param scene Define the scene the camera belongs to
  49312. */
  49313. constructor(name: string, position: Vector3, scene: Scene);
  49314. /**
  49315. * Gets the current object class name.
  49316. * @return the class name
  49317. */
  49318. getClassName(): string;
  49319. }
  49320. }
  49321. declare module BABYLON {
  49322. /**
  49323. * This represents all the required metrics to create a VR camera.
  49324. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  49325. */
  49326. export class VRCameraMetrics {
  49327. /**
  49328. * Define the horizontal resolution off the screen.
  49329. */
  49330. hResolution: number;
  49331. /**
  49332. * Define the vertical resolution off the screen.
  49333. */
  49334. vResolution: number;
  49335. /**
  49336. * Define the horizontal screen size.
  49337. */
  49338. hScreenSize: number;
  49339. /**
  49340. * Define the vertical screen size.
  49341. */
  49342. vScreenSize: number;
  49343. /**
  49344. * Define the vertical screen center position.
  49345. */
  49346. vScreenCenter: number;
  49347. /**
  49348. * Define the distance of the eyes to the screen.
  49349. */
  49350. eyeToScreenDistance: number;
  49351. /**
  49352. * Define the distance between both lenses
  49353. */
  49354. lensSeparationDistance: number;
  49355. /**
  49356. * Define the distance between both viewer's eyes.
  49357. */
  49358. interpupillaryDistance: number;
  49359. /**
  49360. * Define the distortion factor of the VR postprocess.
  49361. * Please, touch with care.
  49362. */
  49363. distortionK: number[];
  49364. /**
  49365. * Define the chromatic aberration correction factors for the VR post process.
  49366. */
  49367. chromaAbCorrection: number[];
  49368. /**
  49369. * Define the scale factor of the post process.
  49370. * The smaller the better but the slower.
  49371. */
  49372. postProcessScaleFactor: number;
  49373. /**
  49374. * Define an offset for the lens center.
  49375. */
  49376. lensCenterOffset: number;
  49377. /**
  49378. * Define if the current vr camera should compensate the distortion of the lense or not.
  49379. */
  49380. compensateDistortion: boolean;
  49381. /**
  49382. * Defines if multiview should be enabled when rendering (Default: false)
  49383. */
  49384. multiviewEnabled: boolean;
  49385. /**
  49386. * Gets the rendering aspect ratio based on the provided resolutions.
  49387. */
  49388. get aspectRatio(): number;
  49389. /**
  49390. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  49391. */
  49392. get aspectRatioFov(): number;
  49393. /**
  49394. * @hidden
  49395. */
  49396. get leftHMatrix(): Matrix;
  49397. /**
  49398. * @hidden
  49399. */
  49400. get rightHMatrix(): Matrix;
  49401. /**
  49402. * @hidden
  49403. */
  49404. get leftPreViewMatrix(): Matrix;
  49405. /**
  49406. * @hidden
  49407. */
  49408. get rightPreViewMatrix(): Matrix;
  49409. /**
  49410. * Get the default VRMetrics based on the most generic setup.
  49411. * @returns the default vr metrics
  49412. */
  49413. static GetDefault(): VRCameraMetrics;
  49414. }
  49415. }
  49416. declare module BABYLON {
  49417. /** @hidden */
  49418. export var vrDistortionCorrectionPixelShader: {
  49419. name: string;
  49420. shader: string;
  49421. };
  49422. }
  49423. declare module BABYLON {
  49424. /**
  49425. * VRDistortionCorrectionPostProcess used for mobile VR
  49426. */
  49427. export class VRDistortionCorrectionPostProcess extends PostProcess {
  49428. private _isRightEye;
  49429. private _distortionFactors;
  49430. private _postProcessScaleFactor;
  49431. private _lensCenterOffset;
  49432. private _scaleIn;
  49433. private _scaleFactor;
  49434. private _lensCenter;
  49435. /**
  49436. * Gets a string identifying the name of the class
  49437. * @returns "VRDistortionCorrectionPostProcess" string
  49438. */
  49439. getClassName(): string;
  49440. /**
  49441. * Initializes the VRDistortionCorrectionPostProcess
  49442. * @param name The name of the effect.
  49443. * @param camera The camera to apply the render pass to.
  49444. * @param isRightEye If this is for the right eye distortion
  49445. * @param vrMetrics All the required metrics for the VR camera
  49446. */
  49447. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  49448. }
  49449. }
  49450. declare module BABYLON {
  49451. /**
  49452. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  49453. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  49454. */
  49455. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  49456. /**
  49457. * Creates a new VRDeviceOrientationArcRotateCamera
  49458. * @param name defines camera name
  49459. * @param alpha defines the camera rotation along the logitudinal axis
  49460. * @param beta defines the camera rotation along the latitudinal axis
  49461. * @param radius defines the camera distance from its target
  49462. * @param target defines the camera target
  49463. * @param scene defines the scene the camera belongs to
  49464. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  49465. * @param vrCameraMetrics defines the vr metrics associated to the camera
  49466. */
  49467. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  49468. /**
  49469. * Gets camera class name
  49470. * @returns VRDeviceOrientationArcRotateCamera
  49471. */
  49472. getClassName(): string;
  49473. }
  49474. }
  49475. declare module BABYLON {
  49476. /**
  49477. * Camera used to simulate VR rendering (based on FreeCamera)
  49478. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  49479. */
  49480. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  49481. /**
  49482. * Creates a new VRDeviceOrientationFreeCamera
  49483. * @param name defines camera name
  49484. * @param position defines the start position of the camera
  49485. * @param scene defines the scene the camera belongs to
  49486. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  49487. * @param vrCameraMetrics defines the vr metrics associated to the camera
  49488. */
  49489. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  49490. /**
  49491. * Gets camera class name
  49492. * @returns VRDeviceOrientationFreeCamera
  49493. */
  49494. getClassName(): string;
  49495. }
  49496. }
  49497. declare module BABYLON {
  49498. /**
  49499. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  49500. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  49501. */
  49502. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  49503. /**
  49504. * Creates a new VRDeviceOrientationGamepadCamera
  49505. * @param name defines camera name
  49506. * @param position defines the start position of the camera
  49507. * @param scene defines the scene the camera belongs to
  49508. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  49509. * @param vrCameraMetrics defines the vr metrics associated to the camera
  49510. */
  49511. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  49512. /**
  49513. * Gets camera class name
  49514. * @returns VRDeviceOrientationGamepadCamera
  49515. */
  49516. getClassName(): string;
  49517. }
  49518. }
  49519. declare module BABYLON {
  49520. /**
  49521. * A class extending Texture allowing drawing on a texture
  49522. * @see https://doc.babylonjs.com/how_to/dynamictexture
  49523. */
  49524. export class DynamicTexture extends Texture {
  49525. private _generateMipMaps;
  49526. private _canvas;
  49527. private _context;
  49528. /**
  49529. * Creates a DynamicTexture
  49530. * @param name defines the name of the texture
  49531. * @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
  49532. * @param scene defines the scene where you want the texture
  49533. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  49534. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  49535. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  49536. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  49537. */
  49538. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number, invertY?: boolean);
  49539. /**
  49540. * Get the current class name of the texture useful for serialization or dynamic coding.
  49541. * @returns "DynamicTexture"
  49542. */
  49543. getClassName(): string;
  49544. /**
  49545. * Gets the current state of canRescale
  49546. */
  49547. get canRescale(): boolean;
  49548. private _recreate;
  49549. /**
  49550. * Scales the texture
  49551. * @param ratio the scale factor to apply to both width and height
  49552. */
  49553. scale(ratio: number): void;
  49554. /**
  49555. * Resizes the texture
  49556. * @param width the new width
  49557. * @param height the new height
  49558. */
  49559. scaleTo(width: number, height: number): void;
  49560. /**
  49561. * Gets the context of the canvas used by the texture
  49562. * @returns the canvas context of the dynamic texture
  49563. */
  49564. getContext(): CanvasRenderingContext2D;
  49565. /**
  49566. * Clears the texture
  49567. */
  49568. clear(): void;
  49569. /**
  49570. * Updates the texture
  49571. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  49572. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  49573. */
  49574. update(invertY?: boolean, premulAlpha?: boolean): void;
  49575. /**
  49576. * Draws text onto the texture
  49577. * @param text defines the text to be drawn
  49578. * @param x defines the placement of the text from the left
  49579. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  49580. * @param font defines the font to be used with font-style, font-size, font-name
  49581. * @param color defines the color used for the text
  49582. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  49583. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  49584. * @param update defines whether texture is immediately update (default is true)
  49585. */
  49586. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  49587. /**
  49588. * Clones the texture
  49589. * @returns the clone of the texture.
  49590. */
  49591. clone(): DynamicTexture;
  49592. /**
  49593. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  49594. * @returns a serialized dynamic texture object
  49595. */
  49596. serialize(): any;
  49597. private _IsCanvasElement;
  49598. /** @hidden */
  49599. _rebuild(): void;
  49600. }
  49601. }
  49602. declare module BABYLON {
  49603. /**
  49604. * Class containing static functions to help procedurally build meshes
  49605. */
  49606. export class GroundBuilder {
  49607. /**
  49608. * Creates a ground mesh
  49609. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  49610. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  49611. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49612. * @param name defines the name of the mesh
  49613. * @param options defines the options used to create the mesh
  49614. * @param scene defines the hosting scene
  49615. * @returns the ground mesh
  49616. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  49617. */
  49618. static CreateGround(name: string, options: {
  49619. width?: number;
  49620. height?: number;
  49621. subdivisions?: number;
  49622. subdivisionsX?: number;
  49623. subdivisionsY?: number;
  49624. updatable?: boolean;
  49625. }, scene: any): Mesh;
  49626. /**
  49627. * Creates a tiled ground mesh
  49628. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  49629. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  49630. * * 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
  49631. * * 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
  49632. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49633. * @param name defines the name of the mesh
  49634. * @param options defines the options used to create the mesh
  49635. * @param scene defines the hosting scene
  49636. * @returns the tiled ground mesh
  49637. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  49638. */
  49639. static CreateTiledGround(name: string, options: {
  49640. xmin: number;
  49641. zmin: number;
  49642. xmax: number;
  49643. zmax: number;
  49644. subdivisions?: {
  49645. w: number;
  49646. h: number;
  49647. };
  49648. precision?: {
  49649. w: number;
  49650. h: number;
  49651. };
  49652. updatable?: boolean;
  49653. }, scene?: Nullable<Scene>): Mesh;
  49654. /**
  49655. * Creates a ground mesh from a height map
  49656. * * The parameter `url` sets the URL of the height map image resource.
  49657. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  49658. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  49659. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  49660. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  49661. * * 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.
  49662. * * 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).
  49663. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  49664. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49665. * @param name defines the name of the mesh
  49666. * @param url defines the url to the height map
  49667. * @param options defines the options used to create the mesh
  49668. * @param scene defines the hosting scene
  49669. * @returns the ground mesh
  49670. * @see https://doc.babylonjs.com/babylon101/height_map
  49671. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  49672. */
  49673. static CreateGroundFromHeightMap(name: string, url: string, options: {
  49674. width?: number;
  49675. height?: number;
  49676. subdivisions?: number;
  49677. minHeight?: number;
  49678. maxHeight?: number;
  49679. colorFilter?: Color3;
  49680. alphaFilter?: number;
  49681. updatable?: boolean;
  49682. onReady?: (mesh: GroundMesh) => void;
  49683. }, scene?: Nullable<Scene>): GroundMesh;
  49684. }
  49685. }
  49686. declare module BABYLON {
  49687. /**
  49688. * Class containing static functions to help procedurally build meshes
  49689. */
  49690. export class TorusBuilder {
  49691. /**
  49692. * Creates a torus mesh
  49693. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  49694. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  49695. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  49696. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49697. * * 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
  49698. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49699. * @param name defines the name of the mesh
  49700. * @param options defines the options used to create the mesh
  49701. * @param scene defines the hosting scene
  49702. * @returns the torus mesh
  49703. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  49704. */
  49705. static CreateTorus(name: string, options: {
  49706. diameter?: number;
  49707. thickness?: number;
  49708. tessellation?: number;
  49709. updatable?: boolean;
  49710. sideOrientation?: number;
  49711. frontUVs?: Vector4;
  49712. backUVs?: Vector4;
  49713. }, scene: any): Mesh;
  49714. }
  49715. }
  49716. declare module BABYLON {
  49717. /**
  49718. * Class containing static functions to help procedurally build meshes
  49719. */
  49720. export class CylinderBuilder {
  49721. /**
  49722. * Creates a cylinder or a cone mesh
  49723. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  49724. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  49725. * * 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.
  49726. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  49727. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  49728. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  49729. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  49730. * * 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).
  49731. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  49732. * * 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).
  49733. * * 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
  49734. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  49735. * * 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
  49736. * * 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.
  49737. * * If `enclose` is false, a ring surface is one element.
  49738. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  49739. * * 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
  49740. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49741. * * 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
  49742. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49743. * @param name defines the name of the mesh
  49744. * @param options defines the options used to create the mesh
  49745. * @param scene defines the hosting scene
  49746. * @returns the cylinder mesh
  49747. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  49748. */
  49749. static CreateCylinder(name: string, options: {
  49750. height?: number;
  49751. diameterTop?: number;
  49752. diameterBottom?: number;
  49753. diameter?: number;
  49754. tessellation?: number;
  49755. subdivisions?: number;
  49756. arc?: number;
  49757. faceColors?: Color4[];
  49758. faceUV?: Vector4[];
  49759. updatable?: boolean;
  49760. hasRings?: boolean;
  49761. enclose?: boolean;
  49762. cap?: number;
  49763. sideOrientation?: number;
  49764. frontUVs?: Vector4;
  49765. backUVs?: Vector4;
  49766. }, scene: any): Mesh;
  49767. }
  49768. }
  49769. declare module BABYLON {
  49770. /**
  49771. * States of the webXR experience
  49772. */
  49773. export enum WebXRState {
  49774. /**
  49775. * Transitioning to being in XR mode
  49776. */
  49777. ENTERING_XR = 0,
  49778. /**
  49779. * Transitioning to non XR mode
  49780. */
  49781. EXITING_XR = 1,
  49782. /**
  49783. * In XR mode and presenting
  49784. */
  49785. IN_XR = 2,
  49786. /**
  49787. * Not entered XR mode
  49788. */
  49789. NOT_IN_XR = 3
  49790. }
  49791. /**
  49792. * Abstraction of the XR render target
  49793. */
  49794. export interface WebXRRenderTarget extends IDisposable {
  49795. /**
  49796. * xrpresent context of the canvas which can be used to display/mirror xr content
  49797. */
  49798. canvasContext: WebGLRenderingContext;
  49799. /**
  49800. * xr layer for the canvas
  49801. */
  49802. xrLayer: Nullable<XRWebGLLayer>;
  49803. /**
  49804. * Initializes the xr layer for the session
  49805. * @param xrSession xr session
  49806. * @returns a promise that will resolve once the XR Layer has been created
  49807. */
  49808. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  49809. }
  49810. }
  49811. declare module BABYLON {
  49812. /**
  49813. * COnfiguration object for WebXR output canvas
  49814. */
  49815. export class WebXRManagedOutputCanvasOptions {
  49816. /**
  49817. * An optional canvas in case you wish to create it yourself and provide it here.
  49818. * If not provided, a new canvas will be created
  49819. */
  49820. canvasElement?: HTMLCanvasElement;
  49821. /**
  49822. * Options for this XR Layer output
  49823. */
  49824. canvasOptions?: XRWebGLLayerOptions;
  49825. /**
  49826. * CSS styling for a newly created canvas (if not provided)
  49827. */
  49828. newCanvasCssStyle?: string;
  49829. /**
  49830. * Get the default values of the configuration object
  49831. * @param engine defines the engine to use (can be null)
  49832. * @returns default values of this configuration object
  49833. */
  49834. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  49835. }
  49836. /**
  49837. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  49838. */
  49839. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  49840. private _options;
  49841. private _canvas;
  49842. private _engine;
  49843. private _originalCanvasSize;
  49844. /**
  49845. * Rendering context of the canvas which can be used to display/mirror xr content
  49846. */
  49847. canvasContext: WebGLRenderingContext;
  49848. /**
  49849. * xr layer for the canvas
  49850. */
  49851. xrLayer: Nullable<XRWebGLLayer>;
  49852. /**
  49853. * Obseervers registered here will be triggered when the xr layer was initialized
  49854. */
  49855. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  49856. /**
  49857. * Initializes the canvas to be added/removed upon entering/exiting xr
  49858. * @param _xrSessionManager The XR Session manager
  49859. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  49860. */
  49861. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  49862. /**
  49863. * Disposes of the object
  49864. */
  49865. dispose(): void;
  49866. /**
  49867. * Initializes the xr layer for the session
  49868. * @param xrSession xr session
  49869. * @returns a promise that will resolve once the XR Layer has been created
  49870. */
  49871. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  49872. private _addCanvas;
  49873. private _removeCanvas;
  49874. private _setCanvasSize;
  49875. private _setManagedOutputCanvas;
  49876. }
  49877. }
  49878. declare module BABYLON {
  49879. /**
  49880. * Manages an XRSession to work with Babylon's engine
  49881. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  49882. */
  49883. export class WebXRSessionManager implements IDisposable {
  49884. /** The scene which the session should be created for */
  49885. scene: Scene;
  49886. private _referenceSpace;
  49887. private _rttProvider;
  49888. private _sessionEnded;
  49889. private _xrNavigator;
  49890. private baseLayer;
  49891. /**
  49892. * The base reference space from which the session started. good if you want to reset your
  49893. * reference space
  49894. */
  49895. baseReferenceSpace: XRReferenceSpace;
  49896. /**
  49897. * Current XR frame
  49898. */
  49899. currentFrame: Nullable<XRFrame>;
  49900. /** WebXR timestamp updated every frame */
  49901. currentTimestamp: number;
  49902. /**
  49903. * Used just in case of a failure to initialize an immersive session.
  49904. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  49905. */
  49906. defaultHeightCompensation: number;
  49907. /**
  49908. * Fires every time a new xrFrame arrives which can be used to update the camera
  49909. */
  49910. onXRFrameObservable: Observable<XRFrame>;
  49911. /**
  49912. * Fires when the reference space changed
  49913. */
  49914. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  49915. /**
  49916. * Fires when the xr session is ended either by the device or manually done
  49917. */
  49918. onXRSessionEnded: Observable<any>;
  49919. /**
  49920. * Fires when the xr session is ended either by the device or manually done
  49921. */
  49922. onXRSessionInit: Observable<XRSession>;
  49923. /**
  49924. * Underlying xr session
  49925. */
  49926. session: XRSession;
  49927. /**
  49928. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  49929. * or get the offset the player is currently at.
  49930. */
  49931. viewerReferenceSpace: XRReferenceSpace;
  49932. /**
  49933. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  49934. * @param scene The scene which the session should be created for
  49935. */
  49936. constructor(
  49937. /** The scene which the session should be created for */
  49938. scene: Scene);
  49939. /**
  49940. * The current reference space used in this session. This reference space can constantly change!
  49941. * It is mainly used to offset the camera's position.
  49942. */
  49943. get referenceSpace(): XRReferenceSpace;
  49944. /**
  49945. * Set a new reference space and triggers the observable
  49946. */
  49947. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  49948. /**
  49949. * Disposes of the session manager
  49950. */
  49951. dispose(): void;
  49952. /**
  49953. * Stops the xrSession and restores the render loop
  49954. * @returns Promise which resolves after it exits XR
  49955. */
  49956. exitXRAsync(): Promise<void>;
  49957. /**
  49958. * Gets the correct render target texture to be rendered this frame for this eye
  49959. * @param eye the eye for which to get the render target
  49960. * @returns the render target for the specified eye
  49961. */
  49962. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  49963. /**
  49964. * Creates a WebXRRenderTarget object for the XR session
  49965. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  49966. * @param options optional options to provide when creating a new render target
  49967. * @returns a WebXR render target to which the session can render
  49968. */
  49969. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  49970. /**
  49971. * Initializes the manager
  49972. * After initialization enterXR can be called to start an XR session
  49973. * @returns Promise which resolves after it is initialized
  49974. */
  49975. initializeAsync(): Promise<void>;
  49976. /**
  49977. * Initializes an xr session
  49978. * @param xrSessionMode mode to initialize
  49979. * @param xrSessionInit defines optional and required values to pass to the session builder
  49980. * @returns a promise which will resolve once the session has been initialized
  49981. */
  49982. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  49983. /**
  49984. * Checks if a session would be supported for the creation options specified
  49985. * @param sessionMode session mode to check if supported eg. immersive-vr
  49986. * @returns A Promise that resolves to true if supported and false if not
  49987. */
  49988. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  49989. /**
  49990. * Resets the reference space to the one started the session
  49991. */
  49992. resetReferenceSpace(): void;
  49993. /**
  49994. * Starts rendering to the xr layer
  49995. */
  49996. runXRRenderLoop(): void;
  49997. /**
  49998. * Sets the reference space on the xr session
  49999. * @param referenceSpaceType space to set
  50000. * @returns a promise that will resolve once the reference space has been set
  50001. */
  50002. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  50003. /**
  50004. * Updates the render state of the session
  50005. * @param state state to set
  50006. * @returns a promise that resolves once the render state has been updated
  50007. */
  50008. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  50009. /**
  50010. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  50011. * @param sessionMode defines the session to test
  50012. * @returns a promise with boolean as final value
  50013. */
  50014. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  50015. private _createRenderTargetTexture;
  50016. }
  50017. }
  50018. declare module BABYLON {
  50019. /**
  50020. * WebXR Camera which holds the views for the xrSession
  50021. * @see https://doc.babylonjs.com/how_to/webxr_camera
  50022. */
  50023. export class WebXRCamera extends FreeCamera {
  50024. private _xrSessionManager;
  50025. private _firstFrame;
  50026. private _referenceQuaternion;
  50027. private _referencedPosition;
  50028. private _xrInvPositionCache;
  50029. private _xrInvQuaternionCache;
  50030. /**
  50031. * Observable raised before camera teleportation
  50032. */
  50033. onBeforeCameraTeleport: Observable<Vector3>;
  50034. /**
  50035. * Observable raised after camera teleportation
  50036. */
  50037. onAfterCameraTeleport: Observable<Vector3>;
  50038. /**
  50039. * Should position compensation execute on first frame.
  50040. * This is used when copying the position from a native (non XR) camera
  50041. */
  50042. compensateOnFirstFrame: boolean;
  50043. /**
  50044. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  50045. * @param name the name of the camera
  50046. * @param scene the scene to add the camera to
  50047. * @param _xrSessionManager a constructed xr session manager
  50048. */
  50049. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  50050. /**
  50051. * Return the user's height, unrelated to the current ground.
  50052. * This will be the y position of this camera, when ground level is 0.
  50053. */
  50054. get realWorldHeight(): number;
  50055. /** @hidden */
  50056. _updateForDualEyeDebugging(): void;
  50057. /**
  50058. * Sets this camera's transformation based on a non-vr camera
  50059. * @param otherCamera the non-vr camera to copy the transformation from
  50060. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  50061. */
  50062. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  50063. /**
  50064. * Gets the current instance class name ("WebXRCamera").
  50065. * @returns the class name
  50066. */
  50067. getClassName(): string;
  50068. private _rotate180;
  50069. private _updateFromXRSession;
  50070. private _updateNumberOfRigCameras;
  50071. private _updateReferenceSpace;
  50072. private _updateReferenceSpaceOffset;
  50073. }
  50074. }
  50075. declare module BABYLON {
  50076. /**
  50077. * Defining the interface required for a (webxr) feature
  50078. */
  50079. export interface IWebXRFeature extends IDisposable {
  50080. /**
  50081. * Is this feature attached
  50082. */
  50083. attached: boolean;
  50084. /**
  50085. * Should auto-attach be disabled?
  50086. */
  50087. disableAutoAttach: boolean;
  50088. /**
  50089. * Attach the feature to the session
  50090. * Will usually be called by the features manager
  50091. *
  50092. * @param force should attachment be forced (even when already attached)
  50093. * @returns true if successful.
  50094. */
  50095. attach(force?: boolean): boolean;
  50096. /**
  50097. * Detach the feature from the session
  50098. * Will usually be called by the features manager
  50099. *
  50100. * @returns true if successful.
  50101. */
  50102. detach(): boolean;
  50103. /**
  50104. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  50105. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  50106. *
  50107. * @returns whether or not the feature is compatible in this environment
  50108. */
  50109. isCompatible(): boolean;
  50110. /**
  50111. * Was this feature disposed;
  50112. */
  50113. isDisposed: boolean;
  50114. /**
  50115. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  50116. */
  50117. xrNativeFeatureName?: string;
  50118. /**
  50119. * A list of (Babylon WebXR) features this feature depends on
  50120. */
  50121. dependsOn?: string[];
  50122. }
  50123. /**
  50124. * A list of the currently available features without referencing them
  50125. */
  50126. export class WebXRFeatureName {
  50127. /**
  50128. * The name of the anchor system feature
  50129. */
  50130. static readonly ANCHOR_SYSTEM: string;
  50131. /**
  50132. * The name of the background remover feature
  50133. */
  50134. static readonly BACKGROUND_REMOVER: string;
  50135. /**
  50136. * The name of the hit test feature
  50137. */
  50138. static readonly HIT_TEST: string;
  50139. /**
  50140. * physics impostors for xr controllers feature
  50141. */
  50142. static readonly PHYSICS_CONTROLLERS: string;
  50143. /**
  50144. * The name of the plane detection feature
  50145. */
  50146. static readonly PLANE_DETECTION: string;
  50147. /**
  50148. * The name of the pointer selection feature
  50149. */
  50150. static readonly POINTER_SELECTION: string;
  50151. /**
  50152. * The name of the teleportation feature
  50153. */
  50154. static readonly TELEPORTATION: string;
  50155. /**
  50156. * The name of the feature points feature.
  50157. */
  50158. static readonly FEATURE_POINTS: string;
  50159. /**
  50160. * The name of the hand tracking feature.
  50161. */
  50162. static readonly HAND_TRACKING: string;
  50163. }
  50164. /**
  50165. * Defining the constructor of a feature. Used to register the modules.
  50166. */
  50167. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  50168. /**
  50169. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  50170. * It is mainly used in AR sessions.
  50171. *
  50172. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  50173. */
  50174. export class WebXRFeaturesManager implements IDisposable {
  50175. private _xrSessionManager;
  50176. private static readonly _AvailableFeatures;
  50177. private _features;
  50178. /**
  50179. * constructs a new features manages.
  50180. *
  50181. * @param _xrSessionManager an instance of WebXRSessionManager
  50182. */
  50183. constructor(_xrSessionManager: WebXRSessionManager);
  50184. /**
  50185. * Used to register a module. After calling this function a developer can use this feature in the scene.
  50186. * Mainly used internally.
  50187. *
  50188. * @param featureName the name of the feature to register
  50189. * @param constructorFunction the function used to construct the module
  50190. * @param version the (babylon) version of the module
  50191. * @param stable is that a stable version of this module
  50192. */
  50193. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  50194. /**
  50195. * Returns a constructor of a specific feature.
  50196. *
  50197. * @param featureName the name of the feature to construct
  50198. * @param version the version of the feature to load
  50199. * @param xrSessionManager the xrSessionManager. Used to construct the module
  50200. * @param options optional options provided to the module.
  50201. * @returns a function that, when called, will return a new instance of this feature
  50202. */
  50203. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  50204. /**
  50205. * Can be used to return the list of features currently registered
  50206. *
  50207. * @returns an Array of available features
  50208. */
  50209. static GetAvailableFeatures(): string[];
  50210. /**
  50211. * Gets the versions available for a specific feature
  50212. * @param featureName the name of the feature
  50213. * @returns an array with the available versions
  50214. */
  50215. static GetAvailableVersions(featureName: string): string[];
  50216. /**
  50217. * Return the latest unstable version of this feature
  50218. * @param featureName the name of the feature to search
  50219. * @returns the version number. if not found will return -1
  50220. */
  50221. static GetLatestVersionOfFeature(featureName: string): number;
  50222. /**
  50223. * Return the latest stable version of this feature
  50224. * @param featureName the name of the feature to search
  50225. * @returns the version number. if not found will return -1
  50226. */
  50227. static GetStableVersionOfFeature(featureName: string): number;
  50228. /**
  50229. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  50230. * Can be used during a session to start a feature
  50231. * @param featureName the name of feature to attach
  50232. */
  50233. attachFeature(featureName: string): void;
  50234. /**
  50235. * Can be used inside a session or when the session ends to detach a specific feature
  50236. * @param featureName the name of the feature to detach
  50237. */
  50238. detachFeature(featureName: string): void;
  50239. /**
  50240. * Used to disable an already-enabled feature
  50241. * The feature will be disposed and will be recreated once enabled.
  50242. * @param featureName the feature to disable
  50243. * @returns true if disable was successful
  50244. */
  50245. disableFeature(featureName: string | {
  50246. Name: string;
  50247. }): boolean;
  50248. /**
  50249. * dispose this features manager
  50250. */
  50251. dispose(): void;
  50252. /**
  50253. * 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.
  50254. * 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.
  50255. *
  50256. * @param featureName the name of the feature to load or the class of the feature
  50257. * @param version optional version to load. if not provided the latest version will be enabled
  50258. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  50259. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  50260. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  50261. * @returns a new constructed feature or throws an error if feature not found.
  50262. */
  50263. enableFeature(featureName: string | {
  50264. Name: string;
  50265. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  50266. /**
  50267. * get the implementation of an enabled feature.
  50268. * @param featureName the name of the feature to load
  50269. * @returns the feature class, if found
  50270. */
  50271. getEnabledFeature(featureName: string): IWebXRFeature;
  50272. /**
  50273. * Get the list of enabled features
  50274. * @returns an array of enabled features
  50275. */
  50276. getEnabledFeatures(): string[];
  50277. /**
  50278. * This function will exten the session creation configuration object with enabled features.
  50279. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  50280. * according to the defined "required" variable, provided during enableFeature call
  50281. * @param xrSessionInit the xr Session init object to extend
  50282. *
  50283. * @returns an extended XRSessionInit object
  50284. */
  50285. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  50286. }
  50287. }
  50288. declare module BABYLON {
  50289. /**
  50290. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  50291. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  50292. */
  50293. export class WebXRExperienceHelper implements IDisposable {
  50294. private scene;
  50295. private _nonVRCamera;
  50296. private _originalSceneAutoClear;
  50297. private _supported;
  50298. /**
  50299. * Camera used to render xr content
  50300. */
  50301. camera: WebXRCamera;
  50302. /** A features manager for this xr session */
  50303. featuresManager: WebXRFeaturesManager;
  50304. /**
  50305. * Observers registered here will be triggered after the camera's initial transformation is set
  50306. * This can be used to set a different ground level or an extra rotation.
  50307. *
  50308. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  50309. * to the position set after this observable is done executing.
  50310. */
  50311. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  50312. /**
  50313. * Fires when the state of the experience helper has changed
  50314. */
  50315. onStateChangedObservable: Observable<WebXRState>;
  50316. /** Session manager used to keep track of xr session */
  50317. sessionManager: WebXRSessionManager;
  50318. /**
  50319. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  50320. */
  50321. state: WebXRState;
  50322. /**
  50323. * Creates a WebXRExperienceHelper
  50324. * @param scene The scene the helper should be created in
  50325. */
  50326. private constructor();
  50327. /**
  50328. * Creates the experience helper
  50329. * @param scene the scene to attach the experience helper to
  50330. * @returns a promise for the experience helper
  50331. */
  50332. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  50333. /**
  50334. * Disposes of the experience helper
  50335. */
  50336. dispose(): void;
  50337. /**
  50338. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  50339. * @param sessionMode options for the XR session
  50340. * @param referenceSpaceType frame of reference of the XR session
  50341. * @param renderTarget the output canvas that will be used to enter XR mode
  50342. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  50343. * @returns promise that resolves after xr mode has entered
  50344. */
  50345. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  50346. /**
  50347. * Exits XR mode and returns the scene to its original state
  50348. * @returns promise that resolves after xr mode has exited
  50349. */
  50350. exitXRAsync(): Promise<void>;
  50351. private _nonXRToXRCamera;
  50352. private _setState;
  50353. }
  50354. }
  50355. declare module BABYLON {
  50356. /**
  50357. * X-Y values for axes in WebXR
  50358. */
  50359. export interface IWebXRMotionControllerAxesValue {
  50360. /**
  50361. * The value of the x axis
  50362. */
  50363. x: number;
  50364. /**
  50365. * The value of the y-axis
  50366. */
  50367. y: number;
  50368. }
  50369. /**
  50370. * changed / previous values for the values of this component
  50371. */
  50372. export interface IWebXRMotionControllerComponentChangesValues<T> {
  50373. /**
  50374. * current (this frame) value
  50375. */
  50376. current: T;
  50377. /**
  50378. * previous (last change) value
  50379. */
  50380. previous: T;
  50381. }
  50382. /**
  50383. * Represents changes in the component between current frame and last values recorded
  50384. */
  50385. export interface IWebXRMotionControllerComponentChanges {
  50386. /**
  50387. * will be populated with previous and current values if axes changed
  50388. */
  50389. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  50390. /**
  50391. * will be populated with previous and current values if pressed changed
  50392. */
  50393. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  50394. /**
  50395. * will be populated with previous and current values if touched changed
  50396. */
  50397. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  50398. /**
  50399. * will be populated with previous and current values if value changed
  50400. */
  50401. value?: IWebXRMotionControllerComponentChangesValues<number>;
  50402. }
  50403. /**
  50404. * This class represents a single component (for example button or thumbstick) of a motion controller
  50405. */
  50406. export class WebXRControllerComponent implements IDisposable {
  50407. /**
  50408. * the id of this component
  50409. */
  50410. id: string;
  50411. /**
  50412. * the type of the component
  50413. */
  50414. type: MotionControllerComponentType;
  50415. private _buttonIndex;
  50416. private _axesIndices;
  50417. private _axes;
  50418. private _changes;
  50419. private _currentValue;
  50420. private _hasChanges;
  50421. private _pressed;
  50422. private _touched;
  50423. /**
  50424. * button component type
  50425. */
  50426. static BUTTON_TYPE: MotionControllerComponentType;
  50427. /**
  50428. * squeeze component type
  50429. */
  50430. static SQUEEZE_TYPE: MotionControllerComponentType;
  50431. /**
  50432. * Thumbstick component type
  50433. */
  50434. static THUMBSTICK_TYPE: MotionControllerComponentType;
  50435. /**
  50436. * Touchpad component type
  50437. */
  50438. static TOUCHPAD_TYPE: MotionControllerComponentType;
  50439. /**
  50440. * trigger component type
  50441. */
  50442. static TRIGGER_TYPE: MotionControllerComponentType;
  50443. /**
  50444. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  50445. * the axes data changes
  50446. */
  50447. onAxisValueChangedObservable: Observable<{
  50448. x: number;
  50449. y: number;
  50450. }>;
  50451. /**
  50452. * Observers registered here will be triggered when the state of a button changes
  50453. * State change is either pressed / touched / value
  50454. */
  50455. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  50456. /**
  50457. * Creates a new component for a motion controller.
  50458. * It is created by the motion controller itself
  50459. *
  50460. * @param id the id of this component
  50461. * @param type the type of the component
  50462. * @param _buttonIndex index in the buttons array of the gamepad
  50463. * @param _axesIndices indices of the values in the axes array of the gamepad
  50464. */
  50465. constructor(
  50466. /**
  50467. * the id of this component
  50468. */
  50469. id: string,
  50470. /**
  50471. * the type of the component
  50472. */
  50473. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  50474. /**
  50475. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  50476. */
  50477. get axes(): IWebXRMotionControllerAxesValue;
  50478. /**
  50479. * Get the changes. Elements will be populated only if they changed with their previous and current value
  50480. */
  50481. get changes(): IWebXRMotionControllerComponentChanges;
  50482. /**
  50483. * Return whether or not the component changed the last frame
  50484. */
  50485. get hasChanges(): boolean;
  50486. /**
  50487. * is the button currently pressed
  50488. */
  50489. get pressed(): boolean;
  50490. /**
  50491. * is the button currently touched
  50492. */
  50493. get touched(): boolean;
  50494. /**
  50495. * Get the current value of this component
  50496. */
  50497. get value(): number;
  50498. /**
  50499. * Dispose this component
  50500. */
  50501. dispose(): void;
  50502. /**
  50503. * Are there axes correlating to this component
  50504. * @return true is axes data is available
  50505. */
  50506. isAxes(): boolean;
  50507. /**
  50508. * Is this component a button (hence - pressable)
  50509. * @returns true if can be pressed
  50510. */
  50511. isButton(): boolean;
  50512. /**
  50513. * update this component using the gamepad object it is in. Called on every frame
  50514. * @param nativeController the native gamepad controller object
  50515. */
  50516. update(nativeController: IMinimalMotionControllerObject): void;
  50517. }
  50518. }
  50519. declare module BABYLON {
  50520. /**
  50521. * Interface used to represent data loading progression
  50522. */
  50523. export interface ISceneLoaderProgressEvent {
  50524. /**
  50525. * Defines if data length to load can be evaluated
  50526. */
  50527. readonly lengthComputable: boolean;
  50528. /**
  50529. * Defines the loaded data length
  50530. */
  50531. readonly loaded: number;
  50532. /**
  50533. * Defines the data length to load
  50534. */
  50535. readonly total: number;
  50536. }
  50537. /**
  50538. * Interface used by SceneLoader plugins to define supported file extensions
  50539. */
  50540. export interface ISceneLoaderPluginExtensions {
  50541. /**
  50542. * Defines the list of supported extensions
  50543. */
  50544. [extension: string]: {
  50545. isBinary: boolean;
  50546. };
  50547. }
  50548. /**
  50549. * Interface used by SceneLoader plugin factory
  50550. */
  50551. export interface ISceneLoaderPluginFactory {
  50552. /**
  50553. * Defines the name of the factory
  50554. */
  50555. name: string;
  50556. /**
  50557. * Function called to create a new plugin
  50558. * @return the new plugin
  50559. */
  50560. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  50561. /**
  50562. * The callback that returns true if the data can be directly loaded.
  50563. * @param data string containing the file data
  50564. * @returns if the data can be loaded directly
  50565. */
  50566. canDirectLoad?(data: string): boolean;
  50567. }
  50568. /**
  50569. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  50570. */
  50571. export interface ISceneLoaderPluginBase {
  50572. /**
  50573. * The friendly name of this plugin.
  50574. */
  50575. name: string;
  50576. /**
  50577. * The file extensions supported by this plugin.
  50578. */
  50579. extensions: string | ISceneLoaderPluginExtensions;
  50580. /**
  50581. * The callback called when loading from a url.
  50582. * @param scene scene loading this url
  50583. * @param url url to load
  50584. * @param onSuccess callback called when the file successfully loads
  50585. * @param onProgress callback called while file is loading (if the server supports this mode)
  50586. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  50587. * @param onError callback called when the file fails to load
  50588. * @returns a file request object
  50589. */
  50590. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  50591. /**
  50592. * The callback called when loading from a file object.
  50593. * @param scene scene loading this file
  50594. * @param file defines the file to load
  50595. * @param onSuccess defines the callback to call when data is loaded
  50596. * @param onProgress defines the callback to call during loading process
  50597. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  50598. * @param onError defines the callback to call when an error occurs
  50599. * @returns a file request object
  50600. */
  50601. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  50602. /**
  50603. * The callback that returns true if the data can be directly loaded.
  50604. * @param data string containing the file data
  50605. * @returns if the data can be loaded directly
  50606. */
  50607. canDirectLoad?(data: string): boolean;
  50608. /**
  50609. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  50610. * @param scene scene loading this data
  50611. * @param data string containing the data
  50612. * @returns data to pass to the plugin
  50613. */
  50614. directLoad?(scene: Scene, data: string): any;
  50615. /**
  50616. * The callback that allows custom handling of the root url based on the response url.
  50617. * @param rootUrl the original root url
  50618. * @param responseURL the response url if available
  50619. * @returns the new root url
  50620. */
  50621. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  50622. }
  50623. /**
  50624. * Interface used to define a SceneLoader plugin
  50625. */
  50626. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  50627. /**
  50628. * Import meshes into a scene.
  50629. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  50630. * @param scene The scene to import into
  50631. * @param data The data to import
  50632. * @param rootUrl The root url for scene and resources
  50633. * @param meshes The meshes array to import into
  50634. * @param particleSystems The particle systems array to import into
  50635. * @param skeletons The skeletons array to import into
  50636. * @param onError The callback when import fails
  50637. * @returns True if successful or false otherwise
  50638. */
  50639. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  50640. /**
  50641. * Load into a scene.
  50642. * @param scene The scene to load into
  50643. * @param data The data to import
  50644. * @param rootUrl The root url for scene and resources
  50645. * @param onError The callback when import fails
  50646. * @returns True if successful or false otherwise
  50647. */
  50648. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  50649. /**
  50650. * Load into an asset container.
  50651. * @param scene The scene to load into
  50652. * @param data The data to import
  50653. * @param rootUrl The root url for scene and resources
  50654. * @param onError The callback when import fails
  50655. * @returns The loaded asset container
  50656. */
  50657. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  50658. }
  50659. /**
  50660. * Interface used to define an async SceneLoader plugin
  50661. */
  50662. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  50663. /**
  50664. * Import meshes into a scene.
  50665. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  50666. * @param scene The scene to import into
  50667. * @param data The data to import
  50668. * @param rootUrl The root url for scene and resources
  50669. * @param onProgress The callback when the load progresses
  50670. * @param fileName Defines the name of the file to load
  50671. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  50672. */
  50673. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  50674. meshes: AbstractMesh[];
  50675. particleSystems: IParticleSystem[];
  50676. skeletons: Skeleton[];
  50677. animationGroups: AnimationGroup[];
  50678. }>;
  50679. /**
  50680. * Load into a scene.
  50681. * @param scene The scene to load into
  50682. * @param data The data to import
  50683. * @param rootUrl The root url for scene and resources
  50684. * @param onProgress The callback when the load progresses
  50685. * @param fileName Defines the name of the file to load
  50686. * @returns Nothing
  50687. */
  50688. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  50689. /**
  50690. * Load into an asset container.
  50691. * @param scene The scene to load into
  50692. * @param data The data to import
  50693. * @param rootUrl The root url for scene and resources
  50694. * @param onProgress The callback when the load progresses
  50695. * @param fileName Defines the name of the file to load
  50696. * @returns The loaded asset container
  50697. */
  50698. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  50699. }
  50700. /**
  50701. * Mode that determines how to handle old animation groups before loading new ones.
  50702. */
  50703. export enum SceneLoaderAnimationGroupLoadingMode {
  50704. /**
  50705. * Reset all old animations to initial state then dispose them.
  50706. */
  50707. Clean = 0,
  50708. /**
  50709. * Stop all old animations.
  50710. */
  50711. Stop = 1,
  50712. /**
  50713. * Restart old animations from first frame.
  50714. */
  50715. Sync = 2,
  50716. /**
  50717. * Old animations remains untouched.
  50718. */
  50719. NoSync = 3
  50720. }
  50721. /**
  50722. * Defines a plugin registered by the SceneLoader
  50723. */
  50724. interface IRegisteredPlugin {
  50725. /**
  50726. * Defines the plugin to use
  50727. */
  50728. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  50729. /**
  50730. * Defines if the plugin supports binary data
  50731. */
  50732. isBinary: boolean;
  50733. }
  50734. /**
  50735. * Class used to load scene from various file formats using registered plugins
  50736. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  50737. */
  50738. export class SceneLoader {
  50739. /**
  50740. * No logging while loading
  50741. */
  50742. static readonly NO_LOGGING: number;
  50743. /**
  50744. * Minimal logging while loading
  50745. */
  50746. static readonly MINIMAL_LOGGING: number;
  50747. /**
  50748. * Summary logging while loading
  50749. */
  50750. static readonly SUMMARY_LOGGING: number;
  50751. /**
  50752. * Detailled logging while loading
  50753. */
  50754. static readonly DETAILED_LOGGING: number;
  50755. /**
  50756. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  50757. */
  50758. static get ForceFullSceneLoadingForIncremental(): boolean;
  50759. static set ForceFullSceneLoadingForIncremental(value: boolean);
  50760. /**
  50761. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  50762. */
  50763. static get ShowLoadingScreen(): boolean;
  50764. static set ShowLoadingScreen(value: boolean);
  50765. /**
  50766. * Defines the current logging level (while loading the scene)
  50767. * @ignorenaming
  50768. */
  50769. static get loggingLevel(): number;
  50770. static set loggingLevel(value: number);
  50771. /**
  50772. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  50773. */
  50774. static get CleanBoneMatrixWeights(): boolean;
  50775. static set CleanBoneMatrixWeights(value: boolean);
  50776. /**
  50777. * Event raised when a plugin is used to load a scene
  50778. */
  50779. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  50780. private static _registeredPlugins;
  50781. private static _showingLoadingScreen;
  50782. /**
  50783. * Gets the default plugin (used to load Babylon files)
  50784. * @returns the .babylon plugin
  50785. */
  50786. static GetDefaultPlugin(): IRegisteredPlugin;
  50787. private static _GetPluginForExtension;
  50788. private static _GetPluginForDirectLoad;
  50789. private static _GetPluginForFilename;
  50790. private static _GetDirectLoad;
  50791. private static _LoadData;
  50792. private static _GetFileInfo;
  50793. /**
  50794. * Gets a plugin that can load the given extension
  50795. * @param extension defines the extension to load
  50796. * @returns a plugin or null if none works
  50797. */
  50798. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  50799. /**
  50800. * Gets a boolean indicating that the given extension can be loaded
  50801. * @param extension defines the extension to load
  50802. * @returns true if the extension is supported
  50803. */
  50804. static IsPluginForExtensionAvailable(extension: string): boolean;
  50805. /**
  50806. * Adds a new plugin to the list of registered plugins
  50807. * @param plugin defines the plugin to add
  50808. */
  50809. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  50810. /**
  50811. * Import meshes into a scene
  50812. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  50813. * @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)
  50814. * @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)
  50815. * @param scene the instance of BABYLON.Scene to append to
  50816. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  50817. * @param onProgress a callback with a progress event for each file being loaded
  50818. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  50819. * @param pluginExtension the extension used to determine the plugin
  50820. * @returns The loaded plugin
  50821. */
  50822. 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>;
  50823. /**
  50824. * Import meshes into a scene
  50825. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  50826. * @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)
  50827. * @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)
  50828. * @param scene the instance of BABYLON.Scene to append to
  50829. * @param onProgress a callback with a progress event for each file being loaded
  50830. * @param pluginExtension the extension used to determine the plugin
  50831. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  50832. */
  50833. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  50834. meshes: AbstractMesh[];
  50835. particleSystems: IParticleSystem[];
  50836. skeletons: Skeleton[];
  50837. animationGroups: AnimationGroup[];
  50838. }>;
  50839. /**
  50840. * Load a scene
  50841. * @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)
  50842. * @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)
  50843. * @param engine is the instance of BABYLON.Engine to use to create the scene
  50844. * @param onSuccess a callback with the scene when import succeeds
  50845. * @param onProgress a callback with a progress event for each file being loaded
  50846. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  50847. * @param pluginExtension the extension used to determine the plugin
  50848. * @returns The loaded plugin
  50849. */
  50850. 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>;
  50851. /**
  50852. * Load a scene
  50853. * @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)
  50854. * @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)
  50855. * @param engine is the instance of BABYLON.Engine to use to create the scene
  50856. * @param onProgress a callback with a progress event for each file being loaded
  50857. * @param pluginExtension the extension used to determine the plugin
  50858. * @returns The loaded scene
  50859. */
  50860. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  50861. /**
  50862. * Append a scene
  50863. * @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)
  50864. * @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)
  50865. * @param scene is the instance of BABYLON.Scene to append to
  50866. * @param onSuccess a callback with the scene when import succeeds
  50867. * @param onProgress a callback with a progress event for each file being loaded
  50868. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  50869. * @param pluginExtension the extension used to determine the plugin
  50870. * @returns The loaded plugin
  50871. */
  50872. 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>;
  50873. /**
  50874. * Append a scene
  50875. * @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)
  50876. * @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)
  50877. * @param scene is the instance of BABYLON.Scene to append to
  50878. * @param onProgress a callback with a progress event for each file being loaded
  50879. * @param pluginExtension the extension used to determine the plugin
  50880. * @returns The given scene
  50881. */
  50882. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  50883. /**
  50884. * Load a scene into an asset container
  50885. * @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)
  50886. * @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)
  50887. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  50888. * @param onSuccess a callback with the scene when import succeeds
  50889. * @param onProgress a callback with a progress event for each file being loaded
  50890. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  50891. * @param pluginExtension the extension used to determine the plugin
  50892. * @returns The loaded plugin
  50893. */
  50894. 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>;
  50895. /**
  50896. * Load a scene into an asset container
  50897. * @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)
  50898. * @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)
  50899. * @param scene is the instance of Scene to append to
  50900. * @param onProgress a callback with a progress event for each file being loaded
  50901. * @param pluginExtension the extension used to determine the plugin
  50902. * @returns The loaded asset container
  50903. */
  50904. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  50905. /**
  50906. * Import animations from a file into a scene
  50907. * @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)
  50908. * @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)
  50909. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  50910. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  50911. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  50912. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  50913. * @param onSuccess a callback with the scene when import succeeds
  50914. * @param onProgress a callback with a progress event for each file being loaded
  50915. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  50916. * @param pluginExtension the extension used to determine the plugin
  50917. */
  50918. 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;
  50919. /**
  50920. * Import animations from a file into a scene
  50921. * @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)
  50922. * @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)
  50923. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  50924. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  50925. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  50926. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  50927. * @param onSuccess a callback with the scene when import succeeds
  50928. * @param onProgress a callback with a progress event for each file being loaded
  50929. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  50930. * @param pluginExtension the extension used to determine the plugin
  50931. * @returns the updated scene with imported animations
  50932. */
  50933. 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>;
  50934. }
  50935. }
  50936. declare module BABYLON {
  50937. /**
  50938. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  50939. */
  50940. export type MotionControllerHandedness = "none" | "left" | "right";
  50941. /**
  50942. * The type of components available in motion controllers.
  50943. * This is not the name of the component.
  50944. */
  50945. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  50946. /**
  50947. * The state of a controller component
  50948. */
  50949. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  50950. /**
  50951. * The schema of motion controller layout.
  50952. * No object will be initialized using this interface
  50953. * This is used just to define the profile.
  50954. */
  50955. export interface IMotionControllerLayout {
  50956. /**
  50957. * Path to load the assets. Usually relative to the base path
  50958. */
  50959. assetPath: string;
  50960. /**
  50961. * Available components (unsorted)
  50962. */
  50963. components: {
  50964. /**
  50965. * A map of component Ids
  50966. */
  50967. [componentId: string]: {
  50968. /**
  50969. * The type of input the component outputs
  50970. */
  50971. type: MotionControllerComponentType;
  50972. /**
  50973. * The indices of this component in the gamepad object
  50974. */
  50975. gamepadIndices: {
  50976. /**
  50977. * Index of button
  50978. */
  50979. button?: number;
  50980. /**
  50981. * If available, index of x-axis
  50982. */
  50983. xAxis?: number;
  50984. /**
  50985. * If available, index of y-axis
  50986. */
  50987. yAxis?: number;
  50988. };
  50989. /**
  50990. * The mesh's root node name
  50991. */
  50992. rootNodeName: string;
  50993. /**
  50994. * Animation definitions for this model
  50995. */
  50996. visualResponses: {
  50997. [stateKey: string]: {
  50998. /**
  50999. * What property will be animated
  51000. */
  51001. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  51002. /**
  51003. * What states influence this visual response
  51004. */
  51005. states: MotionControllerComponentStateType[];
  51006. /**
  51007. * Type of animation - movement or visibility
  51008. */
  51009. valueNodeProperty: "transform" | "visibility";
  51010. /**
  51011. * Base node name to move. Its position will be calculated according to the min and max nodes
  51012. */
  51013. valueNodeName?: string;
  51014. /**
  51015. * Minimum movement node
  51016. */
  51017. minNodeName?: string;
  51018. /**
  51019. * Max movement node
  51020. */
  51021. maxNodeName?: string;
  51022. };
  51023. };
  51024. /**
  51025. * If touch enabled, what is the name of node to display user feedback
  51026. */
  51027. touchPointNodeName?: string;
  51028. };
  51029. };
  51030. /**
  51031. * Is it xr standard mapping or not
  51032. */
  51033. gamepadMapping: "" | "xr-standard";
  51034. /**
  51035. * Base root node of this entire model
  51036. */
  51037. rootNodeName: string;
  51038. /**
  51039. * Defines the main button component id
  51040. */
  51041. selectComponentId: string;
  51042. }
  51043. /**
  51044. * A definition for the layout map in the input profile
  51045. */
  51046. export interface IMotionControllerLayoutMap {
  51047. /**
  51048. * Layouts with handedness type as a key
  51049. */
  51050. [handedness: string]: IMotionControllerLayout;
  51051. }
  51052. /**
  51053. * The XR Input profile schema
  51054. * Profiles can be found here:
  51055. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  51056. */
  51057. export interface IMotionControllerProfile {
  51058. /**
  51059. * fallback profiles for this profileId
  51060. */
  51061. fallbackProfileIds: string[];
  51062. /**
  51063. * The layout map, with handedness as key
  51064. */
  51065. layouts: IMotionControllerLayoutMap;
  51066. /**
  51067. * The id of this profile
  51068. * correlates to the profile(s) in the xrInput.profiles array
  51069. */
  51070. profileId: string;
  51071. }
  51072. /**
  51073. * A helper-interface for the 3 meshes needed for controller button animation
  51074. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  51075. */
  51076. export interface IMotionControllerButtonMeshMap {
  51077. /**
  51078. * the mesh that defines the pressed value mesh position.
  51079. * This is used to find the max-position of this button
  51080. */
  51081. pressedMesh: AbstractMesh;
  51082. /**
  51083. * the mesh that defines the unpressed value mesh position.
  51084. * This is used to find the min (or initial) position of this button
  51085. */
  51086. unpressedMesh: AbstractMesh;
  51087. /**
  51088. * The mesh that will be changed when value changes
  51089. */
  51090. valueMesh: AbstractMesh;
  51091. }
  51092. /**
  51093. * A helper-interface for the 3 meshes needed for controller axis animation.
  51094. * This will be expanded when touchpad animations are fully supported
  51095. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  51096. */
  51097. export interface IMotionControllerMeshMap {
  51098. /**
  51099. * the mesh that defines the maximum value mesh position.
  51100. */
  51101. maxMesh?: AbstractMesh;
  51102. /**
  51103. * the mesh that defines the minimum value mesh position.
  51104. */
  51105. minMesh?: AbstractMesh;
  51106. /**
  51107. * The mesh that will be changed when axis value changes
  51108. */
  51109. valueMesh?: AbstractMesh;
  51110. }
  51111. /**
  51112. * The elements needed for change-detection of the gamepad objects in motion controllers
  51113. */
  51114. export interface IMinimalMotionControllerObject {
  51115. /**
  51116. * Available axes of this controller
  51117. */
  51118. axes: number[];
  51119. /**
  51120. * An array of available buttons
  51121. */
  51122. buttons: Array<{
  51123. /**
  51124. * Value of the button/trigger
  51125. */
  51126. value: number;
  51127. /**
  51128. * If the button/trigger is currently touched
  51129. */
  51130. touched: boolean;
  51131. /**
  51132. * If the button/trigger is currently pressed
  51133. */
  51134. pressed: boolean;
  51135. }>;
  51136. /**
  51137. * EXPERIMENTAL haptic support.
  51138. */
  51139. hapticActuators?: Array<{
  51140. pulse: (value: number, duration: number) => Promise<boolean>;
  51141. }>;
  51142. }
  51143. /**
  51144. * An Abstract Motion controller
  51145. * This class receives an xrInput and a profile layout and uses those to initialize the components
  51146. * Each component has an observable to check for changes in value and state
  51147. */
  51148. export abstract class WebXRAbstractMotionController implements IDisposable {
  51149. protected scene: Scene;
  51150. protected layout: IMotionControllerLayout;
  51151. /**
  51152. * The gamepad object correlating to this controller
  51153. */
  51154. gamepadObject: IMinimalMotionControllerObject;
  51155. /**
  51156. * handedness (left/right/none) of this controller
  51157. */
  51158. handedness: MotionControllerHandedness;
  51159. private _initComponent;
  51160. private _modelReady;
  51161. /**
  51162. * A map of components (WebXRControllerComponent) in this motion controller
  51163. * Components have a ComponentType and can also have both button and axis definitions
  51164. */
  51165. readonly components: {
  51166. [id: string]: WebXRControllerComponent;
  51167. };
  51168. /**
  51169. * Disable the model's animation. Can be set at any time.
  51170. */
  51171. disableAnimation: boolean;
  51172. /**
  51173. * Observers registered here will be triggered when the model of this controller is done loading
  51174. */
  51175. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  51176. /**
  51177. * The profile id of this motion controller
  51178. */
  51179. abstract profileId: string;
  51180. /**
  51181. * The root mesh of the model. It is null if the model was not yet initialized
  51182. */
  51183. rootMesh: Nullable<AbstractMesh>;
  51184. /**
  51185. * constructs a new abstract motion controller
  51186. * @param scene the scene to which the model of the controller will be added
  51187. * @param layout The profile layout to load
  51188. * @param gamepadObject The gamepad object correlating to this controller
  51189. * @param handedness handedness (left/right/none) of this controller
  51190. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  51191. */
  51192. constructor(scene: Scene, layout: IMotionControllerLayout,
  51193. /**
  51194. * The gamepad object correlating to this controller
  51195. */
  51196. gamepadObject: IMinimalMotionControllerObject,
  51197. /**
  51198. * handedness (left/right/none) of this controller
  51199. */
  51200. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  51201. /**
  51202. * Dispose this controller, the model mesh and all its components
  51203. */
  51204. dispose(): void;
  51205. /**
  51206. * Returns all components of specific type
  51207. * @param type the type to search for
  51208. * @return an array of components with this type
  51209. */
  51210. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  51211. /**
  51212. * get a component based an its component id as defined in layout.components
  51213. * @param id the id of the component
  51214. * @returns the component correlates to the id or undefined if not found
  51215. */
  51216. getComponent(id: string): WebXRControllerComponent;
  51217. /**
  51218. * Get the list of components available in this motion controller
  51219. * @returns an array of strings correlating to available components
  51220. */
  51221. getComponentIds(): string[];
  51222. /**
  51223. * Get the first component of specific type
  51224. * @param type type of component to find
  51225. * @return a controller component or null if not found
  51226. */
  51227. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  51228. /**
  51229. * Get the main (Select) component of this controller as defined in the layout
  51230. * @returns the main component of this controller
  51231. */
  51232. getMainComponent(): WebXRControllerComponent;
  51233. /**
  51234. * Loads the model correlating to this controller
  51235. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  51236. * @returns A promise fulfilled with the result of the model loading
  51237. */
  51238. loadModel(): Promise<boolean>;
  51239. /**
  51240. * Update this model using the current XRFrame
  51241. * @param xrFrame the current xr frame to use and update the model
  51242. */
  51243. updateFromXRFrame(xrFrame: XRFrame): void;
  51244. /**
  51245. * Backwards compatibility due to a deeply-integrated typo
  51246. */
  51247. get handness(): XREye;
  51248. /**
  51249. * Pulse (vibrate) this controller
  51250. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  51251. * Consecutive calls to this function will cancel the last pulse call
  51252. *
  51253. * @param value the strength of the pulse in 0.0...1.0 range
  51254. * @param duration Duration of the pulse in milliseconds
  51255. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  51256. * @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
  51257. */
  51258. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  51259. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  51260. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  51261. /**
  51262. * Moves the axis on the controller mesh based on its current state
  51263. * @param axis the index of the axis
  51264. * @param axisValue the value of the axis which determines the meshes new position
  51265. * @hidden
  51266. */
  51267. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  51268. /**
  51269. * Update the model itself with the current frame data
  51270. * @param xrFrame the frame to use for updating the model mesh
  51271. */
  51272. protected updateModel(xrFrame: XRFrame): void;
  51273. /**
  51274. * Get the filename and path for this controller's model
  51275. * @returns a map of filename and path
  51276. */
  51277. protected abstract _getFilenameAndPath(): {
  51278. filename: string;
  51279. path: string;
  51280. };
  51281. /**
  51282. * This function is called before the mesh is loaded. It checks for loading constraints.
  51283. * For example, this function can check if the GLB loader is available
  51284. * If this function returns false, the generic controller will be loaded instead
  51285. * @returns Is the client ready to load the mesh
  51286. */
  51287. protected abstract _getModelLoadingConstraints(): boolean;
  51288. /**
  51289. * This function will be called after the model was successfully loaded and can be used
  51290. * for mesh transformations before it is available for the user
  51291. * @param meshes the loaded meshes
  51292. */
  51293. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  51294. /**
  51295. * Set the root mesh for this controller. Important for the WebXR controller class
  51296. * @param meshes the loaded meshes
  51297. */
  51298. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  51299. /**
  51300. * A function executed each frame that updates the mesh (if needed)
  51301. * @param xrFrame the current xrFrame
  51302. */
  51303. protected abstract _updateModel(xrFrame: XRFrame): void;
  51304. private _getGenericFilenameAndPath;
  51305. private _getGenericParentMesh;
  51306. }
  51307. }
  51308. declare module BABYLON {
  51309. /**
  51310. * A generic trigger-only motion controller for WebXR
  51311. */
  51312. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  51313. /**
  51314. * Static version of the profile id of this controller
  51315. */
  51316. static ProfileId: string;
  51317. profileId: string;
  51318. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  51319. protected _getFilenameAndPath(): {
  51320. filename: string;
  51321. path: string;
  51322. };
  51323. protected _getModelLoadingConstraints(): boolean;
  51324. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  51325. protected _setRootMesh(meshes: AbstractMesh[]): void;
  51326. protected _updateModel(): void;
  51327. }
  51328. }
  51329. declare module BABYLON {
  51330. /**
  51331. * Class containing static functions to help procedurally build meshes
  51332. */
  51333. export class SphereBuilder {
  51334. /**
  51335. * Creates a sphere mesh
  51336. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  51337. * * 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`)
  51338. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  51339. * * 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
  51340. * * 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)
  51341. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51342. * * 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
  51343. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51344. * @param name defines the name of the mesh
  51345. * @param options defines the options used to create the mesh
  51346. * @param scene defines the hosting scene
  51347. * @returns the sphere mesh
  51348. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  51349. */
  51350. static CreateSphere(name: string, options: {
  51351. segments?: number;
  51352. diameter?: number;
  51353. diameterX?: number;
  51354. diameterY?: number;
  51355. diameterZ?: number;
  51356. arc?: number;
  51357. slice?: number;
  51358. sideOrientation?: number;
  51359. frontUVs?: Vector4;
  51360. backUVs?: Vector4;
  51361. updatable?: boolean;
  51362. }, scene?: Nullable<Scene>): Mesh;
  51363. }
  51364. }
  51365. declare module BABYLON {
  51366. /**
  51367. * A profiled motion controller has its profile loaded from an online repository.
  51368. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  51369. */
  51370. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  51371. private _repositoryUrl;
  51372. private _buttonMeshMapping;
  51373. private _touchDots;
  51374. /**
  51375. * The profile ID of this controller. Will be populated when the controller initializes.
  51376. */
  51377. profileId: string;
  51378. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  51379. dispose(): void;
  51380. protected _getFilenameAndPath(): {
  51381. filename: string;
  51382. path: string;
  51383. };
  51384. protected _getModelLoadingConstraints(): boolean;
  51385. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  51386. protected _setRootMesh(meshes: AbstractMesh[]): void;
  51387. protected _updateModel(_xrFrame: XRFrame): void;
  51388. }
  51389. }
  51390. declare module BABYLON {
  51391. /**
  51392. * A construction function type to create a new controller based on an xrInput object
  51393. */
  51394. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  51395. /**
  51396. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  51397. *
  51398. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  51399. * it should be replaced with auto-loaded controllers.
  51400. *
  51401. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  51402. */
  51403. export class WebXRMotionControllerManager {
  51404. private static _AvailableControllers;
  51405. private static _Fallbacks;
  51406. private static _ProfileLoadingPromises;
  51407. private static _ProfilesList;
  51408. /**
  51409. * The base URL of the online controller repository. Can be changed at any time.
  51410. */
  51411. static BaseRepositoryUrl: string;
  51412. /**
  51413. * Which repository gets priority - local or online
  51414. */
  51415. static PrioritizeOnlineRepository: boolean;
  51416. /**
  51417. * Use the online repository, or use only locally-defined controllers
  51418. */
  51419. static UseOnlineRepository: boolean;
  51420. /**
  51421. * Clear the cache used for profile loading and reload when requested again
  51422. */
  51423. static ClearProfilesCache(): void;
  51424. /**
  51425. * Register the default fallbacks.
  51426. * This function is called automatically when this file is imported.
  51427. */
  51428. static DefaultFallbacks(): void;
  51429. /**
  51430. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  51431. * @param profileId the profile to which a fallback needs to be found
  51432. * @return an array with corresponding fallback profiles
  51433. */
  51434. static FindFallbackWithProfileId(profileId: string): string[];
  51435. /**
  51436. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  51437. * The order of search:
  51438. *
  51439. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  51440. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  51441. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  51442. * 4) return the generic trigger controller if none were found
  51443. *
  51444. * @param xrInput the xrInput to which a new controller is initialized
  51445. * @param scene the scene to which the model will be added
  51446. * @param forceProfile force a certain profile for this controller
  51447. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  51448. */
  51449. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  51450. /**
  51451. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  51452. *
  51453. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  51454. *
  51455. * @param type the profile type to register
  51456. * @param constructFunction the function to be called when loading this profile
  51457. */
  51458. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  51459. /**
  51460. * Register a fallback to a specific profile.
  51461. * @param profileId the profileId that will receive the fallbacks
  51462. * @param fallbacks A list of fallback profiles
  51463. */
  51464. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  51465. /**
  51466. * Will update the list of profiles available in the repository
  51467. * @return a promise that resolves to a map of profiles available online
  51468. */
  51469. static UpdateProfilesList(): Promise<{
  51470. [profile: string]: string;
  51471. }>;
  51472. private static _LoadProfileFromRepository;
  51473. private static _LoadProfilesFromAvailableControllers;
  51474. }
  51475. }
  51476. declare module BABYLON {
  51477. /**
  51478. * Configuration options for the WebXR controller creation
  51479. */
  51480. export interface IWebXRControllerOptions {
  51481. /**
  51482. * Should the controller mesh be animated when a user interacts with it
  51483. * The pressed buttons / thumbstick and touchpad animations will be disabled
  51484. */
  51485. disableMotionControllerAnimation?: boolean;
  51486. /**
  51487. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  51488. */
  51489. doNotLoadControllerMesh?: boolean;
  51490. /**
  51491. * Force a specific controller type for this controller.
  51492. * This can be used when creating your own profile or when testing different controllers
  51493. */
  51494. forceControllerProfile?: string;
  51495. /**
  51496. * Defines a rendering group ID for meshes that will be loaded.
  51497. * This is for the default controllers only.
  51498. */
  51499. renderingGroupId?: number;
  51500. }
  51501. /**
  51502. * Represents an XR controller
  51503. */
  51504. export class WebXRInputSource {
  51505. private _scene;
  51506. /** The underlying input source for the controller */
  51507. inputSource: XRInputSource;
  51508. private _options;
  51509. private _tmpVector;
  51510. private _uniqueId;
  51511. private _disposed;
  51512. /**
  51513. * 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
  51514. */
  51515. grip?: AbstractMesh;
  51516. /**
  51517. * If available, this is the gamepad object related to this controller.
  51518. * Using this object it is possible to get click events and trackpad changes of the
  51519. * webxr controller that is currently being used.
  51520. */
  51521. motionController?: WebXRAbstractMotionController;
  51522. /**
  51523. * Event that fires when the controller is removed/disposed.
  51524. * The object provided as event data is this controller, after associated assets were disposed.
  51525. * uniqueId is still available.
  51526. */
  51527. onDisposeObservable: Observable<WebXRInputSource>;
  51528. /**
  51529. * Will be triggered when the mesh associated with the motion controller is done loading.
  51530. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  51531. * A shortened version of controller -> motion controller -> on mesh loaded.
  51532. */
  51533. onMeshLoadedObservable: Observable<AbstractMesh>;
  51534. /**
  51535. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  51536. */
  51537. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  51538. /**
  51539. * Pointer which can be used to select objects or attach a visible laser to
  51540. */
  51541. pointer: AbstractMesh;
  51542. /**
  51543. * Creates the input source object
  51544. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  51545. * @param _scene the scene which the controller should be associated to
  51546. * @param inputSource the underlying input source for the controller
  51547. * @param _options options for this controller creation
  51548. */
  51549. constructor(_scene: Scene,
  51550. /** The underlying input source for the controller */
  51551. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  51552. /**
  51553. * Get this controllers unique id
  51554. */
  51555. get uniqueId(): string;
  51556. /**
  51557. * Disposes of the object
  51558. */
  51559. dispose(): void;
  51560. /**
  51561. * Gets a world space ray coming from the pointer or grip
  51562. * @param result the resulting ray
  51563. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  51564. */
  51565. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  51566. /**
  51567. * Updates the controller pose based on the given XRFrame
  51568. * @param xrFrame xr frame to update the pose with
  51569. * @param referenceSpace reference space to use
  51570. */
  51571. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  51572. }
  51573. }
  51574. declare module BABYLON {
  51575. /**
  51576. * The schema for initialization options of the XR Input class
  51577. */
  51578. export interface IWebXRInputOptions {
  51579. /**
  51580. * If set to true no model will be automatically loaded
  51581. */
  51582. doNotLoadControllerMeshes?: boolean;
  51583. /**
  51584. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  51585. * If not found, the xr input profile data will be used.
  51586. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  51587. */
  51588. forceInputProfile?: string;
  51589. /**
  51590. * Do not send a request to the controller repository to load the profile.
  51591. *
  51592. * Instead, use the controllers available in babylon itself.
  51593. */
  51594. disableOnlineControllerRepository?: boolean;
  51595. /**
  51596. * A custom URL for the controllers repository
  51597. */
  51598. customControllersRepositoryURL?: string;
  51599. /**
  51600. * Should the controller model's components not move according to the user input
  51601. */
  51602. disableControllerAnimation?: boolean;
  51603. /**
  51604. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  51605. */
  51606. controllerOptions?: IWebXRControllerOptions;
  51607. }
  51608. /**
  51609. * XR input used to track XR inputs such as controllers/rays
  51610. */
  51611. export class WebXRInput implements IDisposable {
  51612. /**
  51613. * the xr session manager for this session
  51614. */
  51615. xrSessionManager: WebXRSessionManager;
  51616. /**
  51617. * the WebXR camera for this session. Mainly used for teleportation
  51618. */
  51619. xrCamera: WebXRCamera;
  51620. private readonly options;
  51621. /**
  51622. * XR controllers being tracked
  51623. */
  51624. controllers: Array<WebXRInputSource>;
  51625. private _frameObserver;
  51626. private _sessionEndedObserver;
  51627. private _sessionInitObserver;
  51628. /**
  51629. * Event when a controller has been connected/added
  51630. */
  51631. onControllerAddedObservable: Observable<WebXRInputSource>;
  51632. /**
  51633. * Event when a controller has been removed/disconnected
  51634. */
  51635. onControllerRemovedObservable: Observable<WebXRInputSource>;
  51636. /**
  51637. * Initializes the WebXRInput
  51638. * @param xrSessionManager the xr session manager for this session
  51639. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  51640. * @param options = initialization options for this xr input
  51641. */
  51642. constructor(
  51643. /**
  51644. * the xr session manager for this session
  51645. */
  51646. xrSessionManager: WebXRSessionManager,
  51647. /**
  51648. * the WebXR camera for this session. Mainly used for teleportation
  51649. */
  51650. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  51651. private _onInputSourcesChange;
  51652. private _addAndRemoveControllers;
  51653. /**
  51654. * Disposes of the object
  51655. */
  51656. dispose(): void;
  51657. }
  51658. }
  51659. declare module BABYLON {
  51660. /**
  51661. * This is the base class for all WebXR features.
  51662. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  51663. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  51664. */
  51665. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  51666. protected _xrSessionManager: WebXRSessionManager;
  51667. private _attached;
  51668. private _removeOnDetach;
  51669. /**
  51670. * Is this feature disposed?
  51671. */
  51672. isDisposed: boolean;
  51673. /**
  51674. * Should auto-attach be disabled?
  51675. */
  51676. disableAutoAttach: boolean;
  51677. /**
  51678. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  51679. */
  51680. xrNativeFeatureName: string;
  51681. /**
  51682. * Construct a new (abstract) WebXR feature
  51683. * @param _xrSessionManager the xr session manager for this feature
  51684. */
  51685. constructor(_xrSessionManager: WebXRSessionManager);
  51686. /**
  51687. * Is this feature attached
  51688. */
  51689. get attached(): boolean;
  51690. /**
  51691. * attach this feature
  51692. *
  51693. * @param force should attachment be forced (even when already attached)
  51694. * @returns true if successful, false is failed or already attached
  51695. */
  51696. attach(force?: boolean): boolean;
  51697. /**
  51698. * detach this feature.
  51699. *
  51700. * @returns true if successful, false if failed or already detached
  51701. */
  51702. detach(): boolean;
  51703. /**
  51704. * Dispose this feature and all of the resources attached
  51705. */
  51706. dispose(): void;
  51707. /**
  51708. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  51709. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  51710. *
  51711. * @returns whether or not the feature is compatible in this environment
  51712. */
  51713. isCompatible(): boolean;
  51714. /**
  51715. * This is used to register callbacks that will automatically be removed when detach is called.
  51716. * @param observable the observable to which the observer will be attached
  51717. * @param callback the callback to register
  51718. */
  51719. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  51720. /**
  51721. * Code in this function will be executed on each xrFrame received from the browser.
  51722. * This function will not execute after the feature is detached.
  51723. * @param _xrFrame the current frame
  51724. */
  51725. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  51726. }
  51727. }
  51728. declare module BABYLON {
  51729. /**
  51730. * Renders a layer on top of an existing scene
  51731. */
  51732. export class UtilityLayerRenderer implements IDisposable {
  51733. /** the original scene that will be rendered on top of */
  51734. originalScene: Scene;
  51735. private _pointerCaptures;
  51736. private _lastPointerEvents;
  51737. private static _DefaultUtilityLayer;
  51738. private static _DefaultKeepDepthUtilityLayer;
  51739. private _sharedGizmoLight;
  51740. private _renderCamera;
  51741. /**
  51742. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  51743. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  51744. * @returns the camera that is used when rendering the utility layer
  51745. */
  51746. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  51747. /**
  51748. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  51749. * @param cam the camera that should be used when rendering the utility layer
  51750. */
  51751. setRenderCamera(cam: Nullable<Camera>): void;
  51752. /**
  51753. * @hidden
  51754. * Light which used by gizmos to get light shading
  51755. */
  51756. _getSharedGizmoLight(): HemisphericLight;
  51757. /**
  51758. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  51759. */
  51760. pickUtilitySceneFirst: boolean;
  51761. /**
  51762. * 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)
  51763. */
  51764. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  51765. /**
  51766. * 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)
  51767. */
  51768. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  51769. /**
  51770. * The scene that is rendered on top of the original scene
  51771. */
  51772. utilityLayerScene: Scene;
  51773. /**
  51774. * If the utility layer should automatically be rendered on top of existing scene
  51775. */
  51776. shouldRender: boolean;
  51777. /**
  51778. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  51779. */
  51780. onlyCheckPointerDownEvents: boolean;
  51781. /**
  51782. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  51783. */
  51784. processAllEvents: boolean;
  51785. /**
  51786. * Observable raised when the pointer move from the utility layer scene to the main scene
  51787. */
  51788. onPointerOutObservable: Observable<number>;
  51789. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  51790. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  51791. private _afterRenderObserver;
  51792. private _sceneDisposeObserver;
  51793. private _originalPointerObserver;
  51794. /**
  51795. * Instantiates a UtilityLayerRenderer
  51796. * @param originalScene the original scene that will be rendered on top of
  51797. * @param handleEvents boolean indicating if the utility layer should handle events
  51798. */
  51799. constructor(
  51800. /** the original scene that will be rendered on top of */
  51801. originalScene: Scene, handleEvents?: boolean);
  51802. private _notifyObservers;
  51803. /**
  51804. * Renders the utility layers scene on top of the original scene
  51805. */
  51806. render(): void;
  51807. /**
  51808. * Disposes of the renderer
  51809. */
  51810. dispose(): void;
  51811. private _updateCamera;
  51812. }
  51813. }
  51814. declare module BABYLON {
  51815. /**
  51816. * Options interface for the pointer selection module
  51817. */
  51818. export interface IWebXRControllerPointerSelectionOptions {
  51819. /**
  51820. * if provided, this scene will be used to render meshes.
  51821. */
  51822. customUtilityLayerScene?: Scene;
  51823. /**
  51824. * 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)
  51825. * If not disabled, the last picked point will be used to execute a pointer up event
  51826. * If disabled, pointer up event will be triggered right after the pointer down event.
  51827. * Used in screen and gaze target ray mode only
  51828. */
  51829. disablePointerUpOnTouchOut: boolean;
  51830. /**
  51831. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  51832. */
  51833. forceGazeMode: boolean;
  51834. /**
  51835. * 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
  51836. * to start a new countdown to the pointer down event.
  51837. * Defaults to 1.
  51838. */
  51839. gazeModePointerMovedFactor?: number;
  51840. /**
  51841. * Different button type to use instead of the main component
  51842. */
  51843. overrideButtonId?: string;
  51844. /**
  51845. * use this rendering group id for the meshes (optional)
  51846. */
  51847. renderingGroupId?: number;
  51848. /**
  51849. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  51850. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  51851. * 3000 means 3 seconds between pointing at something and selecting it
  51852. */
  51853. timeToSelect?: number;
  51854. /**
  51855. * Should meshes created here be added to a utility layer or the main scene
  51856. */
  51857. useUtilityLayer?: boolean;
  51858. /**
  51859. * Optional WebXR camera to be used for gaze selection
  51860. */
  51861. gazeCamera?: WebXRCamera;
  51862. /**
  51863. * the xr input to use with this pointer selection
  51864. */
  51865. xrInput: WebXRInput;
  51866. }
  51867. /**
  51868. * A module that will enable pointer selection for motion controllers of XR Input Sources
  51869. */
  51870. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  51871. private readonly _options;
  51872. private static _idCounter;
  51873. private _attachController;
  51874. private _controllers;
  51875. private _scene;
  51876. private _tmpVectorForPickCompare;
  51877. /**
  51878. * The module's name
  51879. */
  51880. static readonly Name: string;
  51881. /**
  51882. * The (Babylon) version of this module.
  51883. * This is an integer representing the implementation version.
  51884. * This number does not correspond to the WebXR specs version
  51885. */
  51886. static readonly Version: number;
  51887. /**
  51888. * Disable lighting on the laser pointer (so it will always be visible)
  51889. */
  51890. disablePointerLighting: boolean;
  51891. /**
  51892. * Disable lighting on the selection mesh (so it will always be visible)
  51893. */
  51894. disableSelectionMeshLighting: boolean;
  51895. /**
  51896. * Should the laser pointer be displayed
  51897. */
  51898. displayLaserPointer: boolean;
  51899. /**
  51900. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  51901. */
  51902. displaySelectionMesh: boolean;
  51903. /**
  51904. * This color will be set to the laser pointer when selection is triggered
  51905. */
  51906. laserPointerPickedColor: Color3;
  51907. /**
  51908. * Default color of the laser pointer
  51909. */
  51910. laserPointerDefaultColor: Color3;
  51911. /**
  51912. * default color of the selection ring
  51913. */
  51914. selectionMeshDefaultColor: Color3;
  51915. /**
  51916. * This color will be applied to the selection ring when selection is triggered
  51917. */
  51918. selectionMeshPickedColor: Color3;
  51919. /**
  51920. * Optional filter to be used for ray selection. This predicate shares behavior with
  51921. * scene.pointerMovePredicate which takes priority if it is also assigned.
  51922. */
  51923. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  51924. /**
  51925. * constructs a new background remover module
  51926. * @param _xrSessionManager the session manager for this module
  51927. * @param _options read-only options to be used in this module
  51928. */
  51929. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  51930. /**
  51931. * attach this feature
  51932. * Will usually be called by the features manager
  51933. *
  51934. * @returns true if successful.
  51935. */
  51936. attach(): boolean;
  51937. /**
  51938. * detach this feature.
  51939. * Will usually be called by the features manager
  51940. *
  51941. * @returns true if successful.
  51942. */
  51943. detach(): boolean;
  51944. /**
  51945. * Will get the mesh under a specific pointer.
  51946. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  51947. * @param controllerId the controllerId to check
  51948. * @returns The mesh under pointer or null if no mesh is under the pointer
  51949. */
  51950. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  51951. /**
  51952. * Get the xr controller that correlates to the pointer id in the pointer event
  51953. *
  51954. * @param id the pointer id to search for
  51955. * @returns the controller that correlates to this id or null if not found
  51956. */
  51957. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  51958. protected _onXRFrame(_xrFrame: XRFrame): void;
  51959. private _attachGazeMode;
  51960. private _attachScreenRayMode;
  51961. private _attachTrackedPointerRayMode;
  51962. private _convertNormalToDirectionOfRay;
  51963. private _detachController;
  51964. private _generateNewMeshPair;
  51965. private _pickingMoved;
  51966. private _updatePointerDistance;
  51967. /** @hidden */
  51968. get lasterPointerDefaultColor(): Color3;
  51969. }
  51970. }
  51971. declare module BABYLON {
  51972. /**
  51973. * Button which can be used to enter a different mode of XR
  51974. */
  51975. export class WebXREnterExitUIButton {
  51976. /** button element */
  51977. element: HTMLElement;
  51978. /** XR initialization options for the button */
  51979. sessionMode: XRSessionMode;
  51980. /** Reference space type */
  51981. referenceSpaceType: XRReferenceSpaceType;
  51982. /**
  51983. * Creates a WebXREnterExitUIButton
  51984. * @param element button element
  51985. * @param sessionMode XR initialization session mode
  51986. * @param referenceSpaceType the type of reference space to be used
  51987. */
  51988. constructor(
  51989. /** button element */
  51990. element: HTMLElement,
  51991. /** XR initialization options for the button */
  51992. sessionMode: XRSessionMode,
  51993. /** Reference space type */
  51994. referenceSpaceType: XRReferenceSpaceType);
  51995. /**
  51996. * Extendable function which can be used to update the button's visuals when the state changes
  51997. * @param activeButton the current active button in the UI
  51998. */
  51999. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  52000. }
  52001. /**
  52002. * Options to create the webXR UI
  52003. */
  52004. export class WebXREnterExitUIOptions {
  52005. /**
  52006. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  52007. */
  52008. customButtons?: Array<WebXREnterExitUIButton>;
  52009. /**
  52010. * A reference space type to use when creating the default button.
  52011. * Default is local-floor
  52012. */
  52013. referenceSpaceType?: XRReferenceSpaceType;
  52014. /**
  52015. * Context to enter xr with
  52016. */
  52017. renderTarget?: Nullable<WebXRRenderTarget>;
  52018. /**
  52019. * A session mode to use when creating the default button.
  52020. * Default is immersive-vr
  52021. */
  52022. sessionMode?: XRSessionMode;
  52023. /**
  52024. * A list of optional features to init the session with
  52025. */
  52026. optionalFeatures?: string[];
  52027. /**
  52028. * A list of optional features to init the session with
  52029. */
  52030. requiredFeatures?: string[];
  52031. }
  52032. /**
  52033. * UI to allow the user to enter/exit XR mode
  52034. */
  52035. export class WebXREnterExitUI implements IDisposable {
  52036. private scene;
  52037. /** version of the options passed to this UI */
  52038. options: WebXREnterExitUIOptions;
  52039. private _activeButton;
  52040. private _buttons;
  52041. /**
  52042. * The HTML Div Element to which buttons are added.
  52043. */
  52044. readonly overlay: HTMLDivElement;
  52045. /**
  52046. * Fired every time the active button is changed.
  52047. *
  52048. * When xr is entered via a button that launches xr that button will be the callback parameter
  52049. *
  52050. * When exiting xr the callback parameter will be null)
  52051. */
  52052. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  52053. /**
  52054. *
  52055. * @param scene babylon scene object to use
  52056. * @param options (read-only) version of the options passed to this UI
  52057. */
  52058. private constructor();
  52059. /**
  52060. * Creates UI to allow the user to enter/exit XR mode
  52061. * @param scene the scene to add the ui to
  52062. * @param helper the xr experience helper to enter/exit xr with
  52063. * @param options options to configure the UI
  52064. * @returns the created ui
  52065. */
  52066. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  52067. /**
  52068. * Disposes of the XR UI component
  52069. */
  52070. dispose(): void;
  52071. private _updateButtons;
  52072. }
  52073. }
  52074. declare module BABYLON {
  52075. /**
  52076. * Class containing static functions to help procedurally build meshes
  52077. */
  52078. export class LinesBuilder {
  52079. /**
  52080. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  52081. * * 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
  52082. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  52083. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  52084. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  52085. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  52086. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  52087. * * 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
  52088. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  52089. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52090. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  52091. * @param name defines the name of the new line system
  52092. * @param options defines the options used to create the line system
  52093. * @param scene defines the hosting scene
  52094. * @returns a new line system mesh
  52095. */
  52096. static CreateLineSystem(name: string, options: {
  52097. lines: Vector3[][];
  52098. updatable?: boolean;
  52099. instance?: Nullable<LinesMesh>;
  52100. colors?: Nullable<Color4[][]>;
  52101. useVertexAlpha?: boolean;
  52102. }, scene: Nullable<Scene>): LinesMesh;
  52103. /**
  52104. * Creates a line mesh
  52105. * 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
  52106. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52107. * * The parameter `points` is an array successive Vector3
  52108. * * 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
  52109. * * The optional parameter `colors` is an array of successive Color4, one per line point
  52110. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  52111. * * When updating an instance, remember that only point positions can change, not the number of points
  52112. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52113. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  52114. * @param name defines the name of the new line system
  52115. * @param options defines the options used to create the line system
  52116. * @param scene defines the hosting scene
  52117. * @returns a new line mesh
  52118. */
  52119. static CreateLines(name: string, options: {
  52120. points: Vector3[];
  52121. updatable?: boolean;
  52122. instance?: Nullable<LinesMesh>;
  52123. colors?: Color4[];
  52124. useVertexAlpha?: boolean;
  52125. }, scene?: Nullable<Scene>): LinesMesh;
  52126. /**
  52127. * Creates a dashed line mesh
  52128. * * 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
  52129. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52130. * * The parameter `points` is an array successive Vector3
  52131. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  52132. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  52133. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  52134. * * 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
  52135. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  52136. * * When updating an instance, remember that only point positions can change, not the number of points
  52137. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52138. * @param name defines the name of the mesh
  52139. * @param options defines the options used to create the mesh
  52140. * @param scene defines the hosting scene
  52141. * @returns the dashed line mesh
  52142. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  52143. */
  52144. static CreateDashedLines(name: string, options: {
  52145. points: Vector3[];
  52146. dashSize?: number;
  52147. gapSize?: number;
  52148. dashNb?: number;
  52149. updatable?: boolean;
  52150. instance?: LinesMesh;
  52151. useVertexAlpha?: boolean;
  52152. }, scene?: Nullable<Scene>): LinesMesh;
  52153. }
  52154. }
  52155. declare module BABYLON {
  52156. /**
  52157. * Construction options for a timer
  52158. */
  52159. export interface ITimerOptions<T> {
  52160. /**
  52161. * Time-to-end
  52162. */
  52163. timeout: number;
  52164. /**
  52165. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  52166. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  52167. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  52168. */
  52169. contextObservable: Observable<T>;
  52170. /**
  52171. * Optional parameters when adding an observer to the observable
  52172. */
  52173. observableParameters?: {
  52174. mask?: number;
  52175. insertFirst?: boolean;
  52176. scope?: any;
  52177. };
  52178. /**
  52179. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  52180. */
  52181. breakCondition?: (data?: ITimerData<T>) => boolean;
  52182. /**
  52183. * Will be triggered when the time condition has met
  52184. */
  52185. onEnded?: (data: ITimerData<any>) => void;
  52186. /**
  52187. * Will be triggered when the break condition has met (prematurely ended)
  52188. */
  52189. onAborted?: (data: ITimerData<any>) => void;
  52190. /**
  52191. * Optional function to execute on each tick (or count)
  52192. */
  52193. onTick?: (data: ITimerData<any>) => void;
  52194. }
  52195. /**
  52196. * An interface defining the data sent by the timer
  52197. */
  52198. export interface ITimerData<T> {
  52199. /**
  52200. * When did it start
  52201. */
  52202. startTime: number;
  52203. /**
  52204. * Time now
  52205. */
  52206. currentTime: number;
  52207. /**
  52208. * Time passed since started
  52209. */
  52210. deltaTime: number;
  52211. /**
  52212. * How much is completed, in [0.0...1.0].
  52213. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  52214. */
  52215. completeRate: number;
  52216. /**
  52217. * What the registered observable sent in the last count
  52218. */
  52219. payload: T;
  52220. }
  52221. /**
  52222. * The current state of the timer
  52223. */
  52224. export enum TimerState {
  52225. /**
  52226. * Timer initialized, not yet started
  52227. */
  52228. INIT = 0,
  52229. /**
  52230. * Timer started and counting
  52231. */
  52232. STARTED = 1,
  52233. /**
  52234. * Timer ended (whether aborted or time reached)
  52235. */
  52236. ENDED = 2
  52237. }
  52238. /**
  52239. * A simple version of the timer. Will take options and start the timer immediately after calling it
  52240. *
  52241. * @param options options with which to initialize this timer
  52242. */
  52243. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  52244. /**
  52245. * An advanced implementation of a timer class
  52246. */
  52247. export class AdvancedTimer<T = any> implements IDisposable {
  52248. /**
  52249. * Will notify each time the timer calculates the remaining time
  52250. */
  52251. onEachCountObservable: Observable<ITimerData<T>>;
  52252. /**
  52253. * Will trigger when the timer was aborted due to the break condition
  52254. */
  52255. onTimerAbortedObservable: Observable<ITimerData<T>>;
  52256. /**
  52257. * Will trigger when the timer ended successfully
  52258. */
  52259. onTimerEndedObservable: Observable<ITimerData<T>>;
  52260. /**
  52261. * Will trigger when the timer state has changed
  52262. */
  52263. onStateChangedObservable: Observable<TimerState>;
  52264. private _observer;
  52265. private _contextObservable;
  52266. private _observableParameters;
  52267. private _startTime;
  52268. private _timer;
  52269. private _state;
  52270. private _breakCondition;
  52271. private _timeToEnd;
  52272. private _breakOnNextTick;
  52273. /**
  52274. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  52275. * @param options construction options for this advanced timer
  52276. */
  52277. constructor(options: ITimerOptions<T>);
  52278. /**
  52279. * set a breaking condition for this timer. Default is to never break during count
  52280. * @param predicate the new break condition. Returns true to break, false otherwise
  52281. */
  52282. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  52283. /**
  52284. * Reset ALL associated observables in this advanced timer
  52285. */
  52286. clearObservables(): void;
  52287. /**
  52288. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  52289. *
  52290. * @param timeToEnd how much time to measure until timer ended
  52291. */
  52292. start(timeToEnd?: number): void;
  52293. /**
  52294. * Will force a stop on the next tick.
  52295. */
  52296. stop(): void;
  52297. /**
  52298. * Dispose this timer, clearing all resources
  52299. */
  52300. dispose(): void;
  52301. private _setState;
  52302. private _tick;
  52303. private _stop;
  52304. }
  52305. }
  52306. declare module BABYLON {
  52307. /**
  52308. * The options container for the teleportation module
  52309. */
  52310. export interface IWebXRTeleportationOptions {
  52311. /**
  52312. * if provided, this scene will be used to render meshes.
  52313. */
  52314. customUtilityLayerScene?: Scene;
  52315. /**
  52316. * Values to configure the default target mesh
  52317. */
  52318. defaultTargetMeshOptions?: {
  52319. /**
  52320. * Fill color of the teleportation area
  52321. */
  52322. teleportationFillColor?: string;
  52323. /**
  52324. * Border color for the teleportation area
  52325. */
  52326. teleportationBorderColor?: string;
  52327. /**
  52328. * Disable the mesh's animation sequence
  52329. */
  52330. disableAnimation?: boolean;
  52331. /**
  52332. * Disable lighting on the material or the ring and arrow
  52333. */
  52334. disableLighting?: boolean;
  52335. /**
  52336. * Override the default material of the torus and arrow
  52337. */
  52338. torusArrowMaterial?: Material;
  52339. };
  52340. /**
  52341. * A list of meshes to use as floor meshes.
  52342. * Meshes can be added and removed after initializing the feature using the
  52343. * addFloorMesh and removeFloorMesh functions
  52344. * If empty, rotation will still work
  52345. */
  52346. floorMeshes?: AbstractMesh[];
  52347. /**
  52348. * use this rendering group id for the meshes (optional)
  52349. */
  52350. renderingGroupId?: number;
  52351. /**
  52352. * Should teleportation move only to snap points
  52353. */
  52354. snapPointsOnly?: boolean;
  52355. /**
  52356. * An array of points to which the teleportation will snap to.
  52357. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  52358. */
  52359. snapPositions?: Vector3[];
  52360. /**
  52361. * How close should the teleportation ray be in order to snap to position.
  52362. * Default to 0.8 units (meters)
  52363. */
  52364. snapToPositionRadius?: number;
  52365. /**
  52366. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  52367. * If you want to support rotation, make sure your mesh has a direction indicator.
  52368. *
  52369. * When left untouched, the default mesh will be initialized.
  52370. */
  52371. teleportationTargetMesh?: AbstractMesh;
  52372. /**
  52373. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  52374. */
  52375. timeToTeleport?: number;
  52376. /**
  52377. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  52378. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  52379. */
  52380. useMainComponentOnly?: boolean;
  52381. /**
  52382. * Should meshes created here be added to a utility layer or the main scene
  52383. */
  52384. useUtilityLayer?: boolean;
  52385. /**
  52386. * Babylon XR Input class for controller
  52387. */
  52388. xrInput: WebXRInput;
  52389. /**
  52390. * Meshes that the teleportation ray cannot go through
  52391. */
  52392. pickBlockerMeshes?: AbstractMesh[];
  52393. }
  52394. /**
  52395. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  52396. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  52397. * the input of the attached controllers.
  52398. */
  52399. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  52400. private _options;
  52401. private _controllers;
  52402. private _currentTeleportationControllerId;
  52403. private _floorMeshes;
  52404. private _quadraticBezierCurve;
  52405. private _selectionFeature;
  52406. private _snapToPositions;
  52407. private _snappedToPoint;
  52408. private _teleportationRingMaterial?;
  52409. private _tmpRay;
  52410. private _tmpVector;
  52411. private _tmpQuaternion;
  52412. /**
  52413. * The module's name
  52414. */
  52415. static readonly Name: string;
  52416. /**
  52417. * The (Babylon) version of this module.
  52418. * This is an integer representing the implementation version.
  52419. * This number does not correspond to the webxr specs version
  52420. */
  52421. static readonly Version: number;
  52422. /**
  52423. * Is movement backwards enabled
  52424. */
  52425. backwardsMovementEnabled: boolean;
  52426. /**
  52427. * Distance to travel when moving backwards
  52428. */
  52429. backwardsTeleportationDistance: number;
  52430. /**
  52431. * The distance from the user to the inspection point in the direction of the controller
  52432. * A higher number will allow the user to move further
  52433. * defaults to 5 (meters, in xr units)
  52434. */
  52435. parabolicCheckRadius: number;
  52436. /**
  52437. * Should the module support parabolic ray on top of direct ray
  52438. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  52439. * Very helpful when moving between floors / different heights
  52440. */
  52441. parabolicRayEnabled: boolean;
  52442. /**
  52443. * How much rotation should be applied when rotating right and left
  52444. */
  52445. rotationAngle: number;
  52446. /**
  52447. * Is rotation enabled when moving forward?
  52448. * Disabling this feature will prevent the user from deciding the direction when teleporting
  52449. */
  52450. rotationEnabled: boolean;
  52451. /**
  52452. * constructs a new anchor system
  52453. * @param _xrSessionManager an instance of WebXRSessionManager
  52454. * @param _options configuration object for this feature
  52455. */
  52456. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  52457. /**
  52458. * Get the snapPointsOnly flag
  52459. */
  52460. get snapPointsOnly(): boolean;
  52461. /**
  52462. * Sets the snapPointsOnly flag
  52463. * @param snapToPoints should teleportation be exclusively to snap points
  52464. */
  52465. set snapPointsOnly(snapToPoints: boolean);
  52466. /**
  52467. * Add a new mesh to the floor meshes array
  52468. * @param mesh the mesh to use as floor mesh
  52469. */
  52470. addFloorMesh(mesh: AbstractMesh): void;
  52471. /**
  52472. * Add a new snap-to point to fix teleportation to this position
  52473. * @param newSnapPoint The new Snap-To point
  52474. */
  52475. addSnapPoint(newSnapPoint: Vector3): void;
  52476. attach(): boolean;
  52477. detach(): boolean;
  52478. dispose(): void;
  52479. /**
  52480. * Remove a mesh from the floor meshes array
  52481. * @param mesh the mesh to remove
  52482. */
  52483. removeFloorMesh(mesh: AbstractMesh): void;
  52484. /**
  52485. * Remove a mesh from the floor meshes array using its name
  52486. * @param name the mesh name to remove
  52487. */
  52488. removeFloorMeshByName(name: string): void;
  52489. /**
  52490. * 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
  52491. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  52492. * @returns was the point found and removed or not
  52493. */
  52494. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  52495. /**
  52496. * This function sets a selection feature that will be disabled when
  52497. * the forward ray is shown and will be reattached when hidden.
  52498. * This is used to remove the selection rays when moving.
  52499. * @param selectionFeature the feature to disable when forward movement is enabled
  52500. */
  52501. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  52502. protected _onXRFrame(_xrFrame: XRFrame): void;
  52503. private _attachController;
  52504. private _createDefaultTargetMesh;
  52505. private _detachController;
  52506. private _findClosestSnapPointWithRadius;
  52507. private _setTargetMeshPosition;
  52508. private _setTargetMeshVisibility;
  52509. private _showParabolicPath;
  52510. private _teleportForward;
  52511. }
  52512. }
  52513. declare module BABYLON {
  52514. /**
  52515. * Options for the default xr helper
  52516. */
  52517. export class WebXRDefaultExperienceOptions {
  52518. /**
  52519. * Enable or disable default UI to enter XR
  52520. */
  52521. disableDefaultUI?: boolean;
  52522. /**
  52523. * Should teleportation not initialize. defaults to false.
  52524. */
  52525. disableTeleportation?: boolean;
  52526. /**
  52527. * Floor meshes that will be used for teleport
  52528. */
  52529. floorMeshes?: Array<AbstractMesh>;
  52530. /**
  52531. * If set to true, the first frame will not be used to reset position
  52532. * The first frame is mainly used when copying transformation from the old camera
  52533. * Mainly used in AR
  52534. */
  52535. ignoreNativeCameraTransformation?: boolean;
  52536. /**
  52537. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  52538. */
  52539. inputOptions?: IWebXRInputOptions;
  52540. /**
  52541. * optional configuration for the output canvas
  52542. */
  52543. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  52544. /**
  52545. * optional UI options. This can be used among other to change session mode and reference space type
  52546. */
  52547. uiOptions?: WebXREnterExitUIOptions;
  52548. /**
  52549. * When loading teleportation and pointer select, use stable versions instead of latest.
  52550. */
  52551. useStablePlugins?: boolean;
  52552. /**
  52553. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  52554. */
  52555. renderingGroupId?: number;
  52556. /**
  52557. * A list of optional features to init the session with
  52558. * If set to true, all features we support will be added
  52559. */
  52560. optionalFeatures?: boolean | string[];
  52561. }
  52562. /**
  52563. * Default experience which provides a similar setup to the previous webVRExperience
  52564. */
  52565. export class WebXRDefaultExperience {
  52566. /**
  52567. * Base experience
  52568. */
  52569. baseExperience: WebXRExperienceHelper;
  52570. /**
  52571. * Enables ui for entering/exiting xr
  52572. */
  52573. enterExitUI: WebXREnterExitUI;
  52574. /**
  52575. * Input experience extension
  52576. */
  52577. input: WebXRInput;
  52578. /**
  52579. * Enables laser pointer and selection
  52580. */
  52581. pointerSelection: WebXRControllerPointerSelection;
  52582. /**
  52583. * Default target xr should render to
  52584. */
  52585. renderTarget: WebXRRenderTarget;
  52586. /**
  52587. * Enables teleportation
  52588. */
  52589. teleportation: WebXRMotionControllerTeleportation;
  52590. private constructor();
  52591. /**
  52592. * Creates the default xr experience
  52593. * @param scene scene
  52594. * @param options options for basic configuration
  52595. * @returns resulting WebXRDefaultExperience
  52596. */
  52597. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  52598. /**
  52599. * DIsposes of the experience helper
  52600. */
  52601. dispose(): void;
  52602. }
  52603. }
  52604. declare module BABYLON {
  52605. /**
  52606. * Options to modify the vr teleportation behavior.
  52607. */
  52608. export interface VRTeleportationOptions {
  52609. /**
  52610. * The name of the mesh which should be used as the teleportation floor. (default: null)
  52611. */
  52612. floorMeshName?: string;
  52613. /**
  52614. * A list of meshes to be used as the teleportation floor. (default: empty)
  52615. */
  52616. floorMeshes?: Mesh[];
  52617. /**
  52618. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  52619. */
  52620. teleportationMode?: number;
  52621. /**
  52622. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  52623. */
  52624. teleportationTime?: number;
  52625. /**
  52626. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  52627. */
  52628. teleportationSpeed?: number;
  52629. /**
  52630. * The easing function used in the animation or null for Linear. (default CircleEase)
  52631. */
  52632. easingFunction?: EasingFunction;
  52633. }
  52634. /**
  52635. * Options to modify the vr experience helper's behavior.
  52636. */
  52637. export interface VRExperienceHelperOptions extends WebVROptions {
  52638. /**
  52639. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  52640. */
  52641. createDeviceOrientationCamera?: boolean;
  52642. /**
  52643. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  52644. */
  52645. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  52646. /**
  52647. * Uses the main button on the controller to toggle the laser casted. (default: true)
  52648. */
  52649. laserToggle?: boolean;
  52650. /**
  52651. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  52652. */
  52653. floorMeshes?: Mesh[];
  52654. /**
  52655. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  52656. */
  52657. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  52658. /**
  52659. * Defines if WebXR should be used instead of WebVR (if available)
  52660. */
  52661. useXR?: boolean;
  52662. }
  52663. /**
  52664. * Event containing information after VR has been entered
  52665. */
  52666. export class OnAfterEnteringVRObservableEvent {
  52667. /**
  52668. * If entering vr was successful
  52669. */
  52670. success: boolean;
  52671. }
  52672. /**
  52673. * Helps to quickly add VR support to an existing scene.
  52674. * See https://doc.babylonjs.com/how_to/webvr_helper
  52675. */
  52676. export class VRExperienceHelper {
  52677. /** Options to modify the vr experience helper's behavior. */
  52678. webVROptions: VRExperienceHelperOptions;
  52679. private _scene;
  52680. private _position;
  52681. private _btnVR;
  52682. private _btnVRDisplayed;
  52683. private _webVRsupported;
  52684. private _webVRready;
  52685. private _webVRrequesting;
  52686. private _webVRpresenting;
  52687. private _hasEnteredVR;
  52688. private _fullscreenVRpresenting;
  52689. private _inputElement;
  52690. private _webVRCamera;
  52691. private _vrDeviceOrientationCamera;
  52692. private _deviceOrientationCamera;
  52693. private _existingCamera;
  52694. private _onKeyDown;
  52695. private _onVrDisplayPresentChange;
  52696. private _onVRDisplayChanged;
  52697. private _onVRRequestPresentStart;
  52698. private _onVRRequestPresentComplete;
  52699. /**
  52700. * 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)
  52701. */
  52702. enableGazeEvenWhenNoPointerLock: boolean;
  52703. /**
  52704. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  52705. */
  52706. exitVROnDoubleTap: boolean;
  52707. /**
  52708. * Observable raised right before entering VR.
  52709. */
  52710. onEnteringVRObservable: Observable<VRExperienceHelper>;
  52711. /**
  52712. * Observable raised when entering VR has completed.
  52713. */
  52714. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  52715. /**
  52716. * Observable raised when exiting VR.
  52717. */
  52718. onExitingVRObservable: Observable<VRExperienceHelper>;
  52719. /**
  52720. * Observable raised when controller mesh is loaded.
  52721. */
  52722. onControllerMeshLoadedObservable: Observable<WebVRController>;
  52723. /** Return this.onEnteringVRObservable
  52724. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  52725. */
  52726. get onEnteringVR(): Observable<VRExperienceHelper>;
  52727. /** Return this.onExitingVRObservable
  52728. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  52729. */
  52730. get onExitingVR(): Observable<VRExperienceHelper>;
  52731. /** Return this.onControllerMeshLoadedObservable
  52732. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  52733. */
  52734. get onControllerMeshLoaded(): Observable<WebVRController>;
  52735. private _rayLength;
  52736. private _useCustomVRButton;
  52737. private _teleportationRequested;
  52738. private _teleportActive;
  52739. private _floorMeshName;
  52740. private _floorMeshesCollection;
  52741. private _teleportationMode;
  52742. private _teleportationTime;
  52743. private _teleportationSpeed;
  52744. private _teleportationEasing;
  52745. private _rotationAllowed;
  52746. private _teleportBackwardsVector;
  52747. private _teleportationTarget;
  52748. private _isDefaultTeleportationTarget;
  52749. private _postProcessMove;
  52750. private _teleportationFillColor;
  52751. private _teleportationBorderColor;
  52752. private _rotationAngle;
  52753. private _haloCenter;
  52754. private _cameraGazer;
  52755. private _padSensibilityUp;
  52756. private _padSensibilityDown;
  52757. private _leftController;
  52758. private _rightController;
  52759. private _gazeColor;
  52760. private _laserColor;
  52761. private _pickedLaserColor;
  52762. private _pickedGazeColor;
  52763. /**
  52764. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  52765. */
  52766. onNewMeshSelected: Observable<AbstractMesh>;
  52767. /**
  52768. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  52769. * This observable will provide the mesh and the controller used to select the mesh
  52770. */
  52771. onMeshSelectedWithController: Observable<{
  52772. mesh: AbstractMesh;
  52773. controller: WebVRController;
  52774. }>;
  52775. /**
  52776. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  52777. */
  52778. onNewMeshPicked: Observable<PickingInfo>;
  52779. private _circleEase;
  52780. /**
  52781. * Observable raised before camera teleportation
  52782. */
  52783. onBeforeCameraTeleport: Observable<Vector3>;
  52784. /**
  52785. * Observable raised after camera teleportation
  52786. */
  52787. onAfterCameraTeleport: Observable<Vector3>;
  52788. /**
  52789. * Observable raised when current selected mesh gets unselected
  52790. */
  52791. onSelectedMeshUnselected: Observable<AbstractMesh>;
  52792. private _raySelectionPredicate;
  52793. /**
  52794. * To be optionaly changed by user to define custom ray selection
  52795. */
  52796. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  52797. /**
  52798. * To be optionaly changed by user to define custom selection logic (after ray selection)
  52799. */
  52800. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  52801. /**
  52802. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  52803. */
  52804. teleportationEnabled: boolean;
  52805. private _defaultHeight;
  52806. private _teleportationInitialized;
  52807. private _interactionsEnabled;
  52808. private _interactionsRequested;
  52809. private _displayGaze;
  52810. private _displayLaserPointer;
  52811. /**
  52812. * The mesh used to display where the user is going to teleport.
  52813. */
  52814. get teleportationTarget(): Mesh;
  52815. /**
  52816. * Sets the mesh to be used to display where the user is going to teleport.
  52817. */
  52818. set teleportationTarget(value: Mesh);
  52819. /**
  52820. * 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
  52821. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  52822. * See https://doc.babylonjs.com/resources/baking_transformations
  52823. */
  52824. get gazeTrackerMesh(): Mesh;
  52825. set gazeTrackerMesh(value: Mesh);
  52826. /**
  52827. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  52828. */
  52829. updateGazeTrackerScale: boolean;
  52830. /**
  52831. * If the gaze trackers color should be updated when selecting meshes
  52832. */
  52833. updateGazeTrackerColor: boolean;
  52834. /**
  52835. * If the controller laser color should be updated when selecting meshes
  52836. */
  52837. updateControllerLaserColor: boolean;
  52838. /**
  52839. * The gaze tracking mesh corresponding to the left controller
  52840. */
  52841. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  52842. /**
  52843. * The gaze tracking mesh corresponding to the right controller
  52844. */
  52845. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  52846. /**
  52847. * If the ray of the gaze should be displayed.
  52848. */
  52849. get displayGaze(): boolean;
  52850. /**
  52851. * Sets if the ray of the gaze should be displayed.
  52852. */
  52853. set displayGaze(value: boolean);
  52854. /**
  52855. * If the ray of the LaserPointer should be displayed.
  52856. */
  52857. get displayLaserPointer(): boolean;
  52858. /**
  52859. * Sets if the ray of the LaserPointer should be displayed.
  52860. */
  52861. set displayLaserPointer(value: boolean);
  52862. /**
  52863. * The deviceOrientationCamera used as the camera when not in VR.
  52864. */
  52865. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  52866. /**
  52867. * Based on the current WebVR support, returns the current VR camera used.
  52868. */
  52869. get currentVRCamera(): Nullable<Camera>;
  52870. /**
  52871. * The webVRCamera which is used when in VR.
  52872. */
  52873. get webVRCamera(): WebVRFreeCamera;
  52874. /**
  52875. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  52876. */
  52877. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  52878. /**
  52879. * The html button that is used to trigger entering into VR.
  52880. */
  52881. get vrButton(): Nullable<HTMLButtonElement>;
  52882. private get _teleportationRequestInitiated();
  52883. /**
  52884. * Defines whether or not Pointer lock should be requested when switching to
  52885. * full screen.
  52886. */
  52887. requestPointerLockOnFullScreen: boolean;
  52888. /**
  52889. * If asking to force XR, this will be populated with the default xr experience
  52890. */
  52891. xr: WebXRDefaultExperience;
  52892. /**
  52893. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  52894. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  52895. */
  52896. xrTestDone: boolean;
  52897. /**
  52898. * Instantiates a VRExperienceHelper.
  52899. * Helps to quickly add VR support to an existing scene.
  52900. * @param scene The scene the VRExperienceHelper belongs to.
  52901. * @param webVROptions Options to modify the vr experience helper's behavior.
  52902. */
  52903. constructor(scene: Scene,
  52904. /** Options to modify the vr experience helper's behavior. */
  52905. webVROptions?: VRExperienceHelperOptions);
  52906. private completeVRInit;
  52907. private _onDefaultMeshLoaded;
  52908. private _onResize;
  52909. private _onFullscreenChange;
  52910. /**
  52911. * Gets a value indicating if we are currently in VR mode.
  52912. */
  52913. get isInVRMode(): boolean;
  52914. private onVrDisplayPresentChange;
  52915. private onVRDisplayChanged;
  52916. private moveButtonToBottomRight;
  52917. private displayVRButton;
  52918. private updateButtonVisibility;
  52919. private _cachedAngularSensibility;
  52920. /**
  52921. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  52922. * Otherwise, will use the fullscreen API.
  52923. */
  52924. enterVR(): void;
  52925. /**
  52926. * Attempt to exit VR, or fullscreen.
  52927. */
  52928. exitVR(): void;
  52929. /**
  52930. * The position of the vr experience helper.
  52931. */
  52932. get position(): Vector3;
  52933. /**
  52934. * Sets the position of the vr experience helper.
  52935. */
  52936. set position(value: Vector3);
  52937. /**
  52938. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  52939. */
  52940. enableInteractions(): void;
  52941. private get _noControllerIsActive();
  52942. private beforeRender;
  52943. private _isTeleportationFloor;
  52944. /**
  52945. * Adds a floor mesh to be used for teleportation.
  52946. * @param floorMesh the mesh to be used for teleportation.
  52947. */
  52948. addFloorMesh(floorMesh: Mesh): void;
  52949. /**
  52950. * Removes a floor mesh from being used for teleportation.
  52951. * @param floorMesh the mesh to be removed.
  52952. */
  52953. removeFloorMesh(floorMesh: Mesh): void;
  52954. /**
  52955. * Enables interactions and teleportation using the VR controllers and gaze.
  52956. * @param vrTeleportationOptions options to modify teleportation behavior.
  52957. */
  52958. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  52959. private _onNewGamepadConnected;
  52960. private _tryEnableInteractionOnController;
  52961. private _onNewGamepadDisconnected;
  52962. private _enableInteractionOnController;
  52963. private _checkTeleportWithRay;
  52964. private _checkRotate;
  52965. private _checkTeleportBackwards;
  52966. private _enableTeleportationOnController;
  52967. private _createTeleportationCircles;
  52968. private _displayTeleportationTarget;
  52969. private _hideTeleportationTarget;
  52970. private _rotateCamera;
  52971. private _moveTeleportationSelectorTo;
  52972. private _workingVector;
  52973. private _workingQuaternion;
  52974. private _workingMatrix;
  52975. /**
  52976. * Time Constant Teleportation Mode
  52977. */
  52978. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  52979. /**
  52980. * Speed Constant Teleportation Mode
  52981. */
  52982. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  52983. /**
  52984. * Teleports the users feet to the desired location
  52985. * @param location The location where the user's feet should be placed
  52986. */
  52987. teleportCamera(location: Vector3): void;
  52988. private _convertNormalToDirectionOfRay;
  52989. private _castRayAndSelectObject;
  52990. private _notifySelectedMeshUnselected;
  52991. /**
  52992. * Permanently set new colors for the laser pointer
  52993. * @param color the new laser color
  52994. * @param pickedColor the new laser color when picked mesh detected
  52995. */
  52996. setLaserColor(color: Color3, pickedColor?: Color3): void;
  52997. /**
  52998. * Set lighting enabled / disabled on the laser pointer of both controllers
  52999. * @param enabled should the lighting be enabled on the laser pointer
  53000. */
  53001. setLaserLightingState(enabled?: boolean): void;
  53002. /**
  53003. * Permanently set new colors for the gaze pointer
  53004. * @param color the new gaze color
  53005. * @param pickedColor the new gaze color when picked mesh detected
  53006. */
  53007. setGazeColor(color: Color3, pickedColor?: Color3): void;
  53008. /**
  53009. * Sets the color of the laser ray from the vr controllers.
  53010. * @param color new color for the ray.
  53011. */
  53012. changeLaserColor(color: Color3): void;
  53013. /**
  53014. * Sets the color of the ray from the vr headsets gaze.
  53015. * @param color new color for the ray.
  53016. */
  53017. changeGazeColor(color: Color3): void;
  53018. /**
  53019. * Exits VR and disposes of the vr experience helper
  53020. */
  53021. dispose(): void;
  53022. /**
  53023. * Gets the name of the VRExperienceHelper class
  53024. * @returns "VRExperienceHelper"
  53025. */
  53026. getClassName(): string;
  53027. }
  53028. }
  53029. declare module BABYLON {
  53030. /**
  53031. * Contains an array of blocks representing the octree
  53032. */
  53033. export interface IOctreeContainer<T> {
  53034. /**
  53035. * Blocks within the octree
  53036. */
  53037. blocks: Array<OctreeBlock<T>>;
  53038. }
  53039. /**
  53040. * Class used to store a cell in an octree
  53041. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53042. */
  53043. export class OctreeBlock<T> {
  53044. /**
  53045. * Gets the content of the current block
  53046. */
  53047. entries: T[];
  53048. /**
  53049. * Gets the list of block children
  53050. */
  53051. blocks: Array<OctreeBlock<T>>;
  53052. private _depth;
  53053. private _maxDepth;
  53054. private _capacity;
  53055. private _minPoint;
  53056. private _maxPoint;
  53057. private _boundingVectors;
  53058. private _creationFunc;
  53059. /**
  53060. * Creates a new block
  53061. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  53062. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  53063. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  53064. * @param depth defines the current depth of this block in the octree
  53065. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  53066. * @param creationFunc defines a callback to call when an element is added to the block
  53067. */
  53068. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  53069. /**
  53070. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  53071. */
  53072. get capacity(): number;
  53073. /**
  53074. * Gets the minimum vector (in world space) of the block's bounding box
  53075. */
  53076. get minPoint(): Vector3;
  53077. /**
  53078. * Gets the maximum vector (in world space) of the block's bounding box
  53079. */
  53080. get maxPoint(): Vector3;
  53081. /**
  53082. * Add a new element to this block
  53083. * @param entry defines the element to add
  53084. */
  53085. addEntry(entry: T): void;
  53086. /**
  53087. * Remove an element from this block
  53088. * @param entry defines the element to remove
  53089. */
  53090. removeEntry(entry: T): void;
  53091. /**
  53092. * Add an array of elements to this block
  53093. * @param entries defines the array of elements to add
  53094. */
  53095. addEntries(entries: T[]): void;
  53096. /**
  53097. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  53098. * @param frustumPlanes defines the frustum planes to test
  53099. * @param selection defines the array to store current content if selection is positive
  53100. * @param allowDuplicate defines if the selection array can contains duplicated entries
  53101. */
  53102. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  53103. /**
  53104. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  53105. * @param sphereCenter defines the bounding sphere center
  53106. * @param sphereRadius defines the bounding sphere radius
  53107. * @param selection defines the array to store current content if selection is positive
  53108. * @param allowDuplicate defines if the selection array can contains duplicated entries
  53109. */
  53110. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  53111. /**
  53112. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  53113. * @param ray defines the ray to test with
  53114. * @param selection defines the array to store current content if selection is positive
  53115. */
  53116. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  53117. /**
  53118. * Subdivide the content into child blocks (this block will then be empty)
  53119. */
  53120. createInnerBlocks(): void;
  53121. /**
  53122. * @hidden
  53123. */
  53124. 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;
  53125. }
  53126. }
  53127. declare module BABYLON {
  53128. /**
  53129. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  53130. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53131. */
  53132. export class Octree<T> {
  53133. /** 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.) */
  53134. maxDepth: number;
  53135. /**
  53136. * Blocks within the octree containing objects
  53137. */
  53138. blocks: Array<OctreeBlock<T>>;
  53139. /**
  53140. * Content stored in the octree
  53141. */
  53142. dynamicContent: T[];
  53143. private _maxBlockCapacity;
  53144. private _selectionContent;
  53145. private _creationFunc;
  53146. /**
  53147. * Creates a octree
  53148. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53149. * @param creationFunc function to be used to instatiate the octree
  53150. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  53151. * @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.)
  53152. */
  53153. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  53154. /** 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.) */
  53155. maxDepth?: number);
  53156. /**
  53157. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  53158. * @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);
  53159. * @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);
  53160. * @param entries meshes to be added to the octree blocks
  53161. */
  53162. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  53163. /**
  53164. * Adds a mesh to the octree
  53165. * @param entry Mesh to add to the octree
  53166. */
  53167. addMesh(entry: T): void;
  53168. /**
  53169. * Remove an element from the octree
  53170. * @param entry defines the element to remove
  53171. */
  53172. removeMesh(entry: T): void;
  53173. /**
  53174. * Selects an array of meshes within the frustum
  53175. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  53176. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  53177. * @returns array of meshes within the frustum
  53178. */
  53179. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  53180. /**
  53181. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  53182. * @param sphereCenter defines the bounding sphere center
  53183. * @param sphereRadius defines the bounding sphere radius
  53184. * @param allowDuplicate defines if the selection array can contains duplicated entries
  53185. * @returns an array of objects that intersect the sphere
  53186. */
  53187. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  53188. /**
  53189. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  53190. * @param ray defines the ray to test with
  53191. * @returns array of intersected objects
  53192. */
  53193. intersectsRay(ray: Ray): SmartArray<T>;
  53194. /**
  53195. * Adds a mesh into the octree block if it intersects the block
  53196. */
  53197. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  53198. /**
  53199. * Adds a submesh into the octree block if it intersects the block
  53200. */
  53201. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  53202. }
  53203. }
  53204. declare module BABYLON {
  53205. interface Scene {
  53206. /**
  53207. * @hidden
  53208. * Backing Filed
  53209. */
  53210. _selectionOctree: Octree<AbstractMesh>;
  53211. /**
  53212. * Gets the octree used to boost mesh selection (picking)
  53213. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53214. */
  53215. selectionOctree: Octree<AbstractMesh>;
  53216. /**
  53217. * Creates or updates the octree used to boost selection (picking)
  53218. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53219. * @param maxCapacity defines the maximum capacity per leaf
  53220. * @param maxDepth defines the maximum depth of the octree
  53221. * @returns an octree of AbstractMesh
  53222. */
  53223. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  53224. }
  53225. interface AbstractMesh {
  53226. /**
  53227. * @hidden
  53228. * Backing Field
  53229. */
  53230. _submeshesOctree: Octree<SubMesh>;
  53231. /**
  53232. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  53233. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  53234. * @param maxCapacity defines the maximum size of each block (64 by default)
  53235. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  53236. * @returns the new octree
  53237. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  53238. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  53239. */
  53240. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  53241. }
  53242. /**
  53243. * Defines the octree scene component responsible to manage any octrees
  53244. * in a given scene.
  53245. */
  53246. export class OctreeSceneComponent {
  53247. /**
  53248. * The component name help to identify the component in the list of scene components.
  53249. */
  53250. readonly name: string;
  53251. /**
  53252. * The scene the component belongs to.
  53253. */
  53254. scene: Scene;
  53255. /**
  53256. * Indicates if the meshes have been checked to make sure they are isEnabled()
  53257. */
  53258. readonly checksIsEnabled: boolean;
  53259. /**
  53260. * Creates a new instance of the component for the given scene
  53261. * @param scene Defines the scene to register the component in
  53262. */
  53263. constructor(scene: Scene);
  53264. /**
  53265. * Registers the component in a given scene
  53266. */
  53267. register(): void;
  53268. /**
  53269. * Return the list of active meshes
  53270. * @returns the list of active meshes
  53271. */
  53272. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  53273. /**
  53274. * Return the list of active sub meshes
  53275. * @param mesh The mesh to get the candidates sub meshes from
  53276. * @returns the list of active sub meshes
  53277. */
  53278. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  53279. private _tempRay;
  53280. /**
  53281. * Return the list of sub meshes intersecting with a given local ray
  53282. * @param mesh defines the mesh to find the submesh for
  53283. * @param localRay defines the ray in local space
  53284. * @returns the list of intersecting sub meshes
  53285. */
  53286. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  53287. /**
  53288. * Return the list of sub meshes colliding with a collider
  53289. * @param mesh defines the mesh to find the submesh for
  53290. * @param collider defines the collider to evaluate the collision against
  53291. * @returns the list of colliding sub meshes
  53292. */
  53293. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  53294. /**
  53295. * Rebuilds the elements related to this component in case of
  53296. * context lost for instance.
  53297. */
  53298. rebuild(): void;
  53299. /**
  53300. * Disposes the component and the associated ressources.
  53301. */
  53302. dispose(): void;
  53303. }
  53304. }
  53305. declare module BABYLON {
  53306. /**
  53307. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  53308. */
  53309. export class Gizmo implements IDisposable {
  53310. /** The utility layer the gizmo will be added to */
  53311. gizmoLayer: UtilityLayerRenderer;
  53312. /**
  53313. * The root mesh of the gizmo
  53314. */
  53315. _rootMesh: Mesh;
  53316. private _attachedMesh;
  53317. private _attachedNode;
  53318. /**
  53319. * Ratio for the scale of the gizmo (Default: 1)
  53320. */
  53321. protected _scaleRatio: number;
  53322. /**
  53323. * boolean updated by pointermove when a gizmo mesh is hovered
  53324. */
  53325. protected _isHovered: boolean;
  53326. /**
  53327. * Ratio for the scale of the gizmo (Default: 1)
  53328. */
  53329. set scaleRatio(value: number);
  53330. get scaleRatio(): number;
  53331. /**
  53332. * True when the mouse pointer is hovered a gizmo mesh
  53333. */
  53334. get isHovered(): boolean;
  53335. /**
  53336. * If a custom mesh has been set (Default: false)
  53337. */
  53338. protected _customMeshSet: boolean;
  53339. /**
  53340. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  53341. * * When set, interactions will be enabled
  53342. */
  53343. get attachedMesh(): Nullable<AbstractMesh>;
  53344. set attachedMesh(value: Nullable<AbstractMesh>);
  53345. /**
  53346. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  53347. * * When set, interactions will be enabled
  53348. */
  53349. get attachedNode(): Nullable<Node>;
  53350. set attachedNode(value: Nullable<Node>);
  53351. /**
  53352. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  53353. * @param mesh The mesh to replace the default mesh of the gizmo
  53354. */
  53355. setCustomMesh(mesh: Mesh): void;
  53356. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  53357. /**
  53358. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  53359. */
  53360. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  53361. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  53362. /**
  53363. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  53364. */
  53365. updateGizmoPositionToMatchAttachedMesh: boolean;
  53366. /**
  53367. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  53368. */
  53369. updateScale: boolean;
  53370. protected _interactionsEnabled: boolean;
  53371. protected _attachedNodeChanged(value: Nullable<Node>): void;
  53372. private _beforeRenderObserver;
  53373. private _tempQuaternion;
  53374. private _tempVector;
  53375. private _tempVector2;
  53376. private _tempMatrix1;
  53377. private _tempMatrix2;
  53378. private _rightHandtoLeftHandMatrix;
  53379. /**
  53380. * Creates a gizmo
  53381. * @param gizmoLayer The utility layer the gizmo will be added to
  53382. */
  53383. constructor(
  53384. /** The utility layer the gizmo will be added to */
  53385. gizmoLayer?: UtilityLayerRenderer);
  53386. /**
  53387. * Updates the gizmo to match the attached mesh's position/rotation
  53388. */
  53389. protected _update(): void;
  53390. /**
  53391. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  53392. * @param value Node, TransformNode or mesh
  53393. */
  53394. protected _matrixChanged(): void;
  53395. /**
  53396. * Disposes of the gizmo
  53397. */
  53398. dispose(): void;
  53399. }
  53400. }
  53401. declare module BABYLON {
  53402. /**
  53403. * Single plane drag gizmo
  53404. */
  53405. export class PlaneDragGizmo extends Gizmo {
  53406. /**
  53407. * Drag behavior responsible for the gizmos dragging interactions
  53408. */
  53409. dragBehavior: PointerDragBehavior;
  53410. private _pointerObserver;
  53411. /**
  53412. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  53413. */
  53414. snapDistance: number;
  53415. /**
  53416. * Event that fires each time the gizmo snaps to a new location.
  53417. * * snapDistance is the the change in distance
  53418. */
  53419. onSnapObservable: Observable<{
  53420. snapDistance: number;
  53421. }>;
  53422. private _plane;
  53423. private _coloredMaterial;
  53424. private _hoverMaterial;
  53425. private _isEnabled;
  53426. private _parent;
  53427. /** @hidden */
  53428. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  53429. /** @hidden */
  53430. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  53431. /**
  53432. * Creates a PlaneDragGizmo
  53433. * @param gizmoLayer The utility layer the gizmo will be added to
  53434. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  53435. * @param color The color of the gizmo
  53436. */
  53437. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  53438. protected _attachedNodeChanged(value: Nullable<Node>): void;
  53439. /**
  53440. * If the gizmo is enabled
  53441. */
  53442. set isEnabled(value: boolean);
  53443. get isEnabled(): boolean;
  53444. /**
  53445. * Disposes of the gizmo
  53446. */
  53447. dispose(): void;
  53448. }
  53449. }
  53450. declare module BABYLON {
  53451. /**
  53452. * Gizmo that enables dragging a mesh along 3 axis
  53453. */
  53454. export class PositionGizmo extends Gizmo {
  53455. /**
  53456. * Internal gizmo used for interactions on the x axis
  53457. */
  53458. xGizmo: AxisDragGizmo;
  53459. /**
  53460. * Internal gizmo used for interactions on the y axis
  53461. */
  53462. yGizmo: AxisDragGizmo;
  53463. /**
  53464. * Internal gizmo used for interactions on the z axis
  53465. */
  53466. zGizmo: AxisDragGizmo;
  53467. /**
  53468. * Internal gizmo used for interactions on the yz plane
  53469. */
  53470. xPlaneGizmo: PlaneDragGizmo;
  53471. /**
  53472. * Internal gizmo used for interactions on the xz plane
  53473. */
  53474. yPlaneGizmo: PlaneDragGizmo;
  53475. /**
  53476. * Internal gizmo used for interactions on the xy plane
  53477. */
  53478. zPlaneGizmo: PlaneDragGizmo;
  53479. /**
  53480. * private variables
  53481. */
  53482. private _meshAttached;
  53483. private _nodeAttached;
  53484. private _snapDistance;
  53485. /** Fires an event when any of it's sub gizmos are dragged */
  53486. onDragStartObservable: Observable<unknown>;
  53487. /** Fires an event when any of it's sub gizmos are released from dragging */
  53488. onDragEndObservable: Observable<unknown>;
  53489. /**
  53490. * If set to true, planar drag is enabled
  53491. */
  53492. private _planarGizmoEnabled;
  53493. get attachedMesh(): Nullable<AbstractMesh>;
  53494. set attachedMesh(mesh: Nullable<AbstractMesh>);
  53495. get attachedNode(): Nullable<Node>;
  53496. set attachedNode(node: Nullable<Node>);
  53497. /**
  53498. * True when the mouse pointer is hovering a gizmo mesh
  53499. */
  53500. get isHovered(): boolean;
  53501. /**
  53502. * Creates a PositionGizmo
  53503. * @param gizmoLayer The utility layer the gizmo will be added to
  53504. @param thickness display gizmo axis thickness
  53505. */
  53506. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  53507. /**
  53508. * If the planar drag gizmo is enabled
  53509. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  53510. */
  53511. set planarGizmoEnabled(value: boolean);
  53512. get planarGizmoEnabled(): boolean;
  53513. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  53514. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  53515. /**
  53516. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  53517. */
  53518. set snapDistance(value: number);
  53519. get snapDistance(): number;
  53520. /**
  53521. * Ratio for the scale of the gizmo (Default: 1)
  53522. */
  53523. set scaleRatio(value: number);
  53524. get scaleRatio(): number;
  53525. /**
  53526. * Disposes of the gizmo
  53527. */
  53528. dispose(): void;
  53529. /**
  53530. * CustomMeshes are not supported by this gizmo
  53531. * @param mesh The mesh to replace the default mesh of the gizmo
  53532. */
  53533. setCustomMesh(mesh: Mesh): void;
  53534. }
  53535. }
  53536. declare module BABYLON {
  53537. /**
  53538. * Single axis drag gizmo
  53539. */
  53540. export class AxisDragGizmo extends Gizmo {
  53541. /**
  53542. * Drag behavior responsible for the gizmos dragging interactions
  53543. */
  53544. dragBehavior: PointerDragBehavior;
  53545. private _pointerObserver;
  53546. /**
  53547. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  53548. */
  53549. snapDistance: number;
  53550. /**
  53551. * Event that fires each time the gizmo snaps to a new location.
  53552. * * snapDistance is the the change in distance
  53553. */
  53554. onSnapObservable: Observable<{
  53555. snapDistance: number;
  53556. }>;
  53557. private _isEnabled;
  53558. private _parent;
  53559. private _arrow;
  53560. private _coloredMaterial;
  53561. private _hoverMaterial;
  53562. /** @hidden */
  53563. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  53564. /** @hidden */
  53565. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  53566. /**
  53567. * Creates an AxisDragGizmo
  53568. * @param gizmoLayer The utility layer the gizmo will be added to
  53569. * @param dragAxis The axis which the gizmo will be able to drag on
  53570. * @param color The color of the gizmo
  53571. * @param thickness display gizmo axis thickness
  53572. */
  53573. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  53574. protected _attachedNodeChanged(value: Nullable<Node>): void;
  53575. /**
  53576. * If the gizmo is enabled
  53577. */
  53578. set isEnabled(value: boolean);
  53579. get isEnabled(): boolean;
  53580. /**
  53581. * Disposes of the gizmo
  53582. */
  53583. dispose(): void;
  53584. }
  53585. }
  53586. declare module BABYLON.Debug {
  53587. /**
  53588. * The Axes viewer will show 3 axes in a specific point in space
  53589. */
  53590. export class AxesViewer {
  53591. private _xAxis;
  53592. private _yAxis;
  53593. private _zAxis;
  53594. private _scaleLinesFactor;
  53595. private _instanced;
  53596. /**
  53597. * Gets the hosting scene
  53598. */
  53599. scene: Nullable<Scene>;
  53600. /**
  53601. * Gets or sets a number used to scale line length
  53602. */
  53603. scaleLines: number;
  53604. /** Gets the node hierarchy used to render x-axis */
  53605. get xAxis(): TransformNode;
  53606. /** Gets the node hierarchy used to render y-axis */
  53607. get yAxis(): TransformNode;
  53608. /** Gets the node hierarchy used to render z-axis */
  53609. get zAxis(): TransformNode;
  53610. /**
  53611. * Creates a new AxesViewer
  53612. * @param scene defines the hosting scene
  53613. * @param scaleLines defines a number used to scale line length (1 by default)
  53614. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  53615. * @param xAxis defines the node hierarchy used to render the x-axis
  53616. * @param yAxis defines the node hierarchy used to render the y-axis
  53617. * @param zAxis defines the node hierarchy used to render the z-axis
  53618. */
  53619. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  53620. /**
  53621. * Force the viewer to update
  53622. * @param position defines the position of the viewer
  53623. * @param xaxis defines the x axis of the viewer
  53624. * @param yaxis defines the y axis of the viewer
  53625. * @param zaxis defines the z axis of the viewer
  53626. */
  53627. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  53628. /**
  53629. * Creates an instance of this axes viewer.
  53630. * @returns a new axes viewer with instanced meshes
  53631. */
  53632. createInstance(): AxesViewer;
  53633. /** Releases resources */
  53634. dispose(): void;
  53635. private static _SetRenderingGroupId;
  53636. }
  53637. }
  53638. declare module BABYLON.Debug {
  53639. /**
  53640. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  53641. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  53642. */
  53643. export class BoneAxesViewer extends AxesViewer {
  53644. /**
  53645. * Gets or sets the target mesh where to display the axes viewer
  53646. */
  53647. mesh: Nullable<Mesh>;
  53648. /**
  53649. * Gets or sets the target bone where to display the axes viewer
  53650. */
  53651. bone: Nullable<Bone>;
  53652. /** Gets current position */
  53653. pos: Vector3;
  53654. /** Gets direction of X axis */
  53655. xaxis: Vector3;
  53656. /** Gets direction of Y axis */
  53657. yaxis: Vector3;
  53658. /** Gets direction of Z axis */
  53659. zaxis: Vector3;
  53660. /**
  53661. * Creates a new BoneAxesViewer
  53662. * @param scene defines the hosting scene
  53663. * @param bone defines the target bone
  53664. * @param mesh defines the target mesh
  53665. * @param scaleLines defines a scaling factor for line length (1 by default)
  53666. */
  53667. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  53668. /**
  53669. * Force the viewer to update
  53670. */
  53671. update(): void;
  53672. /** Releases resources */
  53673. dispose(): void;
  53674. }
  53675. }
  53676. declare module BABYLON {
  53677. /**
  53678. * Interface used to define scene explorer extensibility option
  53679. */
  53680. export interface IExplorerExtensibilityOption {
  53681. /**
  53682. * Define the option label
  53683. */
  53684. label: string;
  53685. /**
  53686. * Defines the action to execute on click
  53687. */
  53688. action: (entity: any) => void;
  53689. }
  53690. /**
  53691. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  53692. */
  53693. export interface IExplorerExtensibilityGroup {
  53694. /**
  53695. * Defines a predicate to test if a given type mut be extended
  53696. */
  53697. predicate: (entity: any) => boolean;
  53698. /**
  53699. * Gets the list of options added to a type
  53700. */
  53701. entries: IExplorerExtensibilityOption[];
  53702. }
  53703. /**
  53704. * Interface used to define the options to use to create the Inspector
  53705. */
  53706. export interface IInspectorOptions {
  53707. /**
  53708. * Display in overlay mode (default: false)
  53709. */
  53710. overlay?: boolean;
  53711. /**
  53712. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  53713. */
  53714. globalRoot?: HTMLElement;
  53715. /**
  53716. * Display the Scene explorer
  53717. */
  53718. showExplorer?: boolean;
  53719. /**
  53720. * Display the property inspector
  53721. */
  53722. showInspector?: boolean;
  53723. /**
  53724. * Display in embed mode (both panes on the right)
  53725. */
  53726. embedMode?: boolean;
  53727. /**
  53728. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  53729. */
  53730. handleResize?: boolean;
  53731. /**
  53732. * Allow the panes to popup (default: true)
  53733. */
  53734. enablePopup?: boolean;
  53735. /**
  53736. * Allow the panes to be closed by users (default: true)
  53737. */
  53738. enableClose?: boolean;
  53739. /**
  53740. * Optional list of extensibility entries
  53741. */
  53742. explorerExtensibility?: IExplorerExtensibilityGroup[];
  53743. /**
  53744. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  53745. */
  53746. inspectorURL?: string;
  53747. /**
  53748. * Optional initial tab (default to DebugLayerTab.Properties)
  53749. */
  53750. initialTab?: DebugLayerTab;
  53751. }
  53752. interface Scene {
  53753. /**
  53754. * @hidden
  53755. * Backing field
  53756. */
  53757. _debugLayer: DebugLayer;
  53758. /**
  53759. * Gets the debug layer (aka Inspector) associated with the scene
  53760. * @see https://doc.babylonjs.com/features/playground_debuglayer
  53761. */
  53762. debugLayer: DebugLayer;
  53763. }
  53764. /**
  53765. * Enum of inspector action tab
  53766. */
  53767. export enum DebugLayerTab {
  53768. /**
  53769. * Properties tag (default)
  53770. */
  53771. Properties = 0,
  53772. /**
  53773. * Debug tab
  53774. */
  53775. Debug = 1,
  53776. /**
  53777. * Statistics tab
  53778. */
  53779. Statistics = 2,
  53780. /**
  53781. * Tools tab
  53782. */
  53783. Tools = 3,
  53784. /**
  53785. * Settings tab
  53786. */
  53787. Settings = 4
  53788. }
  53789. /**
  53790. * The debug layer (aka Inspector) is the go to tool in order to better understand
  53791. * what is happening in your scene
  53792. * @see https://doc.babylonjs.com/features/playground_debuglayer
  53793. */
  53794. export class DebugLayer {
  53795. /**
  53796. * Define the url to get the inspector script from.
  53797. * By default it uses the babylonjs CDN.
  53798. * @ignoreNaming
  53799. */
  53800. static InspectorURL: string;
  53801. private _scene;
  53802. private BJSINSPECTOR;
  53803. private _onPropertyChangedObservable?;
  53804. /**
  53805. * Observable triggered when a property is changed through the inspector.
  53806. */
  53807. get onPropertyChangedObservable(): any;
  53808. /**
  53809. * Instantiates a new debug layer.
  53810. * The debug layer (aka Inspector) is the go to tool in order to better understand
  53811. * what is happening in your scene
  53812. * @see https://doc.babylonjs.com/features/playground_debuglayer
  53813. * @param scene Defines the scene to inspect
  53814. */
  53815. constructor(scene: Scene);
  53816. /** Creates the inspector window. */
  53817. private _createInspector;
  53818. /**
  53819. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  53820. * @param entity defines the entity to select
  53821. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  53822. */
  53823. select(entity: any, lineContainerTitles?: string | string[]): void;
  53824. /** Get the inspector from bundle or global */
  53825. private _getGlobalInspector;
  53826. /**
  53827. * Get if the inspector is visible or not.
  53828. * @returns true if visible otherwise, false
  53829. */
  53830. isVisible(): boolean;
  53831. /**
  53832. * Hide the inspector and close its window.
  53833. */
  53834. hide(): void;
  53835. /**
  53836. * Update the scene in the inspector
  53837. */
  53838. setAsActiveScene(): void;
  53839. /**
  53840. * Launch the debugLayer.
  53841. * @param config Define the configuration of the inspector
  53842. * @return a promise fulfilled when the debug layer is visible
  53843. */
  53844. show(config?: IInspectorOptions): Promise<DebugLayer>;
  53845. }
  53846. }
  53847. declare module BABYLON {
  53848. /**
  53849. * Class containing static functions to help procedurally build meshes
  53850. */
  53851. export class BoxBuilder {
  53852. /**
  53853. * Creates a box mesh
  53854. * * The parameter `size` sets the size (float) of each box side (default 1)
  53855. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  53856. * * 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)
  53857. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  53858. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53859. * * 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
  53860. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53861. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  53862. * @param name defines the name of the mesh
  53863. * @param options defines the options used to create the mesh
  53864. * @param scene defines the hosting scene
  53865. * @returns the box mesh
  53866. */
  53867. static CreateBox(name: string, options: {
  53868. size?: number;
  53869. width?: number;
  53870. height?: number;
  53871. depth?: number;
  53872. faceUV?: Vector4[];
  53873. faceColors?: Color4[];
  53874. sideOrientation?: number;
  53875. frontUVs?: Vector4;
  53876. backUVs?: Vector4;
  53877. wrap?: boolean;
  53878. topBaseAt?: number;
  53879. bottomBaseAt?: number;
  53880. updatable?: boolean;
  53881. }, scene?: Nullable<Scene>): Mesh;
  53882. }
  53883. }
  53884. declare module BABYLON.Debug {
  53885. /**
  53886. * Used to show the physics impostor around the specific mesh
  53887. */
  53888. export class PhysicsViewer {
  53889. /** @hidden */
  53890. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  53891. /** @hidden */
  53892. protected _meshes: Array<Nullable<AbstractMesh>>;
  53893. /** @hidden */
  53894. protected _scene: Nullable<Scene>;
  53895. /** @hidden */
  53896. protected _numMeshes: number;
  53897. /** @hidden */
  53898. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  53899. private _renderFunction;
  53900. private _utilityLayer;
  53901. private _debugBoxMesh;
  53902. private _debugSphereMesh;
  53903. private _debugCylinderMesh;
  53904. private _debugMaterial;
  53905. private _debugMeshMeshes;
  53906. /**
  53907. * Creates a new PhysicsViewer
  53908. * @param scene defines the hosting scene
  53909. */
  53910. constructor(scene: Scene);
  53911. /** @hidden */
  53912. protected _updateDebugMeshes(): void;
  53913. /**
  53914. * Renders a specified physic impostor
  53915. * @param impostor defines the impostor to render
  53916. * @param targetMesh defines the mesh represented by the impostor
  53917. * @returns the new debug mesh used to render the impostor
  53918. */
  53919. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  53920. /**
  53921. * Hides a specified physic impostor
  53922. * @param impostor defines the impostor to hide
  53923. */
  53924. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  53925. private _getDebugMaterial;
  53926. private _getDebugBoxMesh;
  53927. private _getDebugSphereMesh;
  53928. private _getDebugCylinderMesh;
  53929. private _getDebugMeshMesh;
  53930. private _getDebugMesh;
  53931. /** Releases all resources */
  53932. dispose(): void;
  53933. }
  53934. }
  53935. declare module BABYLON {
  53936. /**
  53937. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  53938. * in order to better appreciate the issue one might have.
  53939. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  53940. */
  53941. export class RayHelper {
  53942. /**
  53943. * Defines the ray we are currently tryin to visualize.
  53944. */
  53945. ray: Nullable<Ray>;
  53946. private _renderPoints;
  53947. private _renderLine;
  53948. private _renderFunction;
  53949. private _scene;
  53950. private _onAfterRenderObserver;
  53951. private _onAfterStepObserver;
  53952. private _attachedToMesh;
  53953. private _meshSpaceDirection;
  53954. private _meshSpaceOrigin;
  53955. /**
  53956. * Helper function to create a colored helper in a scene in one line.
  53957. * @param ray Defines the ray we are currently tryin to visualize
  53958. * @param scene Defines the scene the ray is used in
  53959. * @param color Defines the color we want to see the ray in
  53960. * @returns The newly created ray helper.
  53961. */
  53962. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  53963. /**
  53964. * Instantiate a new ray helper.
  53965. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  53966. * in order to better appreciate the issue one might have.
  53967. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  53968. * @param ray Defines the ray we are currently tryin to visualize
  53969. */
  53970. constructor(ray: Ray);
  53971. /**
  53972. * Shows the ray we are willing to debug.
  53973. * @param scene Defines the scene the ray needs to be rendered in
  53974. * @param color Defines the color the ray needs to be rendered in
  53975. */
  53976. show(scene: Scene, color?: Color3): void;
  53977. /**
  53978. * Hides the ray we are debugging.
  53979. */
  53980. hide(): void;
  53981. private _render;
  53982. /**
  53983. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  53984. * @param mesh Defines the mesh we want the helper attached to
  53985. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  53986. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  53987. * @param length Defines the length of the ray
  53988. */
  53989. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  53990. /**
  53991. * Detach the ray helper from the mesh it has previously been attached to.
  53992. */
  53993. detachFromMesh(): void;
  53994. private _updateToMesh;
  53995. /**
  53996. * Dispose the helper and release its associated resources.
  53997. */
  53998. dispose(): void;
  53999. }
  54000. }
  54001. declare module BABYLON {
  54002. /**
  54003. * Defines the options associated with the creation of a SkeletonViewer.
  54004. */
  54005. export interface ISkeletonViewerOptions {
  54006. /** Should the system pause animations before building the Viewer? */
  54007. pauseAnimations: boolean;
  54008. /** Should the system return the skeleton to rest before building? */
  54009. returnToRest: boolean;
  54010. /** public Display Mode of the Viewer */
  54011. displayMode: number;
  54012. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  54013. displayOptions: ISkeletonViewerDisplayOptions;
  54014. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  54015. computeBonesUsingShaders: boolean;
  54016. /** Flag ignore non weighted bones */
  54017. useAllBones: boolean;
  54018. }
  54019. /**
  54020. * Defines how to display the various bone meshes for the viewer.
  54021. */
  54022. export interface ISkeletonViewerDisplayOptions {
  54023. /** How far down to start tapering the bone spurs */
  54024. midStep?: number;
  54025. /** How big is the midStep? */
  54026. midStepFactor?: number;
  54027. /** Base for the Sphere Size */
  54028. sphereBaseSize?: number;
  54029. /** The ratio of the sphere to the longest bone in units */
  54030. sphereScaleUnit?: number;
  54031. /** Ratio for the Sphere Size */
  54032. sphereFactor?: number;
  54033. /** Whether a spur should attach its far end to the child bone position */
  54034. spurFollowsChild?: boolean;
  54035. /** Whether to show local axes or not */
  54036. showLocalAxes?: boolean;
  54037. /** Length of each local axis */
  54038. localAxesSize?: number;
  54039. }
  54040. /**
  54041. * Defines the constructor options for the BoneWeight Shader.
  54042. */
  54043. export interface IBoneWeightShaderOptions {
  54044. /** Skeleton to Map */
  54045. skeleton: Skeleton;
  54046. /** Colors for Uninfluenced bones */
  54047. colorBase?: Color3;
  54048. /** Colors for 0.0-0.25 Weight bones */
  54049. colorZero?: Color3;
  54050. /** Color for 0.25-0.5 Weight Influence */
  54051. colorQuarter?: Color3;
  54052. /** Color for 0.5-0.75 Weight Influence */
  54053. colorHalf?: Color3;
  54054. /** Color for 0.75-1 Weight Influence */
  54055. colorFull?: Color3;
  54056. /** Color for Zero Weight Influence */
  54057. targetBoneIndex?: number;
  54058. }
  54059. /**
  54060. * Simple structure of the gradient steps for the Color Map.
  54061. */
  54062. export interface ISkeletonMapShaderColorMapKnot {
  54063. /** Color of the Knot */
  54064. color: Color3;
  54065. /** Location of the Knot */
  54066. location: number;
  54067. }
  54068. /**
  54069. * Defines the constructor options for the SkeletonMap Shader.
  54070. */
  54071. export interface ISkeletonMapShaderOptions {
  54072. /** Skeleton to Map */
  54073. skeleton: Skeleton;
  54074. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  54075. colorMap?: ISkeletonMapShaderColorMapKnot[];
  54076. }
  54077. }
  54078. declare module BABYLON {
  54079. /**
  54080. * Class containing static functions to help procedurally build meshes
  54081. */
  54082. export class RibbonBuilder {
  54083. /**
  54084. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  54085. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  54086. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  54087. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  54088. * * 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
  54089. * * 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
  54090. * * 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
  54091. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54092. * * 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
  54093. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54094. * * 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
  54095. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  54096. * * 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
  54097. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  54098. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54099. * @param name defines the name of the mesh
  54100. * @param options defines the options used to create the mesh
  54101. * @param scene defines the hosting scene
  54102. * @returns the ribbon mesh
  54103. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  54104. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54105. */
  54106. static CreateRibbon(name: string, options: {
  54107. pathArray: Vector3[][];
  54108. closeArray?: boolean;
  54109. closePath?: boolean;
  54110. offset?: number;
  54111. updatable?: boolean;
  54112. sideOrientation?: number;
  54113. frontUVs?: Vector4;
  54114. backUVs?: Vector4;
  54115. instance?: Mesh;
  54116. invertUV?: boolean;
  54117. uvs?: Vector2[];
  54118. colors?: Color4[];
  54119. }, scene?: Nullable<Scene>): Mesh;
  54120. }
  54121. }
  54122. declare module BABYLON {
  54123. /**
  54124. * Class containing static functions to help procedurally build meshes
  54125. */
  54126. export class ShapeBuilder {
  54127. /**
  54128. * 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.
  54129. * * 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.
  54130. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  54131. * * 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.
  54132. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  54133. * * 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
  54134. * * 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
  54135. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  54136. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54137. * * 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
  54138. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  54139. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54140. * @param name defines the name of the mesh
  54141. * @param options defines the options used to create the mesh
  54142. * @param scene defines the hosting scene
  54143. * @returns the extruded shape mesh
  54144. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54145. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  54146. */
  54147. static ExtrudeShape(name: string, options: {
  54148. shape: Vector3[];
  54149. path: Vector3[];
  54150. scale?: number;
  54151. rotation?: number;
  54152. cap?: number;
  54153. updatable?: boolean;
  54154. sideOrientation?: number;
  54155. frontUVs?: Vector4;
  54156. backUVs?: Vector4;
  54157. instance?: Mesh;
  54158. invertUV?: boolean;
  54159. }, scene?: Nullable<Scene>): Mesh;
  54160. /**
  54161. * Creates an custom extruded shape mesh.
  54162. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  54163. * * 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.
  54164. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  54165. * * 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
  54166. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  54167. * * 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
  54168. * * It must returns a float value that will be the scale value applied to the shape on each path point
  54169. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  54170. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  54171. * * 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
  54172. * * 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
  54173. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  54174. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54175. * * 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
  54176. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54177. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54178. * @param name defines the name of the mesh
  54179. * @param options defines the options used to create the mesh
  54180. * @param scene defines the hosting scene
  54181. * @returns the custom extruded shape mesh
  54182. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  54183. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54184. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  54185. */
  54186. static ExtrudeShapeCustom(name: string, options: {
  54187. shape: Vector3[];
  54188. path: Vector3[];
  54189. scaleFunction?: any;
  54190. rotationFunction?: any;
  54191. ribbonCloseArray?: boolean;
  54192. ribbonClosePath?: boolean;
  54193. cap?: number;
  54194. updatable?: boolean;
  54195. sideOrientation?: number;
  54196. frontUVs?: Vector4;
  54197. backUVs?: Vector4;
  54198. instance?: Mesh;
  54199. invertUV?: boolean;
  54200. }, scene?: Nullable<Scene>): Mesh;
  54201. private static _ExtrudeShapeGeneric;
  54202. }
  54203. }
  54204. declare module BABYLON.Debug {
  54205. /**
  54206. * Class used to render a debug view of a given skeleton
  54207. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  54208. */
  54209. export class SkeletonViewer {
  54210. /** defines the skeleton to render */
  54211. skeleton: Skeleton;
  54212. /** defines the mesh attached to the skeleton */
  54213. mesh: AbstractMesh;
  54214. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  54215. autoUpdateBonesMatrices: boolean;
  54216. /** defines the rendering group id to use with the viewer */
  54217. renderingGroupId: number;
  54218. /** is the options for the viewer */
  54219. options: Partial<ISkeletonViewerOptions>;
  54220. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  54221. static readonly DISPLAY_LINES: number;
  54222. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  54223. static readonly DISPLAY_SPHERES: number;
  54224. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  54225. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  54226. /** public static method to create a BoneWeight Shader
  54227. * @param options The constructor options
  54228. * @param scene The scene that the shader is scoped to
  54229. * @returns The created ShaderMaterial
  54230. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  54231. */
  54232. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  54233. /** public static method to create a BoneWeight Shader
  54234. * @param options The constructor options
  54235. * @param scene The scene that the shader is scoped to
  54236. * @returns The created ShaderMaterial
  54237. */
  54238. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  54239. /** private static method to create a BoneWeight Shader
  54240. * @param size The size of the buffer to create (usually the bone count)
  54241. * @param colorMap The gradient data to generate
  54242. * @param scene The scene that the shader is scoped to
  54243. * @returns an Array of floats from the color gradient values
  54244. */
  54245. private static _CreateBoneMapColorBuffer;
  54246. /** If SkeletonViewer scene scope. */
  54247. private _scene;
  54248. /** Gets or sets the color used to render the skeleton */
  54249. color: Color3;
  54250. /** Array of the points of the skeleton fo the line view. */
  54251. private _debugLines;
  54252. /** The SkeletonViewers Mesh. */
  54253. private _debugMesh;
  54254. /** The local axes Meshes. */
  54255. private _localAxes;
  54256. /** If SkeletonViewer is enabled. */
  54257. private _isEnabled;
  54258. /** If SkeletonViewer is ready. */
  54259. private _ready;
  54260. /** SkeletonViewer render observable. */
  54261. private _obs;
  54262. /** The Utility Layer to render the gizmos in. */
  54263. private _utilityLayer;
  54264. private _boneIndices;
  54265. /** Gets the Scene. */
  54266. get scene(): Scene;
  54267. /** Gets the utilityLayer. */
  54268. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  54269. /** Checks Ready Status. */
  54270. get isReady(): Boolean;
  54271. /** Sets Ready Status. */
  54272. set ready(value: boolean);
  54273. /** Gets the debugMesh */
  54274. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  54275. /** Sets the debugMesh */
  54276. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  54277. /** Gets the displayMode */
  54278. get displayMode(): number;
  54279. /** Sets the displayMode */
  54280. set displayMode(value: number);
  54281. /**
  54282. * Creates a new SkeletonViewer
  54283. * @param skeleton defines the skeleton to render
  54284. * @param mesh defines the mesh attached to the skeleton
  54285. * @param scene defines the hosting scene
  54286. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  54287. * @param renderingGroupId defines the rendering group id to use with the viewer
  54288. * @param options All of the extra constructor options for the SkeletonViewer
  54289. */
  54290. constructor(
  54291. /** defines the skeleton to render */
  54292. skeleton: Skeleton,
  54293. /** defines the mesh attached to the skeleton */
  54294. mesh: AbstractMesh,
  54295. /** The Scene scope*/
  54296. scene: Scene,
  54297. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  54298. autoUpdateBonesMatrices?: boolean,
  54299. /** defines the rendering group id to use with the viewer */
  54300. renderingGroupId?: number,
  54301. /** is the options for the viewer */
  54302. options?: Partial<ISkeletonViewerOptions>);
  54303. /** The Dynamic bindings for the update functions */
  54304. private _bindObs;
  54305. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  54306. update(): void;
  54307. /** Gets or sets a boolean indicating if the viewer is enabled */
  54308. set isEnabled(value: boolean);
  54309. get isEnabled(): boolean;
  54310. private _getBonePosition;
  54311. private _getLinesForBonesWithLength;
  54312. private _getLinesForBonesNoLength;
  54313. /** function to revert the mesh and scene back to the initial state. */
  54314. private _revert;
  54315. /** function to get the absolute bind pose of a bone by accumulating transformations up the bone hierarchy. */
  54316. private _getAbsoluteBindPoseToRef;
  54317. /** function to build and bind sphere joint points and spur bone representations. */
  54318. private _buildSpheresAndSpurs;
  54319. private _buildLocalAxes;
  54320. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  54321. private _displayLinesUpdate;
  54322. /** Changes the displayMode of the skeleton viewer
  54323. * @param mode The displayMode numerical value
  54324. */
  54325. changeDisplayMode(mode: number): void;
  54326. /** Sets a display option of the skeleton viewer
  54327. *
  54328. * | Option | Type | Default | Description |
  54329. * | ---------------- | ------- | ------- | ----------- |
  54330. * | midStep | float | 0.235 | A percentage between a bone and its child that determines the widest part of a spur. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  54331. * | midStepFactor | float | 0.15 | Mid step width expressed as a factor of the length. A value of 0.5 makes the spur width half of the spur length. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  54332. * | sphereBaseSize | float | 2 | Sphere base size. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  54333. * | sphereScaleUnit | float | 0.865 | Sphere scale factor used to scale spheres in relation to the longest bone. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  54334. * | spurFollowsChild | boolean | false | Whether a spur should attach its far end to the child bone. |
  54335. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  54336. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  54337. *
  54338. * @param option String of the option name
  54339. * @param value The numerical option value
  54340. */
  54341. changeDisplayOptions(option: string, value: number): void;
  54342. /** Release associated resources */
  54343. dispose(): void;
  54344. }
  54345. }
  54346. declare module BABYLON {
  54347. /**
  54348. * Enum for Device Types
  54349. */
  54350. export enum DeviceType {
  54351. /** Generic */
  54352. Generic = 0,
  54353. /** Keyboard */
  54354. Keyboard = 1,
  54355. /** Mouse */
  54356. Mouse = 2,
  54357. /** Touch Pointers */
  54358. Touch = 3,
  54359. /** PS4 Dual Shock */
  54360. DualShock = 4,
  54361. /** Xbox */
  54362. Xbox = 5,
  54363. /** Switch Controller */
  54364. Switch = 6
  54365. }
  54366. /**
  54367. * Enum for All Pointers (Touch/Mouse)
  54368. */
  54369. export enum PointerInput {
  54370. /** Horizontal Axis */
  54371. Horizontal = 0,
  54372. /** Vertical Axis */
  54373. Vertical = 1,
  54374. /** Left Click or Touch */
  54375. LeftClick = 2,
  54376. /** Middle Click */
  54377. MiddleClick = 3,
  54378. /** Right Click */
  54379. RightClick = 4,
  54380. /** Browser Back */
  54381. BrowserBack = 5,
  54382. /** Browser Forward */
  54383. BrowserForward = 6
  54384. }
  54385. /**
  54386. * Enum for Dual Shock Gamepad
  54387. */
  54388. export enum DualShockInput {
  54389. /** Cross */
  54390. Cross = 0,
  54391. /** Circle */
  54392. Circle = 1,
  54393. /** Square */
  54394. Square = 2,
  54395. /** Triangle */
  54396. Triangle = 3,
  54397. /** L1 */
  54398. L1 = 4,
  54399. /** R1 */
  54400. R1 = 5,
  54401. /** L2 */
  54402. L2 = 6,
  54403. /** R2 */
  54404. R2 = 7,
  54405. /** Share */
  54406. Share = 8,
  54407. /** Options */
  54408. Options = 9,
  54409. /** L3 */
  54410. L3 = 10,
  54411. /** R3 */
  54412. R3 = 11,
  54413. /** DPadUp */
  54414. DPadUp = 12,
  54415. /** DPadDown */
  54416. DPadDown = 13,
  54417. /** DPadLeft */
  54418. DPadLeft = 14,
  54419. /** DRight */
  54420. DPadRight = 15,
  54421. /** Home */
  54422. Home = 16,
  54423. /** TouchPad */
  54424. TouchPad = 17,
  54425. /** LStickXAxis */
  54426. LStickXAxis = 18,
  54427. /** LStickYAxis */
  54428. LStickYAxis = 19,
  54429. /** RStickXAxis */
  54430. RStickXAxis = 20,
  54431. /** RStickYAxis */
  54432. RStickYAxis = 21
  54433. }
  54434. /**
  54435. * Enum for Xbox Gamepad
  54436. */
  54437. export enum XboxInput {
  54438. /** A */
  54439. A = 0,
  54440. /** B */
  54441. B = 1,
  54442. /** X */
  54443. X = 2,
  54444. /** Y */
  54445. Y = 3,
  54446. /** LB */
  54447. LB = 4,
  54448. /** RB */
  54449. RB = 5,
  54450. /** LT */
  54451. LT = 6,
  54452. /** RT */
  54453. RT = 7,
  54454. /** Back */
  54455. Back = 8,
  54456. /** Start */
  54457. Start = 9,
  54458. /** LS */
  54459. LS = 10,
  54460. /** RS */
  54461. RS = 11,
  54462. /** DPadUp */
  54463. DPadUp = 12,
  54464. /** DPadDown */
  54465. DPadDown = 13,
  54466. /** DPadLeft */
  54467. DPadLeft = 14,
  54468. /** DRight */
  54469. DPadRight = 15,
  54470. /** Home */
  54471. Home = 16,
  54472. /** LStickXAxis */
  54473. LStickXAxis = 17,
  54474. /** LStickYAxis */
  54475. LStickYAxis = 18,
  54476. /** RStickXAxis */
  54477. RStickXAxis = 19,
  54478. /** RStickYAxis */
  54479. RStickYAxis = 20
  54480. }
  54481. /**
  54482. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  54483. */
  54484. export enum SwitchInput {
  54485. /** B */
  54486. B = 0,
  54487. /** A */
  54488. A = 1,
  54489. /** Y */
  54490. Y = 2,
  54491. /** X */
  54492. X = 3,
  54493. /** L */
  54494. L = 4,
  54495. /** R */
  54496. R = 5,
  54497. /** ZL */
  54498. ZL = 6,
  54499. /** ZR */
  54500. ZR = 7,
  54501. /** Minus */
  54502. Minus = 8,
  54503. /** Plus */
  54504. Plus = 9,
  54505. /** LS */
  54506. LS = 10,
  54507. /** RS */
  54508. RS = 11,
  54509. /** DPadUp */
  54510. DPadUp = 12,
  54511. /** DPadDown */
  54512. DPadDown = 13,
  54513. /** DPadLeft */
  54514. DPadLeft = 14,
  54515. /** DRight */
  54516. DPadRight = 15,
  54517. /** Home */
  54518. Home = 16,
  54519. /** Capture */
  54520. Capture = 17,
  54521. /** LStickXAxis */
  54522. LStickXAxis = 18,
  54523. /** LStickYAxis */
  54524. LStickYAxis = 19,
  54525. /** RStickXAxis */
  54526. RStickXAxis = 20,
  54527. /** RStickYAxis */
  54528. RStickYAxis = 21
  54529. }
  54530. }
  54531. declare module BABYLON {
  54532. /**
  54533. * This class will take all inputs from Keyboard, Pointer, and
  54534. * any Gamepads and provide a polling system that all devices
  54535. * will use. This class assumes that there will only be one
  54536. * pointer device and one keyboard.
  54537. */
  54538. export class DeviceInputSystem implements IDisposable {
  54539. /**
  54540. * Callback to be triggered when a device is connected
  54541. */
  54542. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  54543. /**
  54544. * Callback to be triggered when a device is disconnected
  54545. */
  54546. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  54547. /**
  54548. * Callback to be triggered when event driven input is updated
  54549. */
  54550. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  54551. private _inputs;
  54552. private _gamepads;
  54553. private _keyboardActive;
  54554. private _pointerActive;
  54555. private _elementToAttachTo;
  54556. private _keyboardDownEvent;
  54557. private _keyboardUpEvent;
  54558. private _pointerMoveEvent;
  54559. private _pointerDownEvent;
  54560. private _pointerUpEvent;
  54561. private _gamepadConnectedEvent;
  54562. private _gamepadDisconnectedEvent;
  54563. private static _MAX_KEYCODES;
  54564. private static _MAX_POINTER_INPUTS;
  54565. private constructor();
  54566. /**
  54567. * Creates a new DeviceInputSystem instance
  54568. * @param engine Engine to pull input element from
  54569. * @returns The new instance
  54570. */
  54571. static Create(engine: Engine): DeviceInputSystem;
  54572. /**
  54573. * Checks for current device input value, given an id and input index
  54574. * @param deviceName Id of connected device
  54575. * @param inputIndex Index of device input
  54576. * @returns Current value of input
  54577. */
  54578. /**
  54579. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  54580. * @param deviceType Enum specifiying device type
  54581. * @param deviceSlot "Slot" or index that device is referenced in
  54582. * @param inputIndex Id of input to be checked
  54583. * @returns Current value of input
  54584. */
  54585. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  54586. /**
  54587. * Dispose of all the eventlisteners
  54588. */
  54589. dispose(): void;
  54590. /**
  54591. * Add device and inputs to device array
  54592. * @param deviceType Enum specifiying device type
  54593. * @param deviceSlot "Slot" or index that device is referenced in
  54594. * @param numberOfInputs Number of input entries to create for given device
  54595. */
  54596. private _registerDevice;
  54597. /**
  54598. * Given a specific device name, remove that device from the device map
  54599. * @param deviceType Enum specifiying device type
  54600. * @param deviceSlot "Slot" or index that device is referenced in
  54601. */
  54602. private _unregisterDevice;
  54603. /**
  54604. * Handle all actions that come from keyboard interaction
  54605. */
  54606. private _handleKeyActions;
  54607. /**
  54608. * Handle all actions that come from pointer interaction
  54609. */
  54610. private _handlePointerActions;
  54611. /**
  54612. * Handle all actions that come from gamepad interaction
  54613. */
  54614. private _handleGamepadActions;
  54615. /**
  54616. * Update all non-event based devices with each frame
  54617. * @param deviceType Enum specifiying device type
  54618. * @param deviceSlot "Slot" or index that device is referenced in
  54619. * @param inputIndex Id of input to be checked
  54620. */
  54621. private _updateDevice;
  54622. /**
  54623. * Gets DeviceType from the device name
  54624. * @param deviceName Name of Device from DeviceInputSystem
  54625. * @returns DeviceType enum value
  54626. */
  54627. private _getGamepadDeviceType;
  54628. }
  54629. }
  54630. declare module BABYLON {
  54631. /**
  54632. * Type to handle enforcement of inputs
  54633. */
  54634. 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;
  54635. }
  54636. declare module BABYLON {
  54637. /**
  54638. * Class that handles all input for a specific device
  54639. */
  54640. export class DeviceSource<T extends DeviceType> {
  54641. /** Type of device */
  54642. readonly deviceType: DeviceType;
  54643. /** "Slot" or index that device is referenced in */
  54644. readonly deviceSlot: number;
  54645. /**
  54646. * Observable to handle device input changes per device
  54647. */
  54648. readonly onInputChangedObservable: Observable<{
  54649. inputIndex: DeviceInput<T>;
  54650. previousState: Nullable<number>;
  54651. currentState: Nullable<number>;
  54652. }>;
  54653. private readonly _deviceInputSystem;
  54654. /**
  54655. * Default Constructor
  54656. * @param deviceInputSystem Reference to DeviceInputSystem
  54657. * @param deviceType Type of device
  54658. * @param deviceSlot "Slot" or index that device is referenced in
  54659. */
  54660. constructor(deviceInputSystem: DeviceInputSystem,
  54661. /** Type of device */
  54662. deviceType: DeviceType,
  54663. /** "Slot" or index that device is referenced in */
  54664. deviceSlot?: number);
  54665. /**
  54666. * Get input for specific input
  54667. * @param inputIndex index of specific input on device
  54668. * @returns Input value from DeviceInputSystem
  54669. */
  54670. getInput(inputIndex: DeviceInput<T>): number;
  54671. }
  54672. /**
  54673. * Class to keep track of devices
  54674. */
  54675. export class DeviceSourceManager implements IDisposable {
  54676. /**
  54677. * Observable to be triggered when before a device is connected
  54678. */
  54679. readonly onBeforeDeviceConnectedObservable: Observable<{
  54680. deviceType: DeviceType;
  54681. deviceSlot: number;
  54682. }>;
  54683. /**
  54684. * Observable to be triggered when before a device is disconnected
  54685. */
  54686. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  54687. deviceType: DeviceType;
  54688. deviceSlot: number;
  54689. }>;
  54690. /**
  54691. * Observable to be triggered when after a device is connected
  54692. */
  54693. readonly onAfterDeviceConnectedObservable: Observable<{
  54694. deviceType: DeviceType;
  54695. deviceSlot: number;
  54696. }>;
  54697. /**
  54698. * Observable to be triggered when after a device is disconnected
  54699. */
  54700. readonly onAfterDeviceDisconnectedObservable: Observable<{
  54701. deviceType: DeviceType;
  54702. deviceSlot: number;
  54703. }>;
  54704. private readonly _devices;
  54705. private readonly _firstDevice;
  54706. private readonly _deviceInputSystem;
  54707. /**
  54708. * Default Constructor
  54709. * @param engine engine to pull input element from
  54710. */
  54711. constructor(engine: Engine);
  54712. /**
  54713. * Gets a DeviceSource, given a type and slot
  54714. * @param deviceType Enum specifying device type
  54715. * @param deviceSlot "Slot" or index that device is referenced in
  54716. * @returns DeviceSource object
  54717. */
  54718. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  54719. /**
  54720. * Gets an array of DeviceSource objects for a given device type
  54721. * @param deviceType Enum specifying device type
  54722. * @returns Array of DeviceSource objects
  54723. */
  54724. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  54725. /**
  54726. * Dispose of DeviceInputSystem and other parts
  54727. */
  54728. dispose(): void;
  54729. /**
  54730. * Function to add device name to device list
  54731. * @param deviceType Enum specifying device type
  54732. * @param deviceSlot "Slot" or index that device is referenced in
  54733. */
  54734. private _addDevice;
  54735. /**
  54736. * Function to remove device name to device list
  54737. * @param deviceType Enum specifying device type
  54738. * @param deviceSlot "Slot" or index that device is referenced in
  54739. */
  54740. private _removeDevice;
  54741. /**
  54742. * Updates array storing first connected device of each type
  54743. * @param type Type of Device
  54744. */
  54745. private _updateFirstDevices;
  54746. }
  54747. }
  54748. declare module BABYLON {
  54749. /**
  54750. * Options to create the null engine
  54751. */
  54752. export class NullEngineOptions {
  54753. /**
  54754. * Render width (Default: 512)
  54755. */
  54756. renderWidth: number;
  54757. /**
  54758. * Render height (Default: 256)
  54759. */
  54760. renderHeight: number;
  54761. /**
  54762. * Texture size (Default: 512)
  54763. */
  54764. textureSize: number;
  54765. /**
  54766. * If delta time between frames should be constant
  54767. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  54768. */
  54769. deterministicLockstep: boolean;
  54770. /**
  54771. * Maximum about of steps between frames (Default: 4)
  54772. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  54773. */
  54774. lockstepMaxSteps: number;
  54775. /**
  54776. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  54777. */
  54778. useHighPrecisionMatrix?: boolean;
  54779. }
  54780. /**
  54781. * The null engine class provides support for headless version of babylon.js.
  54782. * This can be used in server side scenario or for testing purposes
  54783. */
  54784. export class NullEngine extends Engine {
  54785. private _options;
  54786. /**
  54787. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  54788. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  54789. * @returns true if engine is in deterministic lock step mode
  54790. */
  54791. isDeterministicLockStep(): boolean;
  54792. /**
  54793. * Gets the max steps when engine is running in deterministic lock step
  54794. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  54795. * @returns the max steps
  54796. */
  54797. getLockstepMaxSteps(): number;
  54798. /**
  54799. * Gets the current hardware scaling level.
  54800. * By default the hardware scaling level is computed from the window device ratio.
  54801. * 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.
  54802. * @returns a number indicating the current hardware scaling level
  54803. */
  54804. getHardwareScalingLevel(): number;
  54805. constructor(options?: NullEngineOptions);
  54806. /**
  54807. * Creates a vertex buffer
  54808. * @param vertices the data for the vertex buffer
  54809. * @returns the new WebGL static buffer
  54810. */
  54811. createVertexBuffer(vertices: FloatArray): DataBuffer;
  54812. /**
  54813. * Creates a new index buffer
  54814. * @param indices defines the content of the index buffer
  54815. * @param updatable defines if the index buffer must be updatable
  54816. * @returns a new webGL buffer
  54817. */
  54818. createIndexBuffer(indices: IndicesArray): DataBuffer;
  54819. /**
  54820. * Clear the current render buffer or the current render target (if any is set up)
  54821. * @param color defines the color to use
  54822. * @param backBuffer defines if the back buffer must be cleared
  54823. * @param depth defines if the depth buffer must be cleared
  54824. * @param stencil defines if the stencil buffer must be cleared
  54825. */
  54826. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  54827. /**
  54828. * Gets the current render width
  54829. * @param useScreen defines if screen size must be used (or the current render target if any)
  54830. * @returns a number defining the current render width
  54831. */
  54832. getRenderWidth(useScreen?: boolean): number;
  54833. /**
  54834. * Gets the current render height
  54835. * @param useScreen defines if screen size must be used (or the current render target if any)
  54836. * @returns a number defining the current render height
  54837. */
  54838. getRenderHeight(useScreen?: boolean): number;
  54839. /**
  54840. * Set the WebGL's viewport
  54841. * @param viewport defines the viewport element to be used
  54842. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  54843. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  54844. */
  54845. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  54846. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  54847. /**
  54848. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  54849. * @param pipelineContext defines the pipeline context to use
  54850. * @param uniformsNames defines the list of uniform names
  54851. * @returns an array of webGL uniform locations
  54852. */
  54853. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  54854. /**
  54855. * Gets the lsit of active attributes for a given webGL program
  54856. * @param pipelineContext defines the pipeline context to use
  54857. * @param attributesNames defines the list of attribute names to get
  54858. * @returns an array of indices indicating the offset of each attribute
  54859. */
  54860. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  54861. /**
  54862. * Binds an effect to the webGL context
  54863. * @param effect defines the effect to bind
  54864. */
  54865. bindSamplers(effect: Effect): void;
  54866. /**
  54867. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  54868. * @param effect defines the effect to activate
  54869. */
  54870. enableEffect(effect: Effect): void;
  54871. /**
  54872. * Set various states to the webGL context
  54873. * @param culling defines backface culling state
  54874. * @param zOffset defines the value to apply to zOffset (0 by default)
  54875. * @param force defines if states must be applied even if cache is up to date
  54876. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  54877. */
  54878. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  54879. /**
  54880. * Set the value of an uniform to an array of int32
  54881. * @param uniform defines the webGL uniform location where to store the value
  54882. * @param array defines the array of int32 to store
  54883. * @returns true if value was set
  54884. */
  54885. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  54886. /**
  54887. * Set the value of an uniform to an array of int32 (stored as vec2)
  54888. * @param uniform defines the webGL uniform location where to store the value
  54889. * @param array defines the array of int32 to store
  54890. * @returns true if value was set
  54891. */
  54892. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  54893. /**
  54894. * Set the value of an uniform to an array of int32 (stored as vec3)
  54895. * @param uniform defines the webGL uniform location where to store the value
  54896. * @param array defines the array of int32 to store
  54897. * @returns true if value was set
  54898. */
  54899. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  54900. /**
  54901. * Set the value of an uniform to an array of int32 (stored as vec4)
  54902. * @param uniform defines the webGL uniform location where to store the value
  54903. * @param array defines the array of int32 to store
  54904. * @returns true if value was set
  54905. */
  54906. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  54907. /**
  54908. * Set the value of an uniform to an array of float32
  54909. * @param uniform defines the webGL uniform location where to store the value
  54910. * @param array defines the array of float32 to store
  54911. * @returns true if value was set
  54912. */
  54913. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  54914. /**
  54915. * Set the value of an uniform to an array of float32 (stored as vec2)
  54916. * @param uniform defines the webGL uniform location where to store the value
  54917. * @param array defines the array of float32 to store
  54918. * @returns true if value was set
  54919. */
  54920. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  54921. /**
  54922. * Set the value of an uniform to an array of float32 (stored as vec3)
  54923. * @param uniform defines the webGL uniform location where to store the value
  54924. * @param array defines the array of float32 to store
  54925. * @returns true if value was set
  54926. */
  54927. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  54928. /**
  54929. * Set the value of an uniform to an array of float32 (stored as vec4)
  54930. * @param uniform defines the webGL uniform location where to store the value
  54931. * @param array defines the array of float32 to store
  54932. * @returns true if value was set
  54933. */
  54934. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  54935. /**
  54936. * Set the value of an uniform to an array of number
  54937. * @param uniform defines the webGL uniform location where to store the value
  54938. * @param array defines the array of number to store
  54939. * @returns true if value was set
  54940. */
  54941. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  54942. /**
  54943. * Set the value of an uniform to an array of number (stored as vec2)
  54944. * @param uniform defines the webGL uniform location where to store the value
  54945. * @param array defines the array of number to store
  54946. * @returns true if value was set
  54947. */
  54948. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  54949. /**
  54950. * Set the value of an uniform to an array of number (stored as vec3)
  54951. * @param uniform defines the webGL uniform location where to store the value
  54952. * @param array defines the array of number to store
  54953. * @returns true if value was set
  54954. */
  54955. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  54956. /**
  54957. * Set the value of an uniform to an array of number (stored as vec4)
  54958. * @param uniform defines the webGL uniform location where to store the value
  54959. * @param array defines the array of number to store
  54960. * @returns true if value was set
  54961. */
  54962. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  54963. /**
  54964. * Set the value of an uniform to an array of float32 (stored as matrices)
  54965. * @param uniform defines the webGL uniform location where to store the value
  54966. * @param matrices defines the array of float32 to store
  54967. * @returns true if value was set
  54968. */
  54969. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  54970. /**
  54971. * Set the value of an uniform to a matrix (3x3)
  54972. * @param uniform defines the webGL uniform location where to store the value
  54973. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  54974. * @returns true if value was set
  54975. */
  54976. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  54977. /**
  54978. * Set the value of an uniform to a matrix (2x2)
  54979. * @param uniform defines the webGL uniform location where to store the value
  54980. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  54981. * @returns true if value was set
  54982. */
  54983. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  54984. /**
  54985. * Set the value of an uniform to a number (float)
  54986. * @param uniform defines the webGL uniform location where to store the value
  54987. * @param value defines the float number to store
  54988. * @returns true if value was set
  54989. */
  54990. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  54991. /**
  54992. * Set the value of an uniform to a vec2
  54993. * @param uniform defines the webGL uniform location where to store the value
  54994. * @param x defines the 1st component of the value
  54995. * @param y defines the 2nd component of the value
  54996. * @returns true if value was set
  54997. */
  54998. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  54999. /**
  55000. * Set the value of an uniform to a vec3
  55001. * @param uniform defines the webGL uniform location where to store the value
  55002. * @param x defines the 1st component of the value
  55003. * @param y defines the 2nd component of the value
  55004. * @param z defines the 3rd component of the value
  55005. * @returns true if value was set
  55006. */
  55007. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  55008. /**
  55009. * Set the value of an uniform to a boolean
  55010. * @param uniform defines the webGL uniform location where to store the value
  55011. * @param bool defines the boolean to store
  55012. * @returns true if value was set
  55013. */
  55014. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  55015. /**
  55016. * Set the value of an uniform to a vec4
  55017. * @param uniform defines the webGL uniform location where to store the value
  55018. * @param x defines the 1st component of the value
  55019. * @param y defines the 2nd component of the value
  55020. * @param z defines the 3rd component of the value
  55021. * @param w defines the 4th component of the value
  55022. * @returns true if value was set
  55023. */
  55024. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  55025. /**
  55026. * Sets the current alpha mode
  55027. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  55028. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  55029. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  55030. */
  55031. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  55032. /**
  55033. * Bind webGl buffers directly to the webGL context
  55034. * @param vertexBuffers defines the vertex buffer to bind
  55035. * @param indexBuffer defines the index buffer to bind
  55036. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  55037. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  55038. * @param effect defines the effect associated with the vertex buffer
  55039. */
  55040. bindBuffers(vertexBuffers: {
  55041. [key: string]: VertexBuffer;
  55042. }, indexBuffer: DataBuffer, effect: Effect): void;
  55043. /**
  55044. * Force the entire cache to be cleared
  55045. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  55046. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  55047. */
  55048. wipeCaches(bruteForce?: boolean): void;
  55049. /**
  55050. * Send a draw order
  55051. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  55052. * @param indexStart defines the starting index
  55053. * @param indexCount defines the number of index to draw
  55054. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  55055. */
  55056. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  55057. /**
  55058. * Draw a list of indexed primitives
  55059. * @param fillMode defines the primitive to use
  55060. * @param indexStart defines the starting index
  55061. * @param indexCount defines the number of index to draw
  55062. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  55063. */
  55064. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  55065. /**
  55066. * Draw a list of unindexed primitives
  55067. * @param fillMode defines the primitive to use
  55068. * @param verticesStart defines the index of first vertex to draw
  55069. * @param verticesCount defines the count of vertices to draw
  55070. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  55071. */
  55072. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  55073. /** @hidden */
  55074. _createTexture(): WebGLTexture;
  55075. /** @hidden */
  55076. _releaseTexture(texture: InternalTexture): void;
  55077. /**
  55078. * Usually called from Texture.ts.
  55079. * Passed information to create a WebGLTexture
  55080. * @param urlArg defines a value which contains one of the following:
  55081. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  55082. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  55083. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  55084. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  55085. * @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)
  55086. * @param scene needed for loading to the correct scene
  55087. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  55088. * @param onLoad optional callback to be called upon successful completion
  55089. * @param onError optional callback to be called upon failure
  55090. * @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
  55091. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  55092. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  55093. * @param forcedExtension defines the extension to use to pick the right loader
  55094. * @param mimeType defines an optional mime type
  55095. * @returns a InternalTexture for assignment back into BABYLON.Texture
  55096. */
  55097. 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;
  55098. /**
  55099. * Creates a new render target texture
  55100. * @param size defines the size of the texture
  55101. * @param options defines the options used to create the texture
  55102. * @returns a new render target texture stored in an InternalTexture
  55103. */
  55104. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  55105. /**
  55106. * Update the sampling mode of a given texture
  55107. * @param samplingMode defines the required sampling mode
  55108. * @param texture defines the texture to update
  55109. */
  55110. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  55111. /**
  55112. * Binds the frame buffer to the specified texture.
  55113. * @param texture The texture to render to or null for the default canvas
  55114. * @param faceIndex The face of the texture to render to in case of cube texture
  55115. * @param requiredWidth The width of the target to render to
  55116. * @param requiredHeight The height of the target to render to
  55117. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  55118. * @param lodLevel defines le lod level to bind to the frame buffer
  55119. */
  55120. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  55121. /**
  55122. * Unbind the current render target texture from the webGL context
  55123. * @param texture defines the render target texture to unbind
  55124. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  55125. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  55126. */
  55127. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  55128. /**
  55129. * Creates a dynamic vertex buffer
  55130. * @param vertices the data for the dynamic vertex buffer
  55131. * @returns the new WebGL dynamic buffer
  55132. */
  55133. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  55134. /**
  55135. * Update the content of a dynamic texture
  55136. * @param texture defines the texture to update
  55137. * @param canvas defines the canvas containing the source
  55138. * @param invertY defines if data must be stored with Y axis inverted
  55139. * @param premulAlpha defines if alpha is stored as premultiplied
  55140. * @param format defines the format of the data
  55141. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  55142. */
  55143. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  55144. /**
  55145. * Gets a boolean indicating if all created effects are ready
  55146. * @returns true if all effects are ready
  55147. */
  55148. areAllEffectsReady(): boolean;
  55149. /**
  55150. * @hidden
  55151. * Get the current error code of the webGL context
  55152. * @returns the error code
  55153. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  55154. */
  55155. getError(): number;
  55156. /** @hidden */
  55157. _getUnpackAlignement(): number;
  55158. /** @hidden */
  55159. _unpackFlipY(value: boolean): void;
  55160. /**
  55161. * Update a dynamic index buffer
  55162. * @param indexBuffer defines the target index buffer
  55163. * @param indices defines the data to update
  55164. * @param offset defines the offset in the target index buffer where update should start
  55165. */
  55166. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  55167. /**
  55168. * Updates a dynamic vertex buffer.
  55169. * @param vertexBuffer the vertex buffer to update
  55170. * @param vertices the data used to update the vertex buffer
  55171. * @param byteOffset the byte offset of the data (optional)
  55172. * @param byteLength the byte length of the data (optional)
  55173. */
  55174. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  55175. /** @hidden */
  55176. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  55177. /** @hidden */
  55178. _bindTexture(channel: number, texture: InternalTexture): void;
  55179. protected _deleteBuffer(buffer: WebGLBuffer): void;
  55180. /**
  55181. * 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
  55182. */
  55183. releaseEffects(): void;
  55184. displayLoadingUI(): void;
  55185. hideLoadingUI(): void;
  55186. /** @hidden */
  55187. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  55188. /** @hidden */
  55189. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  55190. /** @hidden */
  55191. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  55192. /** @hidden */
  55193. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  55194. }
  55195. }
  55196. declare module BABYLON {
  55197. /**
  55198. * @hidden
  55199. **/
  55200. export class _TimeToken {
  55201. _startTimeQuery: Nullable<WebGLQuery>;
  55202. _endTimeQuery: Nullable<WebGLQuery>;
  55203. _timeElapsedQuery: Nullable<WebGLQuery>;
  55204. _timeElapsedQueryEnded: boolean;
  55205. }
  55206. }
  55207. declare module BABYLON {
  55208. /** @hidden */
  55209. export class _OcclusionDataStorage {
  55210. /** @hidden */
  55211. occlusionInternalRetryCounter: number;
  55212. /** @hidden */
  55213. isOcclusionQueryInProgress: boolean;
  55214. /** @hidden */
  55215. isOccluded: boolean;
  55216. /** @hidden */
  55217. occlusionRetryCount: number;
  55218. /** @hidden */
  55219. occlusionType: number;
  55220. /** @hidden */
  55221. occlusionQueryAlgorithmType: number;
  55222. }
  55223. interface Engine {
  55224. /**
  55225. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  55226. * @return the new query
  55227. */
  55228. createQuery(): WebGLQuery;
  55229. /**
  55230. * Delete and release a webGL query
  55231. * @param query defines the query to delete
  55232. * @return the current engine
  55233. */
  55234. deleteQuery(query: WebGLQuery): Engine;
  55235. /**
  55236. * Check if a given query has resolved and got its value
  55237. * @param query defines the query to check
  55238. * @returns true if the query got its value
  55239. */
  55240. isQueryResultAvailable(query: WebGLQuery): boolean;
  55241. /**
  55242. * Gets the value of a given query
  55243. * @param query defines the query to check
  55244. * @returns the value of the query
  55245. */
  55246. getQueryResult(query: WebGLQuery): number;
  55247. /**
  55248. * Initiates an occlusion query
  55249. * @param algorithmType defines the algorithm to use
  55250. * @param query defines the query to use
  55251. * @returns the current engine
  55252. * @see https://doc.babylonjs.com/features/occlusionquery
  55253. */
  55254. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  55255. /**
  55256. * Ends an occlusion query
  55257. * @see https://doc.babylonjs.com/features/occlusionquery
  55258. * @param algorithmType defines the algorithm to use
  55259. * @returns the current engine
  55260. */
  55261. endOcclusionQuery(algorithmType: number): Engine;
  55262. /**
  55263. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  55264. * Please note that only one query can be issued at a time
  55265. * @returns a time token used to track the time span
  55266. */
  55267. startTimeQuery(): Nullable<_TimeToken>;
  55268. /**
  55269. * Ends a time query
  55270. * @param token defines the token used to measure the time span
  55271. * @returns the time spent (in ns)
  55272. */
  55273. endTimeQuery(token: _TimeToken): int;
  55274. /** @hidden */
  55275. _currentNonTimestampToken: Nullable<_TimeToken>;
  55276. /** @hidden */
  55277. _createTimeQuery(): WebGLQuery;
  55278. /** @hidden */
  55279. _deleteTimeQuery(query: WebGLQuery): void;
  55280. /** @hidden */
  55281. _getGlAlgorithmType(algorithmType: number): number;
  55282. /** @hidden */
  55283. _getTimeQueryResult(query: WebGLQuery): any;
  55284. /** @hidden */
  55285. _getTimeQueryAvailability(query: WebGLQuery): any;
  55286. }
  55287. interface AbstractMesh {
  55288. /**
  55289. * Backing filed
  55290. * @hidden
  55291. */
  55292. __occlusionDataStorage: _OcclusionDataStorage;
  55293. /**
  55294. * Access property
  55295. * @hidden
  55296. */
  55297. _occlusionDataStorage: _OcclusionDataStorage;
  55298. /**
  55299. * 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.
  55300. * The default value is -1 which means don't break the query and wait till the result
  55301. * @see https://doc.babylonjs.com/features/occlusionquery
  55302. */
  55303. occlusionRetryCount: number;
  55304. /**
  55305. * 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:
  55306. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  55307. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  55308. * * 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.
  55309. * @see https://doc.babylonjs.com/features/occlusionquery
  55310. */
  55311. occlusionType: number;
  55312. /**
  55313. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  55314. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  55315. * * 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.
  55316. * @see https://doc.babylonjs.com/features/occlusionquery
  55317. */
  55318. occlusionQueryAlgorithmType: number;
  55319. /**
  55320. * 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
  55321. * @see https://doc.babylonjs.com/features/occlusionquery
  55322. */
  55323. isOccluded: boolean;
  55324. /**
  55325. * Flag to check the progress status of the query
  55326. * @see https://doc.babylonjs.com/features/occlusionquery
  55327. */
  55328. isOcclusionQueryInProgress: boolean;
  55329. }
  55330. }
  55331. declare module BABYLON {
  55332. /** @hidden */
  55333. export var _forceTransformFeedbackToBundle: boolean;
  55334. interface Engine {
  55335. /**
  55336. * Creates a webGL transform feedback object
  55337. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  55338. * @returns the webGL transform feedback object
  55339. */
  55340. createTransformFeedback(): WebGLTransformFeedback;
  55341. /**
  55342. * Delete a webGL transform feedback object
  55343. * @param value defines the webGL transform feedback object to delete
  55344. */
  55345. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  55346. /**
  55347. * Bind a webGL transform feedback object to the webgl context
  55348. * @param value defines the webGL transform feedback object to bind
  55349. */
  55350. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  55351. /**
  55352. * Begins a transform feedback operation
  55353. * @param usePoints defines if points or triangles must be used
  55354. */
  55355. beginTransformFeedback(usePoints: boolean): void;
  55356. /**
  55357. * Ends a transform feedback operation
  55358. */
  55359. endTransformFeedback(): void;
  55360. /**
  55361. * Specify the varyings to use with transform feedback
  55362. * @param program defines the associated webGL program
  55363. * @param value defines the list of strings representing the varying names
  55364. */
  55365. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  55366. /**
  55367. * Bind a webGL buffer for a transform feedback operation
  55368. * @param value defines the webGL buffer to bind
  55369. */
  55370. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  55371. }
  55372. }
  55373. declare module BABYLON {
  55374. /**
  55375. * Class used to define an additional view for the engine
  55376. * @see https://doc.babylonjs.com/how_to/multi_canvases
  55377. */
  55378. export class EngineView {
  55379. /** Defines the canvas where to render the view */
  55380. target: HTMLCanvasElement;
  55381. /** Defines an optional camera used to render the view (will use active camera else) */
  55382. camera?: Camera;
  55383. }
  55384. interface Engine {
  55385. /**
  55386. * Gets or sets the HTML element to use for attaching events
  55387. */
  55388. inputElement: Nullable<HTMLElement>;
  55389. /**
  55390. * Gets the current engine view
  55391. * @see https://doc.babylonjs.com/how_to/multi_canvases
  55392. */
  55393. activeView: Nullable<EngineView>;
  55394. /** Gets or sets the list of views */
  55395. views: EngineView[];
  55396. /**
  55397. * Register a new child canvas
  55398. * @param canvas defines the canvas to register
  55399. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  55400. * @returns the associated view
  55401. */
  55402. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  55403. /**
  55404. * Remove a registered child canvas
  55405. * @param canvas defines the canvas to remove
  55406. * @returns the current engine
  55407. */
  55408. unRegisterView(canvas: HTMLCanvasElement): Engine;
  55409. }
  55410. }
  55411. declare module BABYLON {
  55412. interface Engine {
  55413. /** @hidden */
  55414. _excludedCompressedTextures: string[];
  55415. /** @hidden */
  55416. _textureFormatInUse: string;
  55417. /**
  55418. * Gets the list of texture formats supported
  55419. */
  55420. readonly texturesSupported: Array<string>;
  55421. /**
  55422. * Gets the texture format in use
  55423. */
  55424. readonly textureFormatInUse: Nullable<string>;
  55425. /**
  55426. * Set the compressed texture extensions or file names to skip.
  55427. *
  55428. * @param skippedFiles defines the list of those texture files you want to skip
  55429. * Example: [".dds", ".env", "myfile.png"]
  55430. */
  55431. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  55432. /**
  55433. * Set the compressed texture format to use, based on the formats you have, and the formats
  55434. * supported by the hardware / browser.
  55435. *
  55436. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  55437. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  55438. * to API arguments needed to compressed textures. This puts the burden on the container
  55439. * generator to house the arcane code for determining these for current & future formats.
  55440. *
  55441. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  55442. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  55443. *
  55444. * Note: The result of this call is not taken into account when a texture is base64.
  55445. *
  55446. * @param formatsAvailable defines the list of those format families you have created
  55447. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  55448. *
  55449. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  55450. * @returns The extension selected.
  55451. */
  55452. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  55453. }
  55454. }
  55455. declare module BABYLON {
  55456. /** @hidden */
  55457. export var rgbdEncodePixelShader: {
  55458. name: string;
  55459. shader: string;
  55460. };
  55461. }
  55462. declare module BABYLON {
  55463. /**
  55464. * Raw texture data and descriptor sufficient for WebGL texture upload
  55465. */
  55466. export interface EnvironmentTextureInfo {
  55467. /**
  55468. * Version of the environment map
  55469. */
  55470. version: number;
  55471. /**
  55472. * Width of image
  55473. */
  55474. width: number;
  55475. /**
  55476. * Irradiance information stored in the file.
  55477. */
  55478. irradiance: any;
  55479. /**
  55480. * Specular information stored in the file.
  55481. */
  55482. specular: any;
  55483. }
  55484. /**
  55485. * Defines One Image in the file. It requires only the position in the file
  55486. * as well as the length.
  55487. */
  55488. interface BufferImageData {
  55489. /**
  55490. * Length of the image data.
  55491. */
  55492. length: number;
  55493. /**
  55494. * Position of the data from the null terminator delimiting the end of the JSON.
  55495. */
  55496. position: number;
  55497. }
  55498. /**
  55499. * Defines the specular data enclosed in the file.
  55500. * This corresponds to the version 1 of the data.
  55501. */
  55502. export interface EnvironmentTextureSpecularInfoV1 {
  55503. /**
  55504. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  55505. */
  55506. specularDataPosition?: number;
  55507. /**
  55508. * This contains all the images data needed to reconstruct the cubemap.
  55509. */
  55510. mipmaps: Array<BufferImageData>;
  55511. /**
  55512. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  55513. */
  55514. lodGenerationScale: number;
  55515. }
  55516. /**
  55517. * Sets of helpers addressing the serialization and deserialization of environment texture
  55518. * stored in a BabylonJS env file.
  55519. * Those files are usually stored as .env files.
  55520. */
  55521. export class EnvironmentTextureTools {
  55522. /**
  55523. * Magic number identifying the env file.
  55524. */
  55525. private static _MagicBytes;
  55526. /**
  55527. * Gets the environment info from an env file.
  55528. * @param data The array buffer containing the .env bytes.
  55529. * @returns the environment file info (the json header) if successfully parsed.
  55530. */
  55531. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  55532. /**
  55533. * Creates an environment texture from a loaded cube texture.
  55534. * @param texture defines the cube texture to convert in env file
  55535. * @return a promise containing the environment data if succesfull.
  55536. */
  55537. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  55538. /**
  55539. * Creates a JSON representation of the spherical data.
  55540. * @param texture defines the texture containing the polynomials
  55541. * @return the JSON representation of the spherical info
  55542. */
  55543. private static _CreateEnvTextureIrradiance;
  55544. /**
  55545. * Creates the ArrayBufferViews used for initializing environment texture image data.
  55546. * @param data the image data
  55547. * @param info parameters that determine what views will be created for accessing the underlying buffer
  55548. * @return the views described by info providing access to the underlying buffer
  55549. */
  55550. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  55551. /**
  55552. * Uploads the texture info contained in the env file to the GPU.
  55553. * @param texture defines the internal texture to upload to
  55554. * @param data defines the data to load
  55555. * @param info defines the texture info retrieved through the GetEnvInfo method
  55556. * @returns a promise
  55557. */
  55558. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  55559. private static _OnImageReadyAsync;
  55560. /**
  55561. * Uploads the levels of image data to the GPU.
  55562. * @param texture defines the internal texture to upload to
  55563. * @param imageData defines the array buffer views of image data [mipmap][face]
  55564. * @returns a promise
  55565. */
  55566. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  55567. /**
  55568. * Uploads spherical polynomials information to the texture.
  55569. * @param texture defines the texture we are trying to upload the information to
  55570. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  55571. */
  55572. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  55573. /** @hidden */
  55574. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  55575. }
  55576. }
  55577. declare module BABYLON {
  55578. /**
  55579. * Class used to inline functions in shader code
  55580. */
  55581. export class ShaderCodeInliner {
  55582. private static readonly _RegexpFindFunctionNameAndType;
  55583. private _sourceCode;
  55584. private _functionDescr;
  55585. private _numMaxIterations;
  55586. /** Gets or sets the token used to mark the functions to inline */
  55587. inlineToken: string;
  55588. /** Gets or sets the debug mode */
  55589. debug: boolean;
  55590. /** Gets the code after the inlining process */
  55591. get code(): string;
  55592. /**
  55593. * Initializes the inliner
  55594. * @param sourceCode shader code source to inline
  55595. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  55596. */
  55597. constructor(sourceCode: string, numMaxIterations?: number);
  55598. /**
  55599. * Start the processing of the shader code
  55600. */
  55601. processCode(): void;
  55602. private _collectFunctions;
  55603. private _processInlining;
  55604. private _extractBetweenMarkers;
  55605. private _skipWhitespaces;
  55606. private _removeComments;
  55607. private _replaceFunctionCallsByCode;
  55608. private _findBackward;
  55609. private _escapeRegExp;
  55610. private _replaceNames;
  55611. }
  55612. }
  55613. declare module BABYLON {
  55614. /**
  55615. * Container for accessors for natively-stored mesh data buffers.
  55616. */
  55617. class NativeDataBuffer extends DataBuffer {
  55618. /**
  55619. * Accessor value used to identify/retrieve a natively-stored index buffer.
  55620. */
  55621. nativeIndexBuffer?: any;
  55622. /**
  55623. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  55624. */
  55625. nativeVertexBuffer?: any;
  55626. }
  55627. /** @hidden */
  55628. class NativeTexture extends InternalTexture {
  55629. getInternalTexture(): InternalTexture;
  55630. getViewCount(): number;
  55631. }
  55632. /** @hidden */
  55633. export class NativeEngine extends Engine {
  55634. private readonly _native;
  55635. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  55636. private readonly INVALID_HANDLE;
  55637. private _boundBuffersVertexArray;
  55638. private _currentDepthTest;
  55639. getHardwareScalingLevel(): number;
  55640. constructor();
  55641. dispose(): void;
  55642. /**
  55643. * Can be used to override the current requestAnimationFrame requester.
  55644. * @hidden
  55645. */
  55646. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  55647. /**
  55648. * Override default engine behavior.
  55649. * @param color
  55650. * @param backBuffer
  55651. * @param depth
  55652. * @param stencil
  55653. */
  55654. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  55655. /**
  55656. * Gets host document
  55657. * @returns the host document object
  55658. */
  55659. getHostDocument(): Nullable<Document>;
  55660. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  55661. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  55662. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  55663. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  55664. [key: string]: VertexBuffer;
  55665. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  55666. bindBuffers(vertexBuffers: {
  55667. [key: string]: VertexBuffer;
  55668. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  55669. recordVertexArrayObject(vertexBuffers: {
  55670. [key: string]: VertexBuffer;
  55671. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  55672. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  55673. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  55674. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  55675. /**
  55676. * Draw a list of indexed primitives
  55677. * @param fillMode defines the primitive to use
  55678. * @param indexStart defines the starting index
  55679. * @param indexCount defines the number of index to draw
  55680. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  55681. */
  55682. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  55683. /**
  55684. * Draw a list of unindexed primitives
  55685. * @param fillMode defines the primitive to use
  55686. * @param verticesStart defines the index of first vertex to draw
  55687. * @param verticesCount defines the count of vertices to draw
  55688. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  55689. */
  55690. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  55691. createPipelineContext(): IPipelineContext;
  55692. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  55693. /** @hidden */
  55694. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  55695. /** @hidden */
  55696. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  55697. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  55698. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  55699. protected _setProgram(program: WebGLProgram): void;
  55700. _releaseEffect(effect: Effect): void;
  55701. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  55702. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  55703. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  55704. bindSamplers(effect: Effect): void;
  55705. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  55706. getRenderWidth(useScreen?: boolean): number;
  55707. getRenderHeight(useScreen?: boolean): number;
  55708. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  55709. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  55710. /**
  55711. * Set the z offset to apply to current rendering
  55712. * @param value defines the offset to apply
  55713. */
  55714. setZOffset(value: number): void;
  55715. /**
  55716. * Gets the current value of the zOffset
  55717. * @returns the current zOffset state
  55718. */
  55719. getZOffset(): number;
  55720. /**
  55721. * Enable or disable depth buffering
  55722. * @param enable defines the state to set
  55723. */
  55724. setDepthBuffer(enable: boolean): void;
  55725. /**
  55726. * Gets a boolean indicating if depth writing is enabled
  55727. * @returns the current depth writing state
  55728. */
  55729. getDepthWrite(): boolean;
  55730. setDepthFunctionToGreater(): void;
  55731. setDepthFunctionToGreaterOrEqual(): void;
  55732. setDepthFunctionToLess(): void;
  55733. setDepthFunctionToLessOrEqual(): void;
  55734. /**
  55735. * Enable or disable depth writing
  55736. * @param enable defines the state to set
  55737. */
  55738. setDepthWrite(enable: boolean): void;
  55739. /**
  55740. * Enable or disable color writing
  55741. * @param enable defines the state to set
  55742. */
  55743. setColorWrite(enable: boolean): void;
  55744. /**
  55745. * Gets a boolean indicating if color writing is enabled
  55746. * @returns the current color writing state
  55747. */
  55748. getColorWrite(): boolean;
  55749. /**
  55750. * Sets alpha constants used by some alpha blending modes
  55751. * @param r defines the red component
  55752. * @param g defines the green component
  55753. * @param b defines the blue component
  55754. * @param a defines the alpha component
  55755. */
  55756. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  55757. /**
  55758. * Sets the current alpha mode
  55759. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  55760. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  55761. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  55762. */
  55763. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  55764. /**
  55765. * Gets the current alpha mode
  55766. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  55767. * @returns the current alpha mode
  55768. */
  55769. getAlphaMode(): number;
  55770. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  55771. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  55772. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  55773. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  55774. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  55775. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  55776. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  55777. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  55778. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  55779. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  55780. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  55781. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  55782. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  55783. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  55784. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  55785. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  55786. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  55787. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  55788. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  55789. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  55790. setColor3(uniform: WebGLUniformLocation, color3: Color3): boolean;
  55791. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): boolean;
  55792. wipeCaches(bruteForce?: boolean): void;
  55793. _createTexture(): WebGLTexture;
  55794. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  55795. /**
  55796. * Update the content of a dynamic texture
  55797. * @param texture defines the texture to update
  55798. * @param canvas defines the canvas containing the source
  55799. * @param invertY defines if data must be stored with Y axis inverted
  55800. * @param premulAlpha defines if alpha is stored as premultiplied
  55801. * @param format defines the format of the data
  55802. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  55803. */
  55804. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  55805. /**
  55806. * Usually called from Texture.ts.
  55807. * Passed information to create a WebGLTexture
  55808. * @param url defines a value which contains one of the following:
  55809. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  55810. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  55811. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  55812. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  55813. * @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)
  55814. * @param scene needed for loading to the correct scene
  55815. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  55816. * @param onLoad optional callback to be called upon successful completion
  55817. * @param onError optional callback to be called upon failure
  55818. * @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
  55819. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  55820. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  55821. * @param forcedExtension defines the extension to use to pick the right loader
  55822. * @param mimeType defines an optional mime type
  55823. * @returns a InternalTexture for assignment back into BABYLON.Texture
  55824. */
  55825. 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;
  55826. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): NativeTexture;
  55827. _releaseFramebufferObjects(texture: InternalTexture): void;
  55828. /**
  55829. * Creates a cube texture
  55830. * @param rootUrl defines the url where the files to load is located
  55831. * @param scene defines the current scene
  55832. * @param files defines the list of files to load (1 per face)
  55833. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  55834. * @param onLoad defines an optional callback raised when the texture is loaded
  55835. * @param onError defines an optional callback raised if there is an issue to load the texture
  55836. * @param format defines the format of the data
  55837. * @param forcedExtension defines the extension to use to pick the right loader
  55838. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  55839. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  55840. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  55841. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  55842. * @returns the cube texture as an InternalTexture
  55843. */
  55844. 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;
  55845. createRenderTargetTexture(size: number | {
  55846. width: number;
  55847. height: number;
  55848. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  55849. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  55850. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  55851. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  55852. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  55853. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  55854. /**
  55855. * Updates a dynamic vertex buffer.
  55856. * @param vertexBuffer the vertex buffer to update
  55857. * @param data the data used to update the vertex buffer
  55858. * @param byteOffset the byte offset of the data (optional)
  55859. * @param byteLength the byte length of the data (optional)
  55860. */
  55861. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  55862. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  55863. private _updateAnisotropicLevel;
  55864. private _getAddressMode;
  55865. /** @hidden */
  55866. _bindTexture(channel: number, texture: InternalTexture): void;
  55867. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  55868. releaseEffects(): void;
  55869. /** @hidden */
  55870. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  55871. /** @hidden */
  55872. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  55873. /** @hidden */
  55874. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  55875. /** @hidden */
  55876. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  55877. private _getNativeSamplingMode;
  55878. private _getNativeTextureFormat;
  55879. private _getNativeAlphaMode;
  55880. private _getNativeAttribType;
  55881. }
  55882. }
  55883. declare module BABYLON {
  55884. /**
  55885. * Gather the list of clipboard event types as constants.
  55886. */
  55887. export class ClipboardEventTypes {
  55888. /**
  55889. * The clipboard event is fired when a copy command is active (pressed).
  55890. */
  55891. static readonly COPY: number;
  55892. /**
  55893. * The clipboard event is fired when a cut command is active (pressed).
  55894. */
  55895. static readonly CUT: number;
  55896. /**
  55897. * The clipboard event is fired when a paste command is active (pressed).
  55898. */
  55899. static readonly PASTE: number;
  55900. }
  55901. /**
  55902. * This class is used to store clipboard related info for the onClipboardObservable event.
  55903. */
  55904. export class ClipboardInfo {
  55905. /**
  55906. * Defines the type of event (BABYLON.ClipboardEventTypes)
  55907. */
  55908. type: number;
  55909. /**
  55910. * Defines the related dom event
  55911. */
  55912. event: ClipboardEvent;
  55913. /**
  55914. *Creates an instance of ClipboardInfo.
  55915. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  55916. * @param event Defines the related dom event
  55917. */
  55918. constructor(
  55919. /**
  55920. * Defines the type of event (BABYLON.ClipboardEventTypes)
  55921. */
  55922. type: number,
  55923. /**
  55924. * Defines the related dom event
  55925. */
  55926. event: ClipboardEvent);
  55927. /**
  55928. * Get the clipboard event's type from the keycode.
  55929. * @param keyCode Defines the keyCode for the current keyboard event.
  55930. * @return {number}
  55931. */
  55932. static GetTypeFromCharacter(keyCode: number): number;
  55933. }
  55934. }
  55935. declare module BABYLON {
  55936. /**
  55937. * Google Daydream controller
  55938. */
  55939. export class DaydreamController extends WebVRController {
  55940. /**
  55941. * Base Url for the controller model.
  55942. */
  55943. static MODEL_BASE_URL: string;
  55944. /**
  55945. * File name for the controller model.
  55946. */
  55947. static MODEL_FILENAME: string;
  55948. /**
  55949. * Gamepad Id prefix used to identify Daydream Controller.
  55950. */
  55951. static readonly GAMEPAD_ID_PREFIX: string;
  55952. /**
  55953. * Creates a new DaydreamController from a gamepad
  55954. * @param vrGamepad the gamepad that the controller should be created from
  55955. */
  55956. constructor(vrGamepad: any);
  55957. /**
  55958. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55959. * @param scene scene in which to add meshes
  55960. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55961. */
  55962. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55963. /**
  55964. * Called once for each button that changed state since the last frame
  55965. * @param buttonIdx Which button index changed
  55966. * @param state New state of the button
  55967. * @param changes Which properties on the state changed since last frame
  55968. */
  55969. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55970. }
  55971. }
  55972. declare module BABYLON {
  55973. /**
  55974. * Gear VR Controller
  55975. */
  55976. export class GearVRController extends WebVRController {
  55977. /**
  55978. * Base Url for the controller model.
  55979. */
  55980. static MODEL_BASE_URL: string;
  55981. /**
  55982. * File name for the controller model.
  55983. */
  55984. static MODEL_FILENAME: string;
  55985. /**
  55986. * Gamepad Id prefix used to identify this controller.
  55987. */
  55988. static readonly GAMEPAD_ID_PREFIX: string;
  55989. private readonly _buttonIndexToObservableNameMap;
  55990. /**
  55991. * Creates a new GearVRController from a gamepad
  55992. * @param vrGamepad the gamepad that the controller should be created from
  55993. */
  55994. constructor(vrGamepad: any);
  55995. /**
  55996. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55997. * @param scene scene in which to add meshes
  55998. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55999. */
  56000. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  56001. /**
  56002. * Called once for each button that changed state since the last frame
  56003. * @param buttonIdx Which button index changed
  56004. * @param state New state of the button
  56005. * @param changes Which properties on the state changed since last frame
  56006. */
  56007. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  56008. }
  56009. }
  56010. declare module BABYLON {
  56011. /**
  56012. * Generic Controller
  56013. */
  56014. export class GenericController extends WebVRController {
  56015. /**
  56016. * Base Url for the controller model.
  56017. */
  56018. static readonly MODEL_BASE_URL: string;
  56019. /**
  56020. * File name for the controller model.
  56021. */
  56022. static readonly MODEL_FILENAME: string;
  56023. /**
  56024. * Creates a new GenericController from a gamepad
  56025. * @param vrGamepad the gamepad that the controller should be created from
  56026. */
  56027. constructor(vrGamepad: any);
  56028. /**
  56029. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  56030. * @param scene scene in which to add meshes
  56031. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  56032. */
  56033. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  56034. /**
  56035. * Called once for each button that changed state since the last frame
  56036. * @param buttonIdx Which button index changed
  56037. * @param state New state of the button
  56038. * @param changes Which properties on the state changed since last frame
  56039. */
  56040. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  56041. }
  56042. }
  56043. declare module BABYLON {
  56044. /**
  56045. * Oculus Touch Controller
  56046. */
  56047. export class OculusTouchController extends WebVRController {
  56048. /**
  56049. * Base Url for the controller model.
  56050. */
  56051. static MODEL_BASE_URL: string;
  56052. /**
  56053. * File name for the left controller model.
  56054. */
  56055. static MODEL_LEFT_FILENAME: string;
  56056. /**
  56057. * File name for the right controller model.
  56058. */
  56059. static MODEL_RIGHT_FILENAME: string;
  56060. /**
  56061. * Base Url for the Quest controller model.
  56062. */
  56063. static QUEST_MODEL_BASE_URL: string;
  56064. /**
  56065. * @hidden
  56066. * If the controllers are running on a device that needs the updated Quest controller models
  56067. */
  56068. static _IsQuest: boolean;
  56069. /**
  56070. * Fired when the secondary trigger on this controller is modified
  56071. */
  56072. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  56073. /**
  56074. * Fired when the thumb rest on this controller is modified
  56075. */
  56076. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  56077. /**
  56078. * Creates a new OculusTouchController from a gamepad
  56079. * @param vrGamepad the gamepad that the controller should be created from
  56080. */
  56081. constructor(vrGamepad: any);
  56082. /**
  56083. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  56084. * @param scene scene in which to add meshes
  56085. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  56086. */
  56087. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  56088. /**
  56089. * Fired when the A button on this controller is modified
  56090. */
  56091. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56092. /**
  56093. * Fired when the B button on this controller is modified
  56094. */
  56095. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56096. /**
  56097. * Fired when the X button on this controller is modified
  56098. */
  56099. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56100. /**
  56101. * Fired when the Y button on this controller is modified
  56102. */
  56103. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56104. /**
  56105. * Called once for each button that changed state since the last frame
  56106. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  56107. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  56108. * 2) secondary trigger (same)
  56109. * 3) A (right) X (left), touch, pressed = value
  56110. * 4) B / Y
  56111. * 5) thumb rest
  56112. * @param buttonIdx Which button index changed
  56113. * @param state New state of the button
  56114. * @param changes Which properties on the state changed since last frame
  56115. */
  56116. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  56117. }
  56118. }
  56119. declare module BABYLON {
  56120. /**
  56121. * Vive Controller
  56122. */
  56123. export class ViveController extends WebVRController {
  56124. /**
  56125. * Base Url for the controller model.
  56126. */
  56127. static MODEL_BASE_URL: string;
  56128. /**
  56129. * File name for the controller model.
  56130. */
  56131. static MODEL_FILENAME: string;
  56132. /**
  56133. * Creates a new ViveController from a gamepad
  56134. * @param vrGamepad the gamepad that the controller should be created from
  56135. */
  56136. constructor(vrGamepad: any);
  56137. /**
  56138. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  56139. * @param scene scene in which to add meshes
  56140. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  56141. */
  56142. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  56143. /**
  56144. * Fired when the left button on this controller is modified
  56145. */
  56146. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56147. /**
  56148. * Fired when the right button on this controller is modified
  56149. */
  56150. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56151. /**
  56152. * Fired when the menu button on this controller is modified
  56153. */
  56154. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56155. /**
  56156. * Called once for each button that changed state since the last frame
  56157. * Vive mapping:
  56158. * 0: touchpad
  56159. * 1: trigger
  56160. * 2: left AND right buttons
  56161. * 3: menu button
  56162. * @param buttonIdx Which button index changed
  56163. * @param state New state of the button
  56164. * @param changes Which properties on the state changed since last frame
  56165. */
  56166. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  56167. }
  56168. }
  56169. declare module BABYLON {
  56170. /**
  56171. * Defines the WindowsMotionController object that the state of the windows motion controller
  56172. */
  56173. export class WindowsMotionController extends WebVRController {
  56174. /**
  56175. * The base url used to load the left and right controller models
  56176. */
  56177. static MODEL_BASE_URL: string;
  56178. /**
  56179. * The name of the left controller model file
  56180. */
  56181. static MODEL_LEFT_FILENAME: string;
  56182. /**
  56183. * The name of the right controller model file
  56184. */
  56185. static MODEL_RIGHT_FILENAME: string;
  56186. /**
  56187. * The controller name prefix for this controller type
  56188. */
  56189. static readonly GAMEPAD_ID_PREFIX: string;
  56190. /**
  56191. * The controller id pattern for this controller type
  56192. */
  56193. private static readonly GAMEPAD_ID_PATTERN;
  56194. private _loadedMeshInfo;
  56195. protected readonly _mapping: {
  56196. buttons: string[];
  56197. buttonMeshNames: {
  56198. trigger: string;
  56199. menu: string;
  56200. grip: string;
  56201. thumbstick: string;
  56202. trackpad: string;
  56203. };
  56204. buttonObservableNames: {
  56205. trigger: string;
  56206. menu: string;
  56207. grip: string;
  56208. thumbstick: string;
  56209. trackpad: string;
  56210. };
  56211. axisMeshNames: string[];
  56212. pointingPoseMeshName: string;
  56213. };
  56214. /**
  56215. * Fired when the trackpad on this controller is clicked
  56216. */
  56217. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  56218. /**
  56219. * Fired when the trackpad on this controller is modified
  56220. */
  56221. onTrackpadValuesChangedObservable: Observable<StickValues>;
  56222. /**
  56223. * The current x and y values of this controller's trackpad
  56224. */
  56225. trackpad: StickValues;
  56226. /**
  56227. * Creates a new WindowsMotionController from a gamepad
  56228. * @param vrGamepad the gamepad that the controller should be created from
  56229. */
  56230. constructor(vrGamepad: any);
  56231. /**
  56232. * Fired when the trigger on this controller is modified
  56233. */
  56234. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56235. /**
  56236. * Fired when the menu button on this controller is modified
  56237. */
  56238. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56239. /**
  56240. * Fired when the grip button on this controller is modified
  56241. */
  56242. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56243. /**
  56244. * Fired when the thumbstick button on this controller is modified
  56245. */
  56246. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56247. /**
  56248. * Fired when the touchpad button on this controller is modified
  56249. */
  56250. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56251. /**
  56252. * Fired when the touchpad values on this controller are modified
  56253. */
  56254. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  56255. protected _updateTrackpad(): void;
  56256. /**
  56257. * Called once per frame by the engine.
  56258. */
  56259. update(): void;
  56260. /**
  56261. * Called once for each button that changed state since the last frame
  56262. * @param buttonIdx Which button index changed
  56263. * @param state New state of the button
  56264. * @param changes Which properties on the state changed since last frame
  56265. */
  56266. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  56267. /**
  56268. * Moves the buttons on the controller mesh based on their current state
  56269. * @param buttonName the name of the button to move
  56270. * @param buttonValue the value of the button which determines the buttons new position
  56271. */
  56272. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  56273. /**
  56274. * Moves the axis on the controller mesh based on its current state
  56275. * @param axis the index of the axis
  56276. * @param axisValue the value of the axis which determines the meshes new position
  56277. * @hidden
  56278. */
  56279. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  56280. /**
  56281. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  56282. * @param scene scene in which to add meshes
  56283. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  56284. */
  56285. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  56286. /**
  56287. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  56288. * can be transformed by button presses and axes values, based on this._mapping.
  56289. *
  56290. * @param scene scene in which the meshes exist
  56291. * @param meshes list of meshes that make up the controller model to process
  56292. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  56293. */
  56294. private processModel;
  56295. private createMeshInfo;
  56296. /**
  56297. * Gets the ray of the controller in the direction the controller is pointing
  56298. * @param length the length the resulting ray should be
  56299. * @returns a ray in the direction the controller is pointing
  56300. */
  56301. getForwardRay(length?: number): Ray;
  56302. /**
  56303. * Disposes of the controller
  56304. */
  56305. dispose(): void;
  56306. }
  56307. /**
  56308. * This class represents a new windows motion controller in XR.
  56309. */
  56310. export class XRWindowsMotionController extends WindowsMotionController {
  56311. /**
  56312. * Changing the original WIndowsMotionController mapping to fir the new mapping
  56313. */
  56314. protected readonly _mapping: {
  56315. buttons: string[];
  56316. buttonMeshNames: {
  56317. trigger: string;
  56318. menu: string;
  56319. grip: string;
  56320. thumbstick: string;
  56321. trackpad: string;
  56322. };
  56323. buttonObservableNames: {
  56324. trigger: string;
  56325. menu: string;
  56326. grip: string;
  56327. thumbstick: string;
  56328. trackpad: string;
  56329. };
  56330. axisMeshNames: string[];
  56331. pointingPoseMeshName: string;
  56332. };
  56333. /**
  56334. * Construct a new XR-Based windows motion controller
  56335. *
  56336. * @param gamepadInfo the gamepad object from the browser
  56337. */
  56338. constructor(gamepadInfo: any);
  56339. /**
  56340. * holds the thumbstick values (X,Y)
  56341. */
  56342. thumbstickValues: StickValues;
  56343. /**
  56344. * Fired when the thumbstick on this controller is clicked
  56345. */
  56346. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  56347. /**
  56348. * Fired when the thumbstick on this controller is modified
  56349. */
  56350. onThumbstickValuesChangedObservable: Observable<StickValues>;
  56351. /**
  56352. * Fired when the touchpad button on this controller is modified
  56353. */
  56354. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  56355. /**
  56356. * Fired when the touchpad values on this controller are modified
  56357. */
  56358. onTrackpadValuesChangedObservable: Observable<StickValues>;
  56359. /**
  56360. * Fired when the thumbstick button on this controller is modified
  56361. * here to prevent breaking changes
  56362. */
  56363. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  56364. /**
  56365. * updating the thumbstick(!) and not the trackpad.
  56366. * This is named this way due to the difference between WebVR and XR and to avoid
  56367. * changing the parent class.
  56368. */
  56369. protected _updateTrackpad(): void;
  56370. /**
  56371. * Disposes the class with joy
  56372. */
  56373. dispose(): void;
  56374. }
  56375. }
  56376. declare module BABYLON {
  56377. /**
  56378. * Class containing static functions to help procedurally build meshes
  56379. */
  56380. export class PolyhedronBuilder {
  56381. /**
  56382. * Creates a polyhedron mesh
  56383. * * 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
  56384. * * The parameter `size` (positive float, default 1) sets the polygon size
  56385. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  56386. * * 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`
  56387. * * 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
  56388. * * 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)`)
  56389. * * 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
  56390. * * 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
  56391. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56392. * * 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
  56393. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56394. * @param name defines the name of the mesh
  56395. * @param options defines the options used to create the mesh
  56396. * @param scene defines the hosting scene
  56397. * @returns the polyhedron mesh
  56398. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  56399. */
  56400. static CreatePolyhedron(name: string, options: {
  56401. type?: number;
  56402. size?: number;
  56403. sizeX?: number;
  56404. sizeY?: number;
  56405. sizeZ?: number;
  56406. custom?: any;
  56407. faceUV?: Vector4[];
  56408. faceColors?: Color4[];
  56409. flat?: boolean;
  56410. updatable?: boolean;
  56411. sideOrientation?: number;
  56412. frontUVs?: Vector4;
  56413. backUVs?: Vector4;
  56414. }, scene?: Nullable<Scene>): Mesh;
  56415. }
  56416. }
  56417. declare module BABYLON {
  56418. /**
  56419. * Gizmo that enables scaling a mesh along 3 axis
  56420. */
  56421. export class ScaleGizmo extends Gizmo {
  56422. /**
  56423. * Internal gizmo used for interactions on the x axis
  56424. */
  56425. xGizmo: AxisScaleGizmo;
  56426. /**
  56427. * Internal gizmo used for interactions on the y axis
  56428. */
  56429. yGizmo: AxisScaleGizmo;
  56430. /**
  56431. * Internal gizmo used for interactions on the z axis
  56432. */
  56433. zGizmo: AxisScaleGizmo;
  56434. /**
  56435. * Internal gizmo used to scale all axis equally
  56436. */
  56437. uniformScaleGizmo: AxisScaleGizmo;
  56438. private _meshAttached;
  56439. private _nodeAttached;
  56440. private _snapDistance;
  56441. private _uniformScalingMesh;
  56442. private _octahedron;
  56443. private _sensitivity;
  56444. /** Fires an event when any of it's sub gizmos are dragged */
  56445. onDragStartObservable: Observable<unknown>;
  56446. /** Fires an event when any of it's sub gizmos are released from dragging */
  56447. onDragEndObservable: Observable<unknown>;
  56448. get attachedMesh(): Nullable<AbstractMesh>;
  56449. set attachedMesh(mesh: Nullable<AbstractMesh>);
  56450. get attachedNode(): Nullable<Node>;
  56451. set attachedNode(node: Nullable<Node>);
  56452. /**
  56453. * True when the mouse pointer is hovering a gizmo mesh
  56454. */
  56455. get isHovered(): boolean;
  56456. /**
  56457. * Creates a ScaleGizmo
  56458. * @param gizmoLayer The utility layer the gizmo will be added to
  56459. * @param thickness display gizmo axis thickness
  56460. */
  56461. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  56462. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  56463. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  56464. /**
  56465. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  56466. */
  56467. set snapDistance(value: number);
  56468. get snapDistance(): number;
  56469. /**
  56470. * Ratio for the scale of the gizmo (Default: 1)
  56471. */
  56472. set scaleRatio(value: number);
  56473. get scaleRatio(): number;
  56474. /**
  56475. * Sensitivity factor for dragging (Default: 1)
  56476. */
  56477. set sensitivity(value: number);
  56478. get sensitivity(): number;
  56479. /**
  56480. * Disposes of the gizmo
  56481. */
  56482. dispose(): void;
  56483. }
  56484. }
  56485. declare module BABYLON {
  56486. /**
  56487. * Single axis scale gizmo
  56488. */
  56489. export class AxisScaleGizmo extends Gizmo {
  56490. /**
  56491. * Drag behavior responsible for the gizmos dragging interactions
  56492. */
  56493. dragBehavior: PointerDragBehavior;
  56494. private _pointerObserver;
  56495. /**
  56496. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  56497. */
  56498. snapDistance: number;
  56499. /**
  56500. * Event that fires each time the gizmo snaps to a new location.
  56501. * * snapDistance is the the change in distance
  56502. */
  56503. onSnapObservable: Observable<{
  56504. snapDistance: number;
  56505. }>;
  56506. /**
  56507. * If the scaling operation should be done on all axis (default: false)
  56508. */
  56509. uniformScaling: boolean;
  56510. /**
  56511. * Custom sensitivity value for the drag strength
  56512. */
  56513. sensitivity: number;
  56514. private _isEnabled;
  56515. private _parent;
  56516. private _arrow;
  56517. private _coloredMaterial;
  56518. private _hoverMaterial;
  56519. /**
  56520. * Creates an AxisScaleGizmo
  56521. * @param gizmoLayer The utility layer the gizmo will be added to
  56522. * @param dragAxis The axis which the gizmo will be able to scale on
  56523. * @param color The color of the gizmo
  56524. * @param thickness display gizmo axis thickness
  56525. */
  56526. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  56527. protected _attachedNodeChanged(value: Nullable<Node>): void;
  56528. /**
  56529. * If the gizmo is enabled
  56530. */
  56531. set isEnabled(value: boolean);
  56532. get isEnabled(): boolean;
  56533. /**
  56534. * Disposes of the gizmo
  56535. */
  56536. dispose(): void;
  56537. /**
  56538. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  56539. * @param mesh The mesh to replace the default mesh of the gizmo
  56540. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  56541. */
  56542. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  56543. }
  56544. }
  56545. declare module BABYLON {
  56546. /**
  56547. * Bounding box gizmo
  56548. */
  56549. export class BoundingBoxGizmo extends Gizmo {
  56550. private _lineBoundingBox;
  56551. private _rotateSpheresParent;
  56552. private _scaleBoxesParent;
  56553. private _boundingDimensions;
  56554. private _renderObserver;
  56555. private _pointerObserver;
  56556. private _scaleDragSpeed;
  56557. private _tmpQuaternion;
  56558. private _tmpVector;
  56559. private _tmpRotationMatrix;
  56560. /**
  56561. * 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)
  56562. */
  56563. ignoreChildren: boolean;
  56564. /**
  56565. * 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)
  56566. */
  56567. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  56568. /**
  56569. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  56570. */
  56571. rotationSphereSize: number;
  56572. /**
  56573. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  56574. */
  56575. scaleBoxSize: number;
  56576. /**
  56577. * 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)
  56578. */
  56579. fixedDragMeshScreenSize: boolean;
  56580. /**
  56581. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  56582. */
  56583. fixedDragMeshScreenSizeDistanceFactor: number;
  56584. /**
  56585. * Fired when a rotation sphere or scale box is dragged
  56586. */
  56587. onDragStartObservable: Observable<{}>;
  56588. /**
  56589. * Fired when a scale box is dragged
  56590. */
  56591. onScaleBoxDragObservable: Observable<{}>;
  56592. /**
  56593. * Fired when a scale box drag is ended
  56594. */
  56595. onScaleBoxDragEndObservable: Observable<{}>;
  56596. /**
  56597. * Fired when a rotation sphere is dragged
  56598. */
  56599. onRotationSphereDragObservable: Observable<{}>;
  56600. /**
  56601. * Fired when a rotation sphere drag is ended
  56602. */
  56603. onRotationSphereDragEndObservable: Observable<{}>;
  56604. /**
  56605. * 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)
  56606. */
  56607. scalePivot: Nullable<Vector3>;
  56608. /**
  56609. * Mesh used as a pivot to rotate the attached node
  56610. */
  56611. private _anchorMesh;
  56612. private _existingMeshScale;
  56613. private _dragMesh;
  56614. private pointerDragBehavior;
  56615. private coloredMaterial;
  56616. private hoverColoredMaterial;
  56617. /**
  56618. * Sets the color of the bounding box gizmo
  56619. * @param color the color to set
  56620. */
  56621. setColor(color: Color3): void;
  56622. /**
  56623. * Creates an BoundingBoxGizmo
  56624. * @param gizmoLayer The utility layer the gizmo will be added to
  56625. * @param color The color of the gizmo
  56626. */
  56627. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  56628. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  56629. private _selectNode;
  56630. /**
  56631. * Updates the bounding box information for the Gizmo
  56632. */
  56633. updateBoundingBox(): void;
  56634. private _updateRotationSpheres;
  56635. private _updateScaleBoxes;
  56636. /**
  56637. * Enables rotation on the specified axis and disables rotation on the others
  56638. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  56639. */
  56640. setEnabledRotationAxis(axis: string): void;
  56641. /**
  56642. * Enables/disables scaling
  56643. * @param enable if scaling should be enabled
  56644. * @param homogeneousScaling defines if scaling should only be homogeneous
  56645. */
  56646. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  56647. private _updateDummy;
  56648. /**
  56649. * Enables a pointer drag behavior on the bounding box of the gizmo
  56650. */
  56651. enableDragBehavior(): void;
  56652. /**
  56653. * Disposes of the gizmo
  56654. */
  56655. dispose(): void;
  56656. /**
  56657. * 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)
  56658. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  56659. * @returns the bounding box mesh with the passed in mesh as a child
  56660. */
  56661. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  56662. /**
  56663. * CustomMeshes are not supported by this gizmo
  56664. * @param mesh The mesh to replace the default mesh of the gizmo
  56665. */
  56666. setCustomMesh(mesh: Mesh): void;
  56667. }
  56668. }
  56669. declare module BABYLON {
  56670. /**
  56671. * Single plane rotation gizmo
  56672. */
  56673. export class PlaneRotationGizmo extends Gizmo {
  56674. /**
  56675. * Drag behavior responsible for the gizmos dragging interactions
  56676. */
  56677. dragBehavior: PointerDragBehavior;
  56678. private _pointerObserver;
  56679. /**
  56680. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  56681. */
  56682. snapDistance: number;
  56683. /**
  56684. * Event that fires each time the gizmo snaps to a new location.
  56685. * * snapDistance is the the change in distance
  56686. */
  56687. onSnapObservable: Observable<{
  56688. snapDistance: number;
  56689. }>;
  56690. private _isEnabled;
  56691. private _parent;
  56692. /**
  56693. * Creates a PlaneRotationGizmo
  56694. * @param gizmoLayer The utility layer the gizmo will be added to
  56695. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  56696. * @param color The color of the gizmo
  56697. * @param tessellation Amount of tessellation to be used when creating rotation circles
  56698. * @param useEulerRotation Use and update Euler angle instead of quaternion
  56699. * @param thickness display gizmo axis thickness
  56700. */
  56701. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  56702. protected _attachedNodeChanged(value: Nullable<Node>): void;
  56703. /**
  56704. * If the gizmo is enabled
  56705. */
  56706. set isEnabled(value: boolean);
  56707. get isEnabled(): boolean;
  56708. /**
  56709. * Disposes of the gizmo
  56710. */
  56711. dispose(): void;
  56712. }
  56713. }
  56714. declare module BABYLON {
  56715. /**
  56716. * Gizmo that enables rotating a mesh along 3 axis
  56717. */
  56718. export class RotationGizmo extends Gizmo {
  56719. /**
  56720. * Internal gizmo used for interactions on the x axis
  56721. */
  56722. xGizmo: PlaneRotationGizmo;
  56723. /**
  56724. * Internal gizmo used for interactions on the y axis
  56725. */
  56726. yGizmo: PlaneRotationGizmo;
  56727. /**
  56728. * Internal gizmo used for interactions on the z axis
  56729. */
  56730. zGizmo: PlaneRotationGizmo;
  56731. /** Fires an event when any of it's sub gizmos are dragged */
  56732. onDragStartObservable: Observable<unknown>;
  56733. /** Fires an event when any of it's sub gizmos are released from dragging */
  56734. onDragEndObservable: Observable<unknown>;
  56735. private _meshAttached;
  56736. private _nodeAttached;
  56737. get attachedMesh(): Nullable<AbstractMesh>;
  56738. set attachedMesh(mesh: Nullable<AbstractMesh>);
  56739. get attachedNode(): Nullable<Node>;
  56740. set attachedNode(node: Nullable<Node>);
  56741. /**
  56742. * True when the mouse pointer is hovering a gizmo mesh
  56743. */
  56744. get isHovered(): boolean;
  56745. /**
  56746. * Creates a RotationGizmo
  56747. * @param gizmoLayer The utility layer the gizmo will be added to
  56748. * @param tessellation Amount of tessellation to be used when creating rotation circles
  56749. * @param useEulerRotation Use and update Euler angle instead of quaternion
  56750. * @param thickness display gizmo axis thickness
  56751. */
  56752. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  56753. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  56754. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  56755. /**
  56756. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  56757. */
  56758. set snapDistance(value: number);
  56759. get snapDistance(): number;
  56760. /**
  56761. * Ratio for the scale of the gizmo (Default: 1)
  56762. */
  56763. set scaleRatio(value: number);
  56764. get scaleRatio(): number;
  56765. /**
  56766. * Disposes of the gizmo
  56767. */
  56768. dispose(): void;
  56769. /**
  56770. * CustomMeshes are not supported by this gizmo
  56771. * @param mesh The mesh to replace the default mesh of the gizmo
  56772. */
  56773. setCustomMesh(mesh: Mesh): void;
  56774. }
  56775. }
  56776. declare module BABYLON {
  56777. /**
  56778. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  56779. */
  56780. export class GizmoManager implements IDisposable {
  56781. private scene;
  56782. /**
  56783. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  56784. */
  56785. gizmos: {
  56786. positionGizmo: Nullable<PositionGizmo>;
  56787. rotationGizmo: Nullable<RotationGizmo>;
  56788. scaleGizmo: Nullable<ScaleGizmo>;
  56789. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  56790. };
  56791. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  56792. clearGizmoOnEmptyPointerEvent: boolean;
  56793. /** Fires an event when the manager is attached to a mesh */
  56794. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  56795. /** Fires an event when the manager is attached to a node */
  56796. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  56797. private _gizmosEnabled;
  56798. private _pointerObserver;
  56799. private _attachedMesh;
  56800. private _attachedNode;
  56801. private _boundingBoxColor;
  56802. private _defaultUtilityLayer;
  56803. private _defaultKeepDepthUtilityLayer;
  56804. private _thickness;
  56805. /**
  56806. * When bounding box gizmo is enabled, this can be used to track drag/end events
  56807. */
  56808. boundingBoxDragBehavior: SixDofDragBehavior;
  56809. /**
  56810. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  56811. */
  56812. attachableMeshes: Nullable<Array<AbstractMesh>>;
  56813. /**
  56814. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  56815. */
  56816. attachableNodes: Nullable<Array<Node>>;
  56817. /**
  56818. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  56819. */
  56820. usePointerToAttachGizmos: boolean;
  56821. /**
  56822. * Utility layer that the bounding box gizmo belongs to
  56823. */
  56824. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  56825. /**
  56826. * Utility layer that all gizmos besides bounding box belong to
  56827. */
  56828. get utilityLayer(): UtilityLayerRenderer;
  56829. /**
  56830. * True when the mouse pointer is hovering a gizmo mesh
  56831. */
  56832. get isHovered(): boolean;
  56833. /**
  56834. * Instatiates a gizmo manager
  56835. * @param scene the scene to overlay the gizmos on top of
  56836. * @param thickness display gizmo axis thickness
  56837. */
  56838. constructor(scene: Scene, thickness?: number);
  56839. /**
  56840. * Attaches a set of gizmos to the specified mesh
  56841. * @param mesh The mesh the gizmo's should be attached to
  56842. */
  56843. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  56844. /**
  56845. * Attaches a set of gizmos to the specified node
  56846. * @param node The node the gizmo's should be attached to
  56847. */
  56848. attachToNode(node: Nullable<Node>): void;
  56849. /**
  56850. * If the position gizmo is enabled
  56851. */
  56852. set positionGizmoEnabled(value: boolean);
  56853. get positionGizmoEnabled(): boolean;
  56854. /**
  56855. * If the rotation gizmo is enabled
  56856. */
  56857. set rotationGizmoEnabled(value: boolean);
  56858. get rotationGizmoEnabled(): boolean;
  56859. /**
  56860. * If the scale gizmo is enabled
  56861. */
  56862. set scaleGizmoEnabled(value: boolean);
  56863. get scaleGizmoEnabled(): boolean;
  56864. /**
  56865. * If the boundingBox gizmo is enabled
  56866. */
  56867. set boundingBoxGizmoEnabled(value: boolean);
  56868. get boundingBoxGizmoEnabled(): boolean;
  56869. /**
  56870. * Disposes of the gizmo manager
  56871. */
  56872. dispose(): void;
  56873. }
  56874. }
  56875. declare module BABYLON {
  56876. /**
  56877. * A directional light is defined by a direction (what a surprise!).
  56878. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  56879. * 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.
  56880. * Documentation: https://doc.babylonjs.com/babylon101/lights
  56881. */
  56882. export class DirectionalLight extends ShadowLight {
  56883. private _shadowFrustumSize;
  56884. /**
  56885. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  56886. */
  56887. get shadowFrustumSize(): number;
  56888. /**
  56889. * Specifies a fix frustum size for the shadow generation.
  56890. */
  56891. set shadowFrustumSize(value: number);
  56892. private _shadowOrthoScale;
  56893. /**
  56894. * Gets the shadow projection scale against the optimal computed one.
  56895. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  56896. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  56897. */
  56898. get shadowOrthoScale(): number;
  56899. /**
  56900. * Sets the shadow projection scale against the optimal computed one.
  56901. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  56902. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  56903. */
  56904. set shadowOrthoScale(value: number);
  56905. /**
  56906. * Automatically compute the projection matrix to best fit (including all the casters)
  56907. * on each frame.
  56908. */
  56909. autoUpdateExtends: boolean;
  56910. /**
  56911. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  56912. * on each frame. autoUpdateExtends must be set to true for this to work
  56913. */
  56914. autoCalcShadowZBounds: boolean;
  56915. private _orthoLeft;
  56916. private _orthoRight;
  56917. private _orthoTop;
  56918. private _orthoBottom;
  56919. /**
  56920. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  56921. * The directional light is emitted from everywhere in the given direction.
  56922. * It can cast shadows.
  56923. * Documentation : https://doc.babylonjs.com/babylon101/lights
  56924. * @param name The friendly name of the light
  56925. * @param direction The direction of the light
  56926. * @param scene The scene the light belongs to
  56927. */
  56928. constructor(name: string, direction: Vector3, scene: Scene);
  56929. /**
  56930. * Returns the string "DirectionalLight".
  56931. * @return The class name
  56932. */
  56933. getClassName(): string;
  56934. /**
  56935. * Returns the integer 1.
  56936. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  56937. */
  56938. getTypeID(): number;
  56939. /**
  56940. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  56941. * Returns the DirectionalLight Shadow projection matrix.
  56942. */
  56943. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  56944. /**
  56945. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  56946. * Returns the DirectionalLight Shadow projection matrix.
  56947. */
  56948. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  56949. /**
  56950. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  56951. * Returns the DirectionalLight Shadow projection matrix.
  56952. */
  56953. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  56954. protected _buildUniformLayout(): void;
  56955. /**
  56956. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  56957. * @param effect The effect to update
  56958. * @param lightIndex The index of the light in the effect to update
  56959. * @returns The directional light
  56960. */
  56961. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  56962. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  56963. /**
  56964. * Gets the minZ used for shadow according to both the scene and the light.
  56965. *
  56966. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  56967. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  56968. * @param activeCamera The camera we are returning the min for
  56969. * @returns the depth min z
  56970. */
  56971. getDepthMinZ(activeCamera: Camera): number;
  56972. /**
  56973. * Gets the maxZ used for shadow according to both the scene and the light.
  56974. *
  56975. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  56976. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  56977. * @param activeCamera The camera we are returning the max for
  56978. * @returns the depth max z
  56979. */
  56980. getDepthMaxZ(activeCamera: Camera): number;
  56981. /**
  56982. * Prepares the list of defines specific to the light type.
  56983. * @param defines the list of defines
  56984. * @param lightIndex defines the index of the light for the effect
  56985. */
  56986. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  56987. }
  56988. }
  56989. declare module BABYLON {
  56990. /**
  56991. * Class containing static functions to help procedurally build meshes
  56992. */
  56993. export class HemisphereBuilder {
  56994. /**
  56995. * Creates a hemisphere mesh
  56996. * @param name defines the name of the mesh
  56997. * @param options defines the options used to create the mesh
  56998. * @param scene defines the hosting scene
  56999. * @returns the hemisphere mesh
  57000. */
  57001. static CreateHemisphere(name: string, options: {
  57002. segments?: number;
  57003. diameter?: number;
  57004. sideOrientation?: number;
  57005. }, scene: any): Mesh;
  57006. }
  57007. }
  57008. declare module BABYLON {
  57009. /**
  57010. * A spot light is defined by a position, a direction, an angle, and an exponent.
  57011. * These values define a cone of light starting from the position, emitting toward the direction.
  57012. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  57013. * and the exponent defines the speed of the decay of the light with distance (reach).
  57014. * Documentation: https://doc.babylonjs.com/babylon101/lights
  57015. */
  57016. export class SpotLight extends ShadowLight {
  57017. private _angle;
  57018. private _innerAngle;
  57019. private _cosHalfAngle;
  57020. private _lightAngleScale;
  57021. private _lightAngleOffset;
  57022. /**
  57023. * Gets the cone angle of the spot light in Radians.
  57024. */
  57025. get angle(): number;
  57026. /**
  57027. * Sets the cone angle of the spot light in Radians.
  57028. */
  57029. set angle(value: number);
  57030. /**
  57031. * Only used in gltf falloff mode, this defines the angle where
  57032. * the directional falloff will start before cutting at angle which could be seen
  57033. * as outer angle.
  57034. */
  57035. get innerAngle(): number;
  57036. /**
  57037. * Only used in gltf falloff mode, this defines the angle where
  57038. * the directional falloff will start before cutting at angle which could be seen
  57039. * as outer angle.
  57040. */
  57041. set innerAngle(value: number);
  57042. private _shadowAngleScale;
  57043. /**
  57044. * Allows scaling the angle of the light for shadow generation only.
  57045. */
  57046. get shadowAngleScale(): number;
  57047. /**
  57048. * Allows scaling the angle of the light for shadow generation only.
  57049. */
  57050. set shadowAngleScale(value: number);
  57051. /**
  57052. * The light decay speed with the distance from the emission spot.
  57053. */
  57054. exponent: number;
  57055. private _projectionTextureMatrix;
  57056. /**
  57057. * Allows reading the projecton texture
  57058. */
  57059. get projectionTextureMatrix(): Matrix;
  57060. protected _projectionTextureLightNear: number;
  57061. /**
  57062. * Gets the near clip of the Spotlight for texture projection.
  57063. */
  57064. get projectionTextureLightNear(): number;
  57065. /**
  57066. * Sets the near clip of the Spotlight for texture projection.
  57067. */
  57068. set projectionTextureLightNear(value: number);
  57069. protected _projectionTextureLightFar: number;
  57070. /**
  57071. * Gets the far clip of the Spotlight for texture projection.
  57072. */
  57073. get projectionTextureLightFar(): number;
  57074. /**
  57075. * Sets the far clip of the Spotlight for texture projection.
  57076. */
  57077. set projectionTextureLightFar(value: number);
  57078. protected _projectionTextureUpDirection: Vector3;
  57079. /**
  57080. * Gets the Up vector of the Spotlight for texture projection.
  57081. */
  57082. get projectionTextureUpDirection(): Vector3;
  57083. /**
  57084. * Sets the Up vector of the Spotlight for texture projection.
  57085. */
  57086. set projectionTextureUpDirection(value: Vector3);
  57087. private _projectionTexture;
  57088. /**
  57089. * Gets the projection texture of the light.
  57090. */
  57091. get projectionTexture(): Nullable<BaseTexture>;
  57092. /**
  57093. * Sets the projection texture of the light.
  57094. */
  57095. set projectionTexture(value: Nullable<BaseTexture>);
  57096. private _projectionTextureViewLightDirty;
  57097. private _projectionTextureProjectionLightDirty;
  57098. private _projectionTextureDirty;
  57099. private _projectionTextureViewTargetVector;
  57100. private _projectionTextureViewLightMatrix;
  57101. private _projectionTextureProjectionLightMatrix;
  57102. private _projectionTextureScalingMatrix;
  57103. /**
  57104. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  57105. * It can cast shadows.
  57106. * Documentation : https://doc.babylonjs.com/babylon101/lights
  57107. * @param name The light friendly name
  57108. * @param position The position of the spot light in the scene
  57109. * @param direction The direction of the light in the scene
  57110. * @param angle The cone angle of the light in Radians
  57111. * @param exponent The light decay speed with the distance from the emission spot
  57112. * @param scene The scene the lights belongs to
  57113. */
  57114. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  57115. /**
  57116. * Returns the string "SpotLight".
  57117. * @returns the class name
  57118. */
  57119. getClassName(): string;
  57120. /**
  57121. * Returns the integer 2.
  57122. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  57123. */
  57124. getTypeID(): number;
  57125. /**
  57126. * Overrides the direction setter to recompute the projection texture view light Matrix.
  57127. */
  57128. protected _setDirection(value: Vector3): void;
  57129. /**
  57130. * Overrides the position setter to recompute the projection texture view light Matrix.
  57131. */
  57132. protected _setPosition(value: Vector3): void;
  57133. /**
  57134. * 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.
  57135. * Returns the SpotLight.
  57136. */
  57137. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  57138. protected _computeProjectionTextureViewLightMatrix(): void;
  57139. protected _computeProjectionTextureProjectionLightMatrix(): void;
  57140. /**
  57141. * Main function for light texture projection matrix computing.
  57142. */
  57143. protected _computeProjectionTextureMatrix(): void;
  57144. protected _buildUniformLayout(): void;
  57145. private _computeAngleValues;
  57146. /**
  57147. * Sets the passed Effect "effect" with the Light textures.
  57148. * @param effect The effect to update
  57149. * @param lightIndex The index of the light in the effect to update
  57150. * @returns The light
  57151. */
  57152. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  57153. /**
  57154. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  57155. * @param effect The effect to update
  57156. * @param lightIndex The index of the light in the effect to update
  57157. * @returns The spot light
  57158. */
  57159. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  57160. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  57161. /**
  57162. * Disposes the light and the associated resources.
  57163. */
  57164. dispose(): void;
  57165. /**
  57166. * Prepares the list of defines specific to the light type.
  57167. * @param defines the list of defines
  57168. * @param lightIndex defines the index of the light for the effect
  57169. */
  57170. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  57171. }
  57172. }
  57173. declare module BABYLON {
  57174. /**
  57175. * Gizmo that enables viewing a light
  57176. */
  57177. export class LightGizmo extends Gizmo {
  57178. private _lightMesh;
  57179. private _material;
  57180. private _cachedPosition;
  57181. private _cachedForward;
  57182. private _attachedMeshParent;
  57183. private _pointerObserver;
  57184. /**
  57185. * Event that fires each time the gizmo is clicked
  57186. */
  57187. onClickedObservable: Observable<Light>;
  57188. /**
  57189. * Creates a LightGizmo
  57190. * @param gizmoLayer The utility layer the gizmo will be added to
  57191. */
  57192. constructor(gizmoLayer?: UtilityLayerRenderer);
  57193. private _light;
  57194. /**
  57195. * The light that the gizmo is attached to
  57196. */
  57197. set light(light: Nullable<Light>);
  57198. get light(): Nullable<Light>;
  57199. /**
  57200. * Gets the material used to render the light gizmo
  57201. */
  57202. get material(): StandardMaterial;
  57203. /**
  57204. * @hidden
  57205. * Updates the gizmo to match the attached mesh's position/rotation
  57206. */
  57207. protected _update(): void;
  57208. private static _Scale;
  57209. /**
  57210. * Creates the lines for a light mesh
  57211. */
  57212. private static _CreateLightLines;
  57213. /**
  57214. * Disposes of the light gizmo
  57215. */
  57216. dispose(): void;
  57217. private static _CreateHemisphericLightMesh;
  57218. private static _CreatePointLightMesh;
  57219. private static _CreateSpotLightMesh;
  57220. private static _CreateDirectionalLightMesh;
  57221. }
  57222. }
  57223. declare module BABYLON {
  57224. /**
  57225. * Gizmo that enables viewing a camera
  57226. */
  57227. export class CameraGizmo extends Gizmo {
  57228. private _cameraMesh;
  57229. private _cameraLinesMesh;
  57230. private _material;
  57231. private _pointerObserver;
  57232. /**
  57233. * Event that fires each time the gizmo is clicked
  57234. */
  57235. onClickedObservable: Observable<Camera>;
  57236. /**
  57237. * Creates a CameraGizmo
  57238. * @param gizmoLayer The utility layer the gizmo will be added to
  57239. */
  57240. constructor(gizmoLayer?: UtilityLayerRenderer);
  57241. private _camera;
  57242. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  57243. get displayFrustum(): boolean;
  57244. set displayFrustum(value: boolean);
  57245. /**
  57246. * The camera that the gizmo is attached to
  57247. */
  57248. set camera(camera: Nullable<Camera>);
  57249. get camera(): Nullable<Camera>;
  57250. /**
  57251. * Gets the material used to render the camera gizmo
  57252. */
  57253. get material(): StandardMaterial;
  57254. /**
  57255. * @hidden
  57256. * Updates the gizmo to match the attached mesh's position/rotation
  57257. */
  57258. protected _update(): void;
  57259. private static _Scale;
  57260. private _invProjection;
  57261. /**
  57262. * Disposes of the camera gizmo
  57263. */
  57264. dispose(): void;
  57265. private static _CreateCameraMesh;
  57266. private static _CreateCameraFrustum;
  57267. }
  57268. }
  57269. declare module BABYLON {
  57270. /** @hidden */
  57271. export var backgroundFragmentDeclaration: {
  57272. name: string;
  57273. shader: string;
  57274. };
  57275. }
  57276. declare module BABYLON {
  57277. /** @hidden */
  57278. export var backgroundUboDeclaration: {
  57279. name: string;
  57280. shader: string;
  57281. };
  57282. }
  57283. declare module BABYLON {
  57284. /** @hidden */
  57285. export var backgroundPixelShader: {
  57286. name: string;
  57287. shader: string;
  57288. };
  57289. }
  57290. declare module BABYLON {
  57291. /** @hidden */
  57292. export var backgroundVertexDeclaration: {
  57293. name: string;
  57294. shader: string;
  57295. };
  57296. }
  57297. declare module BABYLON {
  57298. /** @hidden */
  57299. export var backgroundVertexShader: {
  57300. name: string;
  57301. shader: string;
  57302. };
  57303. }
  57304. declare module BABYLON {
  57305. /**
  57306. * Background material used to create an efficient environement around your scene.
  57307. */
  57308. export class BackgroundMaterial extends PushMaterial {
  57309. /**
  57310. * Standard reflectance value at parallel view angle.
  57311. */
  57312. static StandardReflectance0: number;
  57313. /**
  57314. * Standard reflectance value at grazing angle.
  57315. */
  57316. static StandardReflectance90: number;
  57317. protected _primaryColor: Color3;
  57318. /**
  57319. * Key light Color (multiply against the environement texture)
  57320. */
  57321. primaryColor: Color3;
  57322. protected __perceptualColor: Nullable<Color3>;
  57323. /**
  57324. * Experimental Internal Use Only.
  57325. *
  57326. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  57327. * This acts as a helper to set the primary color to a more "human friendly" value.
  57328. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  57329. * output color as close as possible from the chosen value.
  57330. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  57331. * part of lighting setup.)
  57332. */
  57333. get _perceptualColor(): Nullable<Color3>;
  57334. set _perceptualColor(value: Nullable<Color3>);
  57335. protected _primaryColorShadowLevel: float;
  57336. /**
  57337. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  57338. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  57339. */
  57340. get primaryColorShadowLevel(): float;
  57341. set primaryColorShadowLevel(value: float);
  57342. protected _primaryColorHighlightLevel: float;
  57343. /**
  57344. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  57345. * The primary color is used at the level chosen to define what the white area would look.
  57346. */
  57347. get primaryColorHighlightLevel(): float;
  57348. set primaryColorHighlightLevel(value: float);
  57349. protected _reflectionTexture: Nullable<BaseTexture>;
  57350. /**
  57351. * Reflection Texture used in the material.
  57352. * Should be author in a specific way for the best result (refer to the documentation).
  57353. */
  57354. reflectionTexture: Nullable<BaseTexture>;
  57355. protected _reflectionBlur: float;
  57356. /**
  57357. * Reflection Texture level of blur.
  57358. *
  57359. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  57360. * texture twice.
  57361. */
  57362. reflectionBlur: float;
  57363. protected _diffuseTexture: Nullable<BaseTexture>;
  57364. /**
  57365. * Diffuse Texture used in the material.
  57366. * Should be author in a specific way for the best result (refer to the documentation).
  57367. */
  57368. diffuseTexture: Nullable<BaseTexture>;
  57369. protected _shadowLights: Nullable<IShadowLight[]>;
  57370. /**
  57371. * Specify the list of lights casting shadow on the material.
  57372. * All scene shadow lights will be included if null.
  57373. */
  57374. shadowLights: Nullable<IShadowLight[]>;
  57375. protected _shadowLevel: float;
  57376. /**
  57377. * Helps adjusting the shadow to a softer level if required.
  57378. * 0 means black shadows and 1 means no shadows.
  57379. */
  57380. shadowLevel: float;
  57381. protected _sceneCenter: Vector3;
  57382. /**
  57383. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  57384. * It is usually zero but might be interesting to modify according to your setup.
  57385. */
  57386. sceneCenter: Vector3;
  57387. protected _opacityFresnel: boolean;
  57388. /**
  57389. * This helps specifying that the material is falling off to the sky box at grazing angle.
  57390. * This helps ensuring a nice transition when the camera goes under the ground.
  57391. */
  57392. opacityFresnel: boolean;
  57393. protected _reflectionFresnel: boolean;
  57394. /**
  57395. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  57396. * This helps adding a mirror texture on the ground.
  57397. */
  57398. reflectionFresnel: boolean;
  57399. protected _reflectionFalloffDistance: number;
  57400. /**
  57401. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  57402. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  57403. */
  57404. reflectionFalloffDistance: number;
  57405. protected _reflectionAmount: number;
  57406. /**
  57407. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  57408. */
  57409. reflectionAmount: number;
  57410. protected _reflectionReflectance0: number;
  57411. /**
  57412. * This specifies the weight of the reflection at grazing angle.
  57413. */
  57414. reflectionReflectance0: number;
  57415. protected _reflectionReflectance90: number;
  57416. /**
  57417. * This specifies the weight of the reflection at a perpendicular point of view.
  57418. */
  57419. reflectionReflectance90: number;
  57420. /**
  57421. * Sets the reflection reflectance fresnel values according to the default standard
  57422. * empirically know to work well :-)
  57423. */
  57424. set reflectionStandardFresnelWeight(value: number);
  57425. protected _useRGBColor: boolean;
  57426. /**
  57427. * Helps to directly use the maps channels instead of their level.
  57428. */
  57429. useRGBColor: boolean;
  57430. protected _enableNoise: boolean;
  57431. /**
  57432. * This helps reducing the banding effect that could occur on the background.
  57433. */
  57434. enableNoise: boolean;
  57435. /**
  57436. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  57437. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  57438. * Recommended to be keep at 1.0 except for special cases.
  57439. */
  57440. get fovMultiplier(): number;
  57441. set fovMultiplier(value: number);
  57442. private _fovMultiplier;
  57443. /**
  57444. * Enable the FOV adjustment feature controlled by fovMultiplier.
  57445. */
  57446. useEquirectangularFOV: boolean;
  57447. private _maxSimultaneousLights;
  57448. /**
  57449. * Number of Simultaneous lights allowed on the material.
  57450. */
  57451. maxSimultaneousLights: int;
  57452. private _shadowOnly;
  57453. /**
  57454. * Make the material only render shadows
  57455. */
  57456. shadowOnly: boolean;
  57457. /**
  57458. * Default configuration related to image processing available in the Background Material.
  57459. */
  57460. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  57461. /**
  57462. * Keep track of the image processing observer to allow dispose and replace.
  57463. */
  57464. private _imageProcessingObserver;
  57465. /**
  57466. * Attaches a new image processing configuration to the PBR Material.
  57467. * @param configuration (if null the scene configuration will be use)
  57468. */
  57469. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  57470. /**
  57471. * Gets the image processing configuration used either in this material.
  57472. */
  57473. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  57474. /**
  57475. * Sets the Default image processing configuration used either in the this material.
  57476. *
  57477. * If sets to null, the scene one is in use.
  57478. */
  57479. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  57480. /**
  57481. * Gets wether the color curves effect is enabled.
  57482. */
  57483. get cameraColorCurvesEnabled(): boolean;
  57484. /**
  57485. * Sets wether the color curves effect is enabled.
  57486. */
  57487. set cameraColorCurvesEnabled(value: boolean);
  57488. /**
  57489. * Gets wether the color grading effect is enabled.
  57490. */
  57491. get cameraColorGradingEnabled(): boolean;
  57492. /**
  57493. * Gets wether the color grading effect is enabled.
  57494. */
  57495. set cameraColorGradingEnabled(value: boolean);
  57496. /**
  57497. * Gets wether tonemapping is enabled or not.
  57498. */
  57499. get cameraToneMappingEnabled(): boolean;
  57500. /**
  57501. * Sets wether tonemapping is enabled or not
  57502. */
  57503. set cameraToneMappingEnabled(value: boolean);
  57504. /**
  57505. * The camera exposure used on this material.
  57506. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  57507. * This corresponds to a photographic exposure.
  57508. */
  57509. get cameraExposure(): float;
  57510. /**
  57511. * The camera exposure used on this material.
  57512. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  57513. * This corresponds to a photographic exposure.
  57514. */
  57515. set cameraExposure(value: float);
  57516. /**
  57517. * Gets The camera contrast used on this material.
  57518. */
  57519. get cameraContrast(): float;
  57520. /**
  57521. * Sets The camera contrast used on this material.
  57522. */
  57523. set cameraContrast(value: float);
  57524. /**
  57525. * Gets the Color Grading 2D Lookup Texture.
  57526. */
  57527. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  57528. /**
  57529. * Sets the Color Grading 2D Lookup Texture.
  57530. */
  57531. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  57532. /**
  57533. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  57534. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  57535. * 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;
  57536. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  57537. */
  57538. get cameraColorCurves(): Nullable<ColorCurves>;
  57539. /**
  57540. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  57541. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  57542. * 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;
  57543. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  57544. */
  57545. set cameraColorCurves(value: Nullable<ColorCurves>);
  57546. /**
  57547. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  57548. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  57549. */
  57550. switchToBGR: boolean;
  57551. private _renderTargets;
  57552. private _reflectionControls;
  57553. private _white;
  57554. private _primaryShadowColor;
  57555. private _primaryHighlightColor;
  57556. /**
  57557. * Instantiates a Background Material in the given scene
  57558. * @param name The friendly name of the material
  57559. * @param scene The scene to add the material to
  57560. */
  57561. constructor(name: string, scene: Scene);
  57562. /**
  57563. * Gets a boolean indicating that current material needs to register RTT
  57564. */
  57565. get hasRenderTargetTextures(): boolean;
  57566. /**
  57567. * The entire material has been created in order to prevent overdraw.
  57568. * @returns false
  57569. */
  57570. needAlphaTesting(): boolean;
  57571. /**
  57572. * The entire material has been created in order to prevent overdraw.
  57573. * @returns true if blending is enable
  57574. */
  57575. needAlphaBlending(): boolean;
  57576. /**
  57577. * Checks wether the material is ready to be rendered for a given mesh.
  57578. * @param mesh The mesh to render
  57579. * @param subMesh The submesh to check against
  57580. * @param useInstances Specify wether or not the material is used with instances
  57581. * @returns true if all the dependencies are ready (Textures, Effects...)
  57582. */
  57583. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  57584. /**
  57585. * Compute the primary color according to the chosen perceptual color.
  57586. */
  57587. private _computePrimaryColorFromPerceptualColor;
  57588. /**
  57589. * Compute the highlights and shadow colors according to their chosen levels.
  57590. */
  57591. private _computePrimaryColors;
  57592. /**
  57593. * Build the uniform buffer used in the material.
  57594. */
  57595. buildUniformLayout(): void;
  57596. /**
  57597. * Unbind the material.
  57598. */
  57599. unbind(): void;
  57600. /**
  57601. * Bind only the world matrix to the material.
  57602. * @param world The world matrix to bind.
  57603. */
  57604. bindOnlyWorldMatrix(world: Matrix): void;
  57605. /**
  57606. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  57607. * @param world The world matrix to bind.
  57608. * @param subMesh The submesh to bind for.
  57609. */
  57610. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  57611. /**
  57612. * Checks to see if a texture is used in the material.
  57613. * @param texture - Base texture to use.
  57614. * @returns - Boolean specifying if a texture is used in the material.
  57615. */
  57616. hasTexture(texture: BaseTexture): boolean;
  57617. /**
  57618. * Dispose the material.
  57619. * @param forceDisposeEffect Force disposal of the associated effect.
  57620. * @param forceDisposeTextures Force disposal of the associated textures.
  57621. */
  57622. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  57623. /**
  57624. * Clones the material.
  57625. * @param name The cloned name.
  57626. * @returns The cloned material.
  57627. */
  57628. clone(name: string): BackgroundMaterial;
  57629. /**
  57630. * Serializes the current material to its JSON representation.
  57631. * @returns The JSON representation.
  57632. */
  57633. serialize(): any;
  57634. /**
  57635. * Gets the class name of the material
  57636. * @returns "BackgroundMaterial"
  57637. */
  57638. getClassName(): string;
  57639. /**
  57640. * Parse a JSON input to create back a background material.
  57641. * @param source The JSON data to parse
  57642. * @param scene The scene to create the parsed material in
  57643. * @param rootUrl The root url of the assets the material depends upon
  57644. * @returns the instantiated BackgroundMaterial.
  57645. */
  57646. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  57647. }
  57648. }
  57649. declare module BABYLON {
  57650. /**
  57651. * Represents the different options available during the creation of
  57652. * a Environment helper.
  57653. *
  57654. * This can control the default ground, skybox and image processing setup of your scene.
  57655. */
  57656. export interface IEnvironmentHelperOptions {
  57657. /**
  57658. * Specifies whether or not to create a ground.
  57659. * True by default.
  57660. */
  57661. createGround: boolean;
  57662. /**
  57663. * Specifies the ground size.
  57664. * 15 by default.
  57665. */
  57666. groundSize: number;
  57667. /**
  57668. * The texture used on the ground for the main color.
  57669. * Comes from the BabylonJS CDN by default.
  57670. *
  57671. * Remarks: Can be either a texture or a url.
  57672. */
  57673. groundTexture: string | BaseTexture;
  57674. /**
  57675. * The color mixed in the ground texture by default.
  57676. * BabylonJS clearColor by default.
  57677. */
  57678. groundColor: Color3;
  57679. /**
  57680. * Specifies the ground opacity.
  57681. * 1 by default.
  57682. */
  57683. groundOpacity: number;
  57684. /**
  57685. * Enables the ground to receive shadows.
  57686. * True by default.
  57687. */
  57688. enableGroundShadow: boolean;
  57689. /**
  57690. * Helps preventing the shadow to be fully black on the ground.
  57691. * 0.5 by default.
  57692. */
  57693. groundShadowLevel: number;
  57694. /**
  57695. * Creates a mirror texture attach to the ground.
  57696. * false by default.
  57697. */
  57698. enableGroundMirror: boolean;
  57699. /**
  57700. * Specifies the ground mirror size ratio.
  57701. * 0.3 by default as the default kernel is 64.
  57702. */
  57703. groundMirrorSizeRatio: number;
  57704. /**
  57705. * Specifies the ground mirror blur kernel size.
  57706. * 64 by default.
  57707. */
  57708. groundMirrorBlurKernel: number;
  57709. /**
  57710. * Specifies the ground mirror visibility amount.
  57711. * 1 by default
  57712. */
  57713. groundMirrorAmount: number;
  57714. /**
  57715. * Specifies the ground mirror reflectance weight.
  57716. * This uses the standard weight of the background material to setup the fresnel effect
  57717. * of the mirror.
  57718. * 1 by default.
  57719. */
  57720. groundMirrorFresnelWeight: number;
  57721. /**
  57722. * Specifies the ground mirror Falloff distance.
  57723. * This can helps reducing the size of the reflection.
  57724. * 0 by Default.
  57725. */
  57726. groundMirrorFallOffDistance: number;
  57727. /**
  57728. * Specifies the ground mirror texture type.
  57729. * Unsigned Int by Default.
  57730. */
  57731. groundMirrorTextureType: number;
  57732. /**
  57733. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  57734. * the shown objects.
  57735. */
  57736. groundYBias: number;
  57737. /**
  57738. * Specifies whether or not to create a skybox.
  57739. * True by default.
  57740. */
  57741. createSkybox: boolean;
  57742. /**
  57743. * Specifies the skybox size.
  57744. * 20 by default.
  57745. */
  57746. skyboxSize: number;
  57747. /**
  57748. * The texture used on the skybox for the main color.
  57749. * Comes from the BabylonJS CDN by default.
  57750. *
  57751. * Remarks: Can be either a texture or a url.
  57752. */
  57753. skyboxTexture: string | BaseTexture;
  57754. /**
  57755. * The color mixed in the skybox texture by default.
  57756. * BabylonJS clearColor by default.
  57757. */
  57758. skyboxColor: Color3;
  57759. /**
  57760. * The background rotation around the Y axis of the scene.
  57761. * This helps aligning the key lights of your scene with the background.
  57762. * 0 by default.
  57763. */
  57764. backgroundYRotation: number;
  57765. /**
  57766. * Compute automatically the size of the elements to best fit with the scene.
  57767. */
  57768. sizeAuto: boolean;
  57769. /**
  57770. * Default position of the rootMesh if autoSize is not true.
  57771. */
  57772. rootPosition: Vector3;
  57773. /**
  57774. * Sets up the image processing in the scene.
  57775. * true by default.
  57776. */
  57777. setupImageProcessing: boolean;
  57778. /**
  57779. * The texture used as your environment texture in the scene.
  57780. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  57781. *
  57782. * Remarks: Can be either a texture or a url.
  57783. */
  57784. environmentTexture: string | BaseTexture;
  57785. /**
  57786. * The value of the exposure to apply to the scene.
  57787. * 0.6 by default if setupImageProcessing is true.
  57788. */
  57789. cameraExposure: number;
  57790. /**
  57791. * The value of the contrast to apply to the scene.
  57792. * 1.6 by default if setupImageProcessing is true.
  57793. */
  57794. cameraContrast: number;
  57795. /**
  57796. * Specifies whether or not tonemapping should be enabled in the scene.
  57797. * true by default if setupImageProcessing is true.
  57798. */
  57799. toneMappingEnabled: boolean;
  57800. }
  57801. /**
  57802. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  57803. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  57804. * It also helps with the default setup of your imageProcessing configuration.
  57805. */
  57806. export class EnvironmentHelper {
  57807. /**
  57808. * Default ground texture URL.
  57809. */
  57810. private static _groundTextureCDNUrl;
  57811. /**
  57812. * Default skybox texture URL.
  57813. */
  57814. private static _skyboxTextureCDNUrl;
  57815. /**
  57816. * Default environment texture URL.
  57817. */
  57818. private static _environmentTextureCDNUrl;
  57819. /**
  57820. * Creates the default options for the helper.
  57821. */
  57822. private static _getDefaultOptions;
  57823. private _rootMesh;
  57824. /**
  57825. * Gets the root mesh created by the helper.
  57826. */
  57827. get rootMesh(): Mesh;
  57828. private _skybox;
  57829. /**
  57830. * Gets the skybox created by the helper.
  57831. */
  57832. get skybox(): Nullable<Mesh>;
  57833. private _skyboxTexture;
  57834. /**
  57835. * Gets the skybox texture created by the helper.
  57836. */
  57837. get skyboxTexture(): Nullable<BaseTexture>;
  57838. private _skyboxMaterial;
  57839. /**
  57840. * Gets the skybox material created by the helper.
  57841. */
  57842. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  57843. private _ground;
  57844. /**
  57845. * Gets the ground mesh created by the helper.
  57846. */
  57847. get ground(): Nullable<Mesh>;
  57848. private _groundTexture;
  57849. /**
  57850. * Gets the ground texture created by the helper.
  57851. */
  57852. get groundTexture(): Nullable<BaseTexture>;
  57853. private _groundMirror;
  57854. /**
  57855. * Gets the ground mirror created by the helper.
  57856. */
  57857. get groundMirror(): Nullable<MirrorTexture>;
  57858. /**
  57859. * Gets the ground mirror render list to helps pushing the meshes
  57860. * you wish in the ground reflection.
  57861. */
  57862. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  57863. private _groundMaterial;
  57864. /**
  57865. * Gets the ground material created by the helper.
  57866. */
  57867. get groundMaterial(): Nullable<BackgroundMaterial>;
  57868. /**
  57869. * Stores the creation options.
  57870. */
  57871. private readonly _scene;
  57872. private _options;
  57873. /**
  57874. * This observable will be notified with any error during the creation of the environment,
  57875. * mainly texture creation errors.
  57876. */
  57877. onErrorObservable: Observable<{
  57878. message?: string;
  57879. exception?: any;
  57880. }>;
  57881. /**
  57882. * constructor
  57883. * @param options Defines the options we want to customize the helper
  57884. * @param scene The scene to add the material to
  57885. */
  57886. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  57887. /**
  57888. * Updates the background according to the new options
  57889. * @param options
  57890. */
  57891. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  57892. /**
  57893. * Sets the primary color of all the available elements.
  57894. * @param color the main color to affect to the ground and the background
  57895. */
  57896. setMainColor(color: Color3): void;
  57897. /**
  57898. * Setup the image processing according to the specified options.
  57899. */
  57900. private _setupImageProcessing;
  57901. /**
  57902. * Setup the environment texture according to the specified options.
  57903. */
  57904. private _setupEnvironmentTexture;
  57905. /**
  57906. * Setup the background according to the specified options.
  57907. */
  57908. private _setupBackground;
  57909. /**
  57910. * Get the scene sizes according to the setup.
  57911. */
  57912. private _getSceneSize;
  57913. /**
  57914. * Setup the ground according to the specified options.
  57915. */
  57916. private _setupGround;
  57917. /**
  57918. * Setup the ground material according to the specified options.
  57919. */
  57920. private _setupGroundMaterial;
  57921. /**
  57922. * Setup the ground diffuse texture according to the specified options.
  57923. */
  57924. private _setupGroundDiffuseTexture;
  57925. /**
  57926. * Setup the ground mirror texture according to the specified options.
  57927. */
  57928. private _setupGroundMirrorTexture;
  57929. /**
  57930. * Setup the ground to receive the mirror texture.
  57931. */
  57932. private _setupMirrorInGroundMaterial;
  57933. /**
  57934. * Setup the skybox according to the specified options.
  57935. */
  57936. private _setupSkybox;
  57937. /**
  57938. * Setup the skybox material according to the specified options.
  57939. */
  57940. private _setupSkyboxMaterial;
  57941. /**
  57942. * Setup the skybox reflection texture according to the specified options.
  57943. */
  57944. private _setupSkyboxReflectionTexture;
  57945. private _errorHandler;
  57946. /**
  57947. * Dispose all the elements created by the Helper.
  57948. */
  57949. dispose(): void;
  57950. }
  57951. }
  57952. declare module BABYLON {
  57953. /**
  57954. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  57955. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  57956. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  57957. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  57958. */
  57959. export abstract class TextureDome<T extends Texture> extends TransformNode {
  57960. protected onError: Nullable<(message?: string, exception?: any) => void>;
  57961. /**
  57962. * Define the source as a Monoscopic panoramic 360/180.
  57963. */
  57964. static readonly MODE_MONOSCOPIC: number;
  57965. /**
  57966. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  57967. */
  57968. static readonly MODE_TOPBOTTOM: number;
  57969. /**
  57970. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  57971. */
  57972. static readonly MODE_SIDEBYSIDE: number;
  57973. private _halfDome;
  57974. private _crossEye;
  57975. protected _useDirectMapping: boolean;
  57976. /**
  57977. * The texture being displayed on the sphere
  57978. */
  57979. protected _texture: T;
  57980. /**
  57981. * Gets the texture being displayed on the sphere
  57982. */
  57983. get texture(): T;
  57984. /**
  57985. * Sets the texture being displayed on the sphere
  57986. */
  57987. set texture(newTexture: T);
  57988. /**
  57989. * The skybox material
  57990. */
  57991. protected _material: BackgroundMaterial;
  57992. /**
  57993. * The surface used for the dome
  57994. */
  57995. protected _mesh: Mesh;
  57996. /**
  57997. * Gets the mesh used for the dome.
  57998. */
  57999. get mesh(): Mesh;
  58000. /**
  58001. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  58002. */
  58003. private _halfDomeMask;
  58004. /**
  58005. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  58006. * Also see the options.resolution property.
  58007. */
  58008. get fovMultiplier(): number;
  58009. set fovMultiplier(value: number);
  58010. protected _textureMode: number;
  58011. /**
  58012. * Gets or set the current texture mode for the texture. It can be:
  58013. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  58014. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  58015. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  58016. */
  58017. get textureMode(): number;
  58018. /**
  58019. * Sets the current texture mode for the texture. It can be:
  58020. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  58021. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  58022. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  58023. */
  58024. set textureMode(value: number);
  58025. /**
  58026. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  58027. */
  58028. get halfDome(): boolean;
  58029. /**
  58030. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  58031. */
  58032. set halfDome(enabled: boolean);
  58033. /**
  58034. * Set the cross-eye mode. If set, images that can be seen when crossing eyes will render correctly
  58035. */
  58036. set crossEye(enabled: boolean);
  58037. /**
  58038. * Is it a cross-eye texture?
  58039. */
  58040. get crossEye(): boolean;
  58041. /**
  58042. * Oberserver used in Stereoscopic VR Mode.
  58043. */
  58044. private _onBeforeCameraRenderObserver;
  58045. /**
  58046. * Observable raised when an error occured while loading the 360 image
  58047. */
  58048. onLoadErrorObservable: Observable<string>;
  58049. /**
  58050. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  58051. * @param name Element's name, child elements will append suffixes for their own names.
  58052. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  58053. * @param options An object containing optional or exposed sub element properties
  58054. */
  58055. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  58056. resolution?: number;
  58057. clickToPlay?: boolean;
  58058. autoPlay?: boolean;
  58059. loop?: boolean;
  58060. size?: number;
  58061. poster?: string;
  58062. faceForward?: boolean;
  58063. useDirectMapping?: boolean;
  58064. halfDomeMode?: boolean;
  58065. crossEyeMode?: boolean;
  58066. generateMipMaps?: boolean;
  58067. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  58068. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  58069. protected _changeTextureMode(value: number): void;
  58070. /**
  58071. * Releases resources associated with this node.
  58072. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  58073. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  58074. */
  58075. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  58076. }
  58077. }
  58078. declare module BABYLON {
  58079. /**
  58080. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  58081. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  58082. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  58083. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  58084. */
  58085. export class PhotoDome extends TextureDome<Texture> {
  58086. /**
  58087. * Define the image as a Monoscopic panoramic 360 image.
  58088. */
  58089. static readonly MODE_MONOSCOPIC: number;
  58090. /**
  58091. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  58092. */
  58093. static readonly MODE_TOPBOTTOM: number;
  58094. /**
  58095. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  58096. */
  58097. static readonly MODE_SIDEBYSIDE: number;
  58098. /**
  58099. * Gets or sets the texture being displayed on the sphere
  58100. */
  58101. get photoTexture(): Texture;
  58102. /**
  58103. * sets the texture being displayed on the sphere
  58104. */
  58105. set photoTexture(value: Texture);
  58106. /**
  58107. * Gets the current video mode for the video. It can be:
  58108. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  58109. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  58110. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  58111. */
  58112. get imageMode(): number;
  58113. /**
  58114. * Sets the current video mode for the video. It can be:
  58115. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  58116. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  58117. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  58118. */
  58119. set imageMode(value: number);
  58120. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  58121. }
  58122. }
  58123. declare module BABYLON {
  58124. /**
  58125. * Direct draw surface info
  58126. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  58127. */
  58128. export interface DDSInfo {
  58129. /**
  58130. * Width of the texture
  58131. */
  58132. width: number;
  58133. /**
  58134. * Width of the texture
  58135. */
  58136. height: number;
  58137. /**
  58138. * Number of Mipmaps for the texture
  58139. * @see https://en.wikipedia.org/wiki/Mipmap
  58140. */
  58141. mipmapCount: number;
  58142. /**
  58143. * If the textures format is a known fourCC format
  58144. * @see https://www.fourcc.org/
  58145. */
  58146. isFourCC: boolean;
  58147. /**
  58148. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  58149. */
  58150. isRGB: boolean;
  58151. /**
  58152. * If the texture is a lumincance format
  58153. */
  58154. isLuminance: boolean;
  58155. /**
  58156. * If this is a cube texture
  58157. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  58158. */
  58159. isCube: boolean;
  58160. /**
  58161. * If the texture is a compressed format eg. FOURCC_DXT1
  58162. */
  58163. isCompressed: boolean;
  58164. /**
  58165. * The dxgiFormat of the texture
  58166. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  58167. */
  58168. dxgiFormat: number;
  58169. /**
  58170. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  58171. */
  58172. textureType: number;
  58173. /**
  58174. * Sphericle polynomial created for the dds texture
  58175. */
  58176. sphericalPolynomial?: SphericalPolynomial;
  58177. }
  58178. /**
  58179. * Class used to provide DDS decompression tools
  58180. */
  58181. export class DDSTools {
  58182. /**
  58183. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  58184. */
  58185. static StoreLODInAlphaChannel: boolean;
  58186. /**
  58187. * Gets DDS information from an array buffer
  58188. * @param data defines the array buffer view to read data from
  58189. * @returns the DDS information
  58190. */
  58191. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  58192. private static _FloatView;
  58193. private static _Int32View;
  58194. private static _ToHalfFloat;
  58195. private static _FromHalfFloat;
  58196. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  58197. private static _GetHalfFloatRGBAArrayBuffer;
  58198. private static _GetFloatRGBAArrayBuffer;
  58199. private static _GetFloatAsUIntRGBAArrayBuffer;
  58200. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  58201. private static _GetRGBAArrayBuffer;
  58202. private static _ExtractLongWordOrder;
  58203. private static _GetRGBArrayBuffer;
  58204. private static _GetLuminanceArrayBuffer;
  58205. /**
  58206. * Uploads DDS Levels to a Babylon Texture
  58207. * @hidden
  58208. */
  58209. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  58210. }
  58211. interface ThinEngine {
  58212. /**
  58213. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  58214. * @param rootUrl defines the url where the file to load is located
  58215. * @param scene defines the current scene
  58216. * @param lodScale defines scale to apply to the mip map selection
  58217. * @param lodOffset defines offset to apply to the mip map selection
  58218. * @param onLoad defines an optional callback raised when the texture is loaded
  58219. * @param onError defines an optional callback raised if there is an issue to load the texture
  58220. * @param format defines the format of the data
  58221. * @param forcedExtension defines the extension to use to pick the right loader
  58222. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  58223. * @returns the cube texture as an InternalTexture
  58224. */
  58225. 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;
  58226. }
  58227. }
  58228. declare module BABYLON {
  58229. /**
  58230. * Implementation of the DDS Texture Loader.
  58231. * @hidden
  58232. */
  58233. export class _DDSTextureLoader implements IInternalTextureLoader {
  58234. /**
  58235. * Defines wether the loader supports cascade loading the different faces.
  58236. */
  58237. readonly supportCascades: boolean;
  58238. /**
  58239. * This returns if the loader support the current file information.
  58240. * @param extension defines the file extension of the file being loaded
  58241. * @returns true if the loader can load the specified file
  58242. */
  58243. canLoad(extension: string): boolean;
  58244. /**
  58245. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58246. * @param data contains the texture data
  58247. * @param texture defines the BabylonJS internal texture
  58248. * @param createPolynomials will be true if polynomials have been requested
  58249. * @param onLoad defines the callback to trigger once the texture is ready
  58250. * @param onError defines the callback to trigger in case of error
  58251. */
  58252. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58253. /**
  58254. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58255. * @param data contains the texture data
  58256. * @param texture defines the BabylonJS internal texture
  58257. * @param callback defines the method to call once ready to upload
  58258. */
  58259. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58260. }
  58261. }
  58262. declare module BABYLON {
  58263. /**
  58264. * Implementation of the ENV Texture Loader.
  58265. * @hidden
  58266. */
  58267. export class _ENVTextureLoader implements IInternalTextureLoader {
  58268. /**
  58269. * Defines wether the loader supports cascade loading the different faces.
  58270. */
  58271. readonly supportCascades: boolean;
  58272. /**
  58273. * This returns if the loader support the current file information.
  58274. * @param extension defines the file extension of the file being loaded
  58275. * @returns true if the loader can load the specified file
  58276. */
  58277. canLoad(extension: string): boolean;
  58278. /**
  58279. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58280. * @param data contains the texture data
  58281. * @param texture defines the BabylonJS internal texture
  58282. * @param createPolynomials will be true if polynomials have been requested
  58283. * @param onLoad defines the callback to trigger once the texture is ready
  58284. * @param onError defines the callback to trigger in case of error
  58285. */
  58286. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58287. /**
  58288. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58289. * @param data contains the texture data
  58290. * @param texture defines the BabylonJS internal texture
  58291. * @param callback defines the method to call once ready to upload
  58292. */
  58293. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  58294. }
  58295. }
  58296. declare module BABYLON {
  58297. /**
  58298. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  58299. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  58300. */
  58301. export class KhronosTextureContainer {
  58302. /** contents of the KTX container file */
  58303. data: ArrayBufferView;
  58304. private static HEADER_LEN;
  58305. private static COMPRESSED_2D;
  58306. private static COMPRESSED_3D;
  58307. private static TEX_2D;
  58308. private static TEX_3D;
  58309. /**
  58310. * Gets the openGL type
  58311. */
  58312. glType: number;
  58313. /**
  58314. * Gets the openGL type size
  58315. */
  58316. glTypeSize: number;
  58317. /**
  58318. * Gets the openGL format
  58319. */
  58320. glFormat: number;
  58321. /**
  58322. * Gets the openGL internal format
  58323. */
  58324. glInternalFormat: number;
  58325. /**
  58326. * Gets the base internal format
  58327. */
  58328. glBaseInternalFormat: number;
  58329. /**
  58330. * Gets image width in pixel
  58331. */
  58332. pixelWidth: number;
  58333. /**
  58334. * Gets image height in pixel
  58335. */
  58336. pixelHeight: number;
  58337. /**
  58338. * Gets image depth in pixels
  58339. */
  58340. pixelDepth: number;
  58341. /**
  58342. * Gets the number of array elements
  58343. */
  58344. numberOfArrayElements: number;
  58345. /**
  58346. * Gets the number of faces
  58347. */
  58348. numberOfFaces: number;
  58349. /**
  58350. * Gets the number of mipmap levels
  58351. */
  58352. numberOfMipmapLevels: number;
  58353. /**
  58354. * Gets the bytes of key value data
  58355. */
  58356. bytesOfKeyValueData: number;
  58357. /**
  58358. * Gets the load type
  58359. */
  58360. loadType: number;
  58361. /**
  58362. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  58363. */
  58364. isInvalid: boolean;
  58365. /**
  58366. * Creates a new KhronosTextureContainer
  58367. * @param data contents of the KTX container file
  58368. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  58369. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  58370. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  58371. */
  58372. constructor(
  58373. /** contents of the KTX container file */
  58374. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  58375. /**
  58376. * Uploads KTX content to a Babylon Texture.
  58377. * It is assumed that the texture has already been created & is currently bound
  58378. * @hidden
  58379. */
  58380. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  58381. private _upload2DCompressedLevels;
  58382. /**
  58383. * Checks if the given data starts with a KTX file identifier.
  58384. * @param data the data to check
  58385. * @returns true if the data is a KTX file or false otherwise
  58386. */
  58387. static IsValid(data: ArrayBufferView): boolean;
  58388. }
  58389. }
  58390. declare module BABYLON {
  58391. /**
  58392. * Helper class to push actions to a pool of workers.
  58393. */
  58394. export class WorkerPool implements IDisposable {
  58395. private _workerInfos;
  58396. private _pendingActions;
  58397. /**
  58398. * Constructor
  58399. * @param workers Array of workers to use for actions
  58400. */
  58401. constructor(workers: Array<Worker>);
  58402. /**
  58403. * Terminates all workers and clears any pending actions.
  58404. */
  58405. dispose(): void;
  58406. /**
  58407. * Pushes an action to the worker pool. If all the workers are active, the action will be
  58408. * pended until a worker has completed its action.
  58409. * @param action The action to perform. Call onComplete when the action is complete.
  58410. */
  58411. push(action: (worker: Worker, onComplete: () => void) => void): void;
  58412. private _execute;
  58413. }
  58414. }
  58415. declare module BABYLON {
  58416. /**
  58417. * Class for loading KTX2 files
  58418. */
  58419. export class KhronosTextureContainer2 {
  58420. private static _WorkerPoolPromise?;
  58421. private static _Initialized;
  58422. private static _Ktx2Decoder;
  58423. /**
  58424. * URLs to use when loading the KTX2 decoder module as well as its dependencies
  58425. * If a url is null, the default url is used (pointing to https://preview.babylonjs.com)
  58426. * Note that jsDecoderModule can't be null and that the other dependencies will only be loaded if necessary
  58427. * Urls you can change:
  58428. * URLConfig.jsDecoderModule
  58429. * URLConfig.wasmUASTCToASTC
  58430. * URLConfig.wasmUASTCToBC7
  58431. * URLConfig.jsMSCTranscoder
  58432. * URLConfig.wasmMSCTranscoder
  58433. * You can see their default values in this PG: https://playground.babylonjs.com/#EIJH8L#9
  58434. */
  58435. static URLConfig: {
  58436. jsDecoderModule: string;
  58437. wasmUASTCToASTC: null;
  58438. wasmUASTCToBC7: null;
  58439. jsMSCTranscoder: null;
  58440. wasmMSCTranscoder: null;
  58441. };
  58442. /**
  58443. * Default number of workers used to handle data decoding
  58444. */
  58445. static DefaultNumWorkers: number;
  58446. private static GetDefaultNumWorkers;
  58447. private _engine;
  58448. private static _CreateWorkerPool;
  58449. /**
  58450. * Constructor
  58451. * @param engine The engine to use
  58452. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  58453. */
  58454. constructor(engine: ThinEngine, numWorkers?: number);
  58455. /** @hidden */
  58456. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  58457. /**
  58458. * Stop all async operations and release resources.
  58459. */
  58460. dispose(): void;
  58461. protected _createTexture(data: any, internalTexture: InternalTexture): void;
  58462. /**
  58463. * Checks if the given data starts with a KTX2 file identifier.
  58464. * @param data the data to check
  58465. * @returns true if the data is a KTX2 file or false otherwise
  58466. */
  58467. static IsValid(data: ArrayBufferView): boolean;
  58468. }
  58469. }
  58470. declare module BABYLON {
  58471. /**
  58472. * Implementation of the KTX Texture Loader.
  58473. * @hidden
  58474. */
  58475. export class _KTXTextureLoader implements IInternalTextureLoader {
  58476. /**
  58477. * Defines wether the loader supports cascade loading the different faces.
  58478. */
  58479. readonly supportCascades: boolean;
  58480. /**
  58481. * This returns if the loader support the current file information.
  58482. * @param extension defines the file extension of the file being loaded
  58483. * @param mimeType defines the optional mime type of the file being loaded
  58484. * @returns true if the loader can load the specified file
  58485. */
  58486. canLoad(extension: string, mimeType?: string): boolean;
  58487. /**
  58488. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  58489. * @param data contains the texture data
  58490. * @param texture defines the BabylonJS internal texture
  58491. * @param createPolynomials will be true if polynomials have been requested
  58492. * @param onLoad defines the callback to trigger once the texture is ready
  58493. * @param onError defines the callback to trigger in case of error
  58494. */
  58495. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  58496. /**
  58497. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  58498. * @param data contains the texture data
  58499. * @param texture defines the BabylonJS internal texture
  58500. * @param callback defines the method to call once ready to upload
  58501. */
  58502. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  58503. }
  58504. }
  58505. declare module BABYLON {
  58506. /** @hidden */
  58507. export var _forceSceneHelpersToBundle: boolean;
  58508. interface Scene {
  58509. /**
  58510. * Creates a default light for the scene.
  58511. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  58512. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  58513. */
  58514. createDefaultLight(replace?: boolean): void;
  58515. /**
  58516. * Creates a default camera for the scene.
  58517. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  58518. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  58519. * @param replace has default false, when true replaces the active camera in the scene
  58520. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  58521. */
  58522. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  58523. /**
  58524. * Creates a default camera and a default light.
  58525. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  58526. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  58527. * @param replace has the default false, when true replaces the active camera/light in the scene
  58528. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  58529. */
  58530. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  58531. /**
  58532. * Creates a new sky box
  58533. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  58534. * @param environmentTexture defines the texture to use as environment texture
  58535. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  58536. * @param scale defines the overall scale of the skybox
  58537. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  58538. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  58539. * @returns a new mesh holding the sky box
  58540. */
  58541. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  58542. /**
  58543. * Creates a new environment
  58544. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  58545. * @param options defines the options you can use to configure the environment
  58546. * @returns the new EnvironmentHelper
  58547. */
  58548. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  58549. /**
  58550. * Creates a new VREXperienceHelper
  58551. * @see https://doc.babylonjs.com/how_to/webvr_helper
  58552. * @param webVROptions defines the options used to create the new VREXperienceHelper
  58553. * @returns a new VREXperienceHelper
  58554. */
  58555. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  58556. /**
  58557. * Creates a new WebXRDefaultExperience
  58558. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  58559. * @param options experience options
  58560. * @returns a promise for a new WebXRDefaultExperience
  58561. */
  58562. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  58563. }
  58564. }
  58565. declare module BABYLON {
  58566. /**
  58567. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  58568. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  58569. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  58570. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  58571. */
  58572. export class VideoDome extends TextureDome<VideoTexture> {
  58573. /**
  58574. * Define the video source as a Monoscopic panoramic 360 video.
  58575. */
  58576. static readonly MODE_MONOSCOPIC: number;
  58577. /**
  58578. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  58579. */
  58580. static readonly MODE_TOPBOTTOM: number;
  58581. /**
  58582. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  58583. */
  58584. static readonly MODE_SIDEBYSIDE: number;
  58585. /**
  58586. * Get the video texture associated with this video dome
  58587. */
  58588. get videoTexture(): VideoTexture;
  58589. /**
  58590. * Get the video mode of this dome
  58591. */
  58592. get videoMode(): number;
  58593. /**
  58594. * Set the video mode of this dome.
  58595. * @see textureMode
  58596. */
  58597. set videoMode(value: number);
  58598. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  58599. }
  58600. }
  58601. declare module BABYLON {
  58602. /**
  58603. * This class can be used to get instrumentation data from a Babylon engine
  58604. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  58605. */
  58606. export class EngineInstrumentation implements IDisposable {
  58607. /**
  58608. * Define the instrumented engine.
  58609. */
  58610. engine: Engine;
  58611. private _captureGPUFrameTime;
  58612. private _gpuFrameTimeToken;
  58613. private _gpuFrameTime;
  58614. private _captureShaderCompilationTime;
  58615. private _shaderCompilationTime;
  58616. private _onBeginFrameObserver;
  58617. private _onEndFrameObserver;
  58618. private _onBeforeShaderCompilationObserver;
  58619. private _onAfterShaderCompilationObserver;
  58620. /**
  58621. * Gets the perf counter used for GPU frame time
  58622. */
  58623. get gpuFrameTimeCounter(): PerfCounter;
  58624. /**
  58625. * Gets the GPU frame time capture status
  58626. */
  58627. get captureGPUFrameTime(): boolean;
  58628. /**
  58629. * Enable or disable the GPU frame time capture
  58630. */
  58631. set captureGPUFrameTime(value: boolean);
  58632. /**
  58633. * Gets the perf counter used for shader compilation time
  58634. */
  58635. get shaderCompilationTimeCounter(): PerfCounter;
  58636. /**
  58637. * Gets the shader compilation time capture status
  58638. */
  58639. get captureShaderCompilationTime(): boolean;
  58640. /**
  58641. * Enable or disable the shader compilation time capture
  58642. */
  58643. set captureShaderCompilationTime(value: boolean);
  58644. /**
  58645. * Instantiates a new engine instrumentation.
  58646. * This class can be used to get instrumentation data from a Babylon engine
  58647. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  58648. * @param engine Defines the engine to instrument
  58649. */
  58650. constructor(
  58651. /**
  58652. * Define the instrumented engine.
  58653. */
  58654. engine: Engine);
  58655. /**
  58656. * Dispose and release associated resources.
  58657. */
  58658. dispose(): void;
  58659. }
  58660. }
  58661. declare module BABYLON {
  58662. /**
  58663. * This class can be used to get instrumentation data from a Babylon engine
  58664. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  58665. */
  58666. export class SceneInstrumentation implements IDisposable {
  58667. /**
  58668. * Defines the scene to instrument
  58669. */
  58670. scene: Scene;
  58671. private _captureActiveMeshesEvaluationTime;
  58672. private _activeMeshesEvaluationTime;
  58673. private _captureRenderTargetsRenderTime;
  58674. private _renderTargetsRenderTime;
  58675. private _captureFrameTime;
  58676. private _frameTime;
  58677. private _captureRenderTime;
  58678. private _renderTime;
  58679. private _captureInterFrameTime;
  58680. private _interFrameTime;
  58681. private _captureParticlesRenderTime;
  58682. private _particlesRenderTime;
  58683. private _captureSpritesRenderTime;
  58684. private _spritesRenderTime;
  58685. private _capturePhysicsTime;
  58686. private _physicsTime;
  58687. private _captureAnimationsTime;
  58688. private _animationsTime;
  58689. private _captureCameraRenderTime;
  58690. private _cameraRenderTime;
  58691. private _onBeforeActiveMeshesEvaluationObserver;
  58692. private _onAfterActiveMeshesEvaluationObserver;
  58693. private _onBeforeRenderTargetsRenderObserver;
  58694. private _onAfterRenderTargetsRenderObserver;
  58695. private _onAfterRenderObserver;
  58696. private _onBeforeDrawPhaseObserver;
  58697. private _onAfterDrawPhaseObserver;
  58698. private _onBeforeAnimationsObserver;
  58699. private _onBeforeParticlesRenderingObserver;
  58700. private _onAfterParticlesRenderingObserver;
  58701. private _onBeforeSpritesRenderingObserver;
  58702. private _onAfterSpritesRenderingObserver;
  58703. private _onBeforePhysicsObserver;
  58704. private _onAfterPhysicsObserver;
  58705. private _onAfterAnimationsObserver;
  58706. private _onBeforeCameraRenderObserver;
  58707. private _onAfterCameraRenderObserver;
  58708. /**
  58709. * Gets the perf counter used for active meshes evaluation time
  58710. */
  58711. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  58712. /**
  58713. * Gets the active meshes evaluation time capture status
  58714. */
  58715. get captureActiveMeshesEvaluationTime(): boolean;
  58716. /**
  58717. * Enable or disable the active meshes evaluation time capture
  58718. */
  58719. set captureActiveMeshesEvaluationTime(value: boolean);
  58720. /**
  58721. * Gets the perf counter used for render targets render time
  58722. */
  58723. get renderTargetsRenderTimeCounter(): PerfCounter;
  58724. /**
  58725. * Gets the render targets render time capture status
  58726. */
  58727. get captureRenderTargetsRenderTime(): boolean;
  58728. /**
  58729. * Enable or disable the render targets render time capture
  58730. */
  58731. set captureRenderTargetsRenderTime(value: boolean);
  58732. /**
  58733. * Gets the perf counter used for particles render time
  58734. */
  58735. get particlesRenderTimeCounter(): PerfCounter;
  58736. /**
  58737. * Gets the particles render time capture status
  58738. */
  58739. get captureParticlesRenderTime(): boolean;
  58740. /**
  58741. * Enable or disable the particles render time capture
  58742. */
  58743. set captureParticlesRenderTime(value: boolean);
  58744. /**
  58745. * Gets the perf counter used for sprites render time
  58746. */
  58747. get spritesRenderTimeCounter(): PerfCounter;
  58748. /**
  58749. * Gets the sprites render time capture status
  58750. */
  58751. get captureSpritesRenderTime(): boolean;
  58752. /**
  58753. * Enable or disable the sprites render time capture
  58754. */
  58755. set captureSpritesRenderTime(value: boolean);
  58756. /**
  58757. * Gets the perf counter used for physics time
  58758. */
  58759. get physicsTimeCounter(): PerfCounter;
  58760. /**
  58761. * Gets the physics time capture status
  58762. */
  58763. get capturePhysicsTime(): boolean;
  58764. /**
  58765. * Enable or disable the physics time capture
  58766. */
  58767. set capturePhysicsTime(value: boolean);
  58768. /**
  58769. * Gets the perf counter used for animations time
  58770. */
  58771. get animationsTimeCounter(): PerfCounter;
  58772. /**
  58773. * Gets the animations time capture status
  58774. */
  58775. get captureAnimationsTime(): boolean;
  58776. /**
  58777. * Enable or disable the animations time capture
  58778. */
  58779. set captureAnimationsTime(value: boolean);
  58780. /**
  58781. * Gets the perf counter used for frame time capture
  58782. */
  58783. get frameTimeCounter(): PerfCounter;
  58784. /**
  58785. * Gets the frame time capture status
  58786. */
  58787. get captureFrameTime(): boolean;
  58788. /**
  58789. * Enable or disable the frame time capture
  58790. */
  58791. set captureFrameTime(value: boolean);
  58792. /**
  58793. * Gets the perf counter used for inter-frames time capture
  58794. */
  58795. get interFrameTimeCounter(): PerfCounter;
  58796. /**
  58797. * Gets the inter-frames time capture status
  58798. */
  58799. get captureInterFrameTime(): boolean;
  58800. /**
  58801. * Enable or disable the inter-frames time capture
  58802. */
  58803. set captureInterFrameTime(value: boolean);
  58804. /**
  58805. * Gets the perf counter used for render time capture
  58806. */
  58807. get renderTimeCounter(): PerfCounter;
  58808. /**
  58809. * Gets the render time capture status
  58810. */
  58811. get captureRenderTime(): boolean;
  58812. /**
  58813. * Enable or disable the render time capture
  58814. */
  58815. set captureRenderTime(value: boolean);
  58816. /**
  58817. * Gets the perf counter used for camera render time capture
  58818. */
  58819. get cameraRenderTimeCounter(): PerfCounter;
  58820. /**
  58821. * Gets the camera render time capture status
  58822. */
  58823. get captureCameraRenderTime(): boolean;
  58824. /**
  58825. * Enable or disable the camera render time capture
  58826. */
  58827. set captureCameraRenderTime(value: boolean);
  58828. /**
  58829. * Gets the perf counter used for draw calls
  58830. */
  58831. get drawCallsCounter(): PerfCounter;
  58832. /**
  58833. * Instantiates a new scene instrumentation.
  58834. * This class can be used to get instrumentation data from a Babylon engine
  58835. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  58836. * @param scene Defines the scene to instrument
  58837. */
  58838. constructor(
  58839. /**
  58840. * Defines the scene to instrument
  58841. */
  58842. scene: Scene);
  58843. /**
  58844. * Dispose and release associated resources.
  58845. */
  58846. dispose(): void;
  58847. }
  58848. }
  58849. declare module BABYLON {
  58850. /** @hidden */
  58851. export var glowMapGenerationPixelShader: {
  58852. name: string;
  58853. shader: string;
  58854. };
  58855. }
  58856. declare module BABYLON {
  58857. /** @hidden */
  58858. export var glowMapGenerationVertexShader: {
  58859. name: string;
  58860. shader: string;
  58861. };
  58862. }
  58863. declare module BABYLON {
  58864. /**
  58865. * Effect layer options. This helps customizing the behaviour
  58866. * of the effect layer.
  58867. */
  58868. export interface IEffectLayerOptions {
  58869. /**
  58870. * Multiplication factor apply to the canvas size to compute the render target size
  58871. * used to generated the objects (the smaller the faster).
  58872. */
  58873. mainTextureRatio: number;
  58874. /**
  58875. * Enforces a fixed size texture to ensure effect stability across devices.
  58876. */
  58877. mainTextureFixedSize?: number;
  58878. /**
  58879. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  58880. */
  58881. alphaBlendingMode: number;
  58882. /**
  58883. * The camera attached to the layer.
  58884. */
  58885. camera: Nullable<Camera>;
  58886. /**
  58887. * The rendering group to draw the layer in.
  58888. */
  58889. renderingGroupId: number;
  58890. }
  58891. /**
  58892. * The effect layer Helps adding post process effect blended with the main pass.
  58893. *
  58894. * This can be for instance use to generate glow or higlight effects on the scene.
  58895. *
  58896. * The effect layer class can not be used directly and is intented to inherited from to be
  58897. * customized per effects.
  58898. */
  58899. export abstract class EffectLayer {
  58900. private _vertexBuffers;
  58901. private _indexBuffer;
  58902. private _cachedDefines;
  58903. private _effectLayerMapGenerationEffect;
  58904. private _effectLayerOptions;
  58905. private _mergeEffect;
  58906. protected _scene: Scene;
  58907. protected _engine: Engine;
  58908. protected _maxSize: number;
  58909. protected _mainTextureDesiredSize: ISize;
  58910. protected _mainTexture: RenderTargetTexture;
  58911. protected _shouldRender: boolean;
  58912. protected _postProcesses: PostProcess[];
  58913. protected _textures: BaseTexture[];
  58914. protected _emissiveTextureAndColor: {
  58915. texture: Nullable<BaseTexture>;
  58916. color: Color4;
  58917. };
  58918. /**
  58919. * The name of the layer
  58920. */
  58921. name: string;
  58922. /**
  58923. * The clear color of the texture used to generate the glow map.
  58924. */
  58925. neutralColor: Color4;
  58926. /**
  58927. * Specifies whether the highlight layer is enabled or not.
  58928. */
  58929. isEnabled: boolean;
  58930. /**
  58931. * Gets the camera attached to the layer.
  58932. */
  58933. get camera(): Nullable<Camera>;
  58934. /**
  58935. * Gets the rendering group id the layer should render in.
  58936. */
  58937. get renderingGroupId(): number;
  58938. set renderingGroupId(renderingGroupId: number);
  58939. /**
  58940. * An event triggered when the effect layer has been disposed.
  58941. */
  58942. onDisposeObservable: Observable<EffectLayer>;
  58943. /**
  58944. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  58945. */
  58946. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  58947. /**
  58948. * An event triggered when the generated texture is being merged in the scene.
  58949. */
  58950. onBeforeComposeObservable: Observable<EffectLayer>;
  58951. /**
  58952. * An event triggered when the mesh is rendered into the effect render target.
  58953. */
  58954. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  58955. /**
  58956. * An event triggered after the mesh has been rendered into the effect render target.
  58957. */
  58958. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  58959. /**
  58960. * An event triggered when the generated texture has been merged in the scene.
  58961. */
  58962. onAfterComposeObservable: Observable<EffectLayer>;
  58963. /**
  58964. * An event triggered when the efffect layer changes its size.
  58965. */
  58966. onSizeChangedObservable: Observable<EffectLayer>;
  58967. /** @hidden */
  58968. static _SceneComponentInitialization: (scene: Scene) => void;
  58969. /**
  58970. * Instantiates a new effect Layer and references it in the scene.
  58971. * @param name The name of the layer
  58972. * @param scene The scene to use the layer in
  58973. */
  58974. constructor(
  58975. /** The Friendly of the effect in the scene */
  58976. name: string, scene: Scene);
  58977. /**
  58978. * Get the effect name of the layer.
  58979. * @return The effect name
  58980. */
  58981. abstract getEffectName(): string;
  58982. /**
  58983. * Checks for the readiness of the element composing the layer.
  58984. * @param subMesh the mesh to check for
  58985. * @param useInstances specify whether or not to use instances to render the mesh
  58986. * @return true if ready otherwise, false
  58987. */
  58988. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58989. /**
  58990. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  58991. * @returns true if the effect requires stencil during the main canvas render pass.
  58992. */
  58993. abstract needStencil(): boolean;
  58994. /**
  58995. * Create the merge effect. This is the shader use to blit the information back
  58996. * to the main canvas at the end of the scene rendering.
  58997. * @returns The effect containing the shader used to merge the effect on the main canvas
  58998. */
  58999. protected abstract _createMergeEffect(): Effect;
  59000. /**
  59001. * Creates the render target textures and post processes used in the effect layer.
  59002. */
  59003. protected abstract _createTextureAndPostProcesses(): void;
  59004. /**
  59005. * Implementation specific of rendering the generating effect on the main canvas.
  59006. * @param effect The effect used to render through
  59007. */
  59008. protected abstract _internalRender(effect: Effect): void;
  59009. /**
  59010. * Sets the required values for both the emissive texture and and the main color.
  59011. */
  59012. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  59013. /**
  59014. * Free any resources and references associated to a mesh.
  59015. * Internal use
  59016. * @param mesh The mesh to free.
  59017. */
  59018. abstract _disposeMesh(mesh: Mesh): void;
  59019. /**
  59020. * Serializes this layer (Glow or Highlight for example)
  59021. * @returns a serialized layer object
  59022. */
  59023. abstract serialize?(): any;
  59024. /**
  59025. * Initializes the effect layer with the required options.
  59026. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  59027. */
  59028. protected _init(options: Partial<IEffectLayerOptions>): void;
  59029. /**
  59030. * Generates the index buffer of the full screen quad blending to the main canvas.
  59031. */
  59032. private _generateIndexBuffer;
  59033. /**
  59034. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  59035. */
  59036. private _generateVertexBuffer;
  59037. /**
  59038. * Sets the main texture desired size which is the closest power of two
  59039. * of the engine canvas size.
  59040. */
  59041. private _setMainTextureSize;
  59042. /**
  59043. * Creates the main texture for the effect layer.
  59044. */
  59045. protected _createMainTexture(): void;
  59046. /**
  59047. * Adds specific effects defines.
  59048. * @param defines The defines to add specifics to.
  59049. */
  59050. protected _addCustomEffectDefines(defines: string[]): void;
  59051. /**
  59052. * Checks for the readiness of the element composing the layer.
  59053. * @param subMesh the mesh to check for
  59054. * @param useInstances specify whether or not to use instances to render the mesh
  59055. * @param emissiveTexture the associated emissive texture used to generate the glow
  59056. * @return true if ready otherwise, false
  59057. */
  59058. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  59059. /**
  59060. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  59061. */
  59062. render(): void;
  59063. /**
  59064. * Determine if a given mesh will be used in the current effect.
  59065. * @param mesh mesh to test
  59066. * @returns true if the mesh will be used
  59067. */
  59068. hasMesh(mesh: AbstractMesh): boolean;
  59069. /**
  59070. * Returns true if the layer contains information to display, otherwise false.
  59071. * @returns true if the glow layer should be rendered
  59072. */
  59073. shouldRender(): boolean;
  59074. /**
  59075. * Returns true if the mesh should render, otherwise false.
  59076. * @param mesh The mesh to render
  59077. * @returns true if it should render otherwise false
  59078. */
  59079. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  59080. /**
  59081. * Returns true if the mesh can be rendered, otherwise false.
  59082. * @param mesh The mesh to render
  59083. * @param material The material used on the mesh
  59084. * @returns true if it can be rendered otherwise false
  59085. */
  59086. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  59087. /**
  59088. * Returns true if the mesh should render, otherwise false.
  59089. * @param mesh The mesh to render
  59090. * @returns true if it should render otherwise false
  59091. */
  59092. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  59093. /**
  59094. * Renders the submesh passed in parameter to the generation map.
  59095. */
  59096. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  59097. /**
  59098. * Defines whether the current material of the mesh should be use to render the effect.
  59099. * @param mesh defines the current mesh to render
  59100. */
  59101. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  59102. /**
  59103. * Rebuild the required buffers.
  59104. * @hidden Internal use only.
  59105. */
  59106. _rebuild(): void;
  59107. /**
  59108. * Dispose only the render target textures and post process.
  59109. */
  59110. private _disposeTextureAndPostProcesses;
  59111. /**
  59112. * Dispose the highlight layer and free resources.
  59113. */
  59114. dispose(): void;
  59115. /**
  59116. * Gets the class name of the effect layer
  59117. * @returns the string with the class name of the effect layer
  59118. */
  59119. getClassName(): string;
  59120. /**
  59121. * Creates an effect layer from parsed effect layer data
  59122. * @param parsedEffectLayer defines effect layer data
  59123. * @param scene defines the current scene
  59124. * @param rootUrl defines the root URL containing the effect layer information
  59125. * @returns a parsed effect Layer
  59126. */
  59127. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  59128. }
  59129. }
  59130. declare module BABYLON {
  59131. interface AbstractScene {
  59132. /**
  59133. * The list of effect layers (highlights/glow) added to the scene
  59134. * @see https://doc.babylonjs.com/how_to/highlight_layer
  59135. * @see https://doc.babylonjs.com/how_to/glow_layer
  59136. */
  59137. effectLayers: Array<EffectLayer>;
  59138. /**
  59139. * Removes the given effect layer from this scene.
  59140. * @param toRemove defines the effect layer to remove
  59141. * @returns the index of the removed effect layer
  59142. */
  59143. removeEffectLayer(toRemove: EffectLayer): number;
  59144. /**
  59145. * Adds the given effect layer to this scene
  59146. * @param newEffectLayer defines the effect layer to add
  59147. */
  59148. addEffectLayer(newEffectLayer: EffectLayer): void;
  59149. }
  59150. /**
  59151. * Defines the layer scene component responsible to manage any effect layers
  59152. * in a given scene.
  59153. */
  59154. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  59155. /**
  59156. * The component name helpfull to identify the component in the list of scene components.
  59157. */
  59158. readonly name: string;
  59159. /**
  59160. * The scene the component belongs to.
  59161. */
  59162. scene: Scene;
  59163. private _engine;
  59164. private _renderEffects;
  59165. private _needStencil;
  59166. private _previousStencilState;
  59167. /**
  59168. * Creates a new instance of the component for the given scene
  59169. * @param scene Defines the scene to register the component in
  59170. */
  59171. constructor(scene: Scene);
  59172. /**
  59173. * Registers the component in a given scene
  59174. */
  59175. register(): void;
  59176. /**
  59177. * Rebuilds the elements related to this component in case of
  59178. * context lost for instance.
  59179. */
  59180. rebuild(): void;
  59181. /**
  59182. * Serializes the component data to the specified json object
  59183. * @param serializationObject The object to serialize to
  59184. */
  59185. serialize(serializationObject: any): void;
  59186. /**
  59187. * Adds all the elements from the container to the scene
  59188. * @param container the container holding the elements
  59189. */
  59190. addFromContainer(container: AbstractScene): void;
  59191. /**
  59192. * Removes all the elements in the container from the scene
  59193. * @param container contains the elements to remove
  59194. * @param dispose if the removed element should be disposed (default: false)
  59195. */
  59196. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  59197. /**
  59198. * Disposes the component and the associated ressources.
  59199. */
  59200. dispose(): void;
  59201. private _isReadyForMesh;
  59202. private _renderMainTexture;
  59203. private _setStencil;
  59204. private _setStencilBack;
  59205. private _draw;
  59206. private _drawCamera;
  59207. private _drawRenderingGroup;
  59208. }
  59209. }
  59210. declare module BABYLON {
  59211. /** @hidden */
  59212. export var glowMapMergePixelShader: {
  59213. name: string;
  59214. shader: string;
  59215. };
  59216. }
  59217. declare module BABYLON {
  59218. /** @hidden */
  59219. export var glowMapMergeVertexShader: {
  59220. name: string;
  59221. shader: string;
  59222. };
  59223. }
  59224. declare module BABYLON {
  59225. interface AbstractScene {
  59226. /**
  59227. * Return a the first highlight layer of the scene with a given name.
  59228. * @param name The name of the highlight layer to look for.
  59229. * @return The highlight layer if found otherwise null.
  59230. */
  59231. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  59232. }
  59233. /**
  59234. * Glow layer options. This helps customizing the behaviour
  59235. * of the glow layer.
  59236. */
  59237. export interface IGlowLayerOptions {
  59238. /**
  59239. * Multiplication factor apply to the canvas size to compute the render target size
  59240. * used to generated the glowing objects (the smaller the faster).
  59241. */
  59242. mainTextureRatio: number;
  59243. /**
  59244. * Enforces a fixed size texture to ensure resize independant blur.
  59245. */
  59246. mainTextureFixedSize?: number;
  59247. /**
  59248. * How big is the kernel of the blur texture.
  59249. */
  59250. blurKernelSize: number;
  59251. /**
  59252. * The camera attached to the layer.
  59253. */
  59254. camera: Nullable<Camera>;
  59255. /**
  59256. * Enable MSAA by chosing the number of samples.
  59257. */
  59258. mainTextureSamples?: number;
  59259. /**
  59260. * The rendering group to draw the layer in.
  59261. */
  59262. renderingGroupId: number;
  59263. }
  59264. /**
  59265. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  59266. *
  59267. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  59268. *
  59269. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  59270. */
  59271. export class GlowLayer extends EffectLayer {
  59272. /**
  59273. * Effect Name of the layer.
  59274. */
  59275. static readonly EffectName: string;
  59276. /**
  59277. * The default blur kernel size used for the glow.
  59278. */
  59279. static DefaultBlurKernelSize: number;
  59280. /**
  59281. * The default texture size ratio used for the glow.
  59282. */
  59283. static DefaultTextureRatio: number;
  59284. /**
  59285. * Sets the kernel size of the blur.
  59286. */
  59287. set blurKernelSize(value: number);
  59288. /**
  59289. * Gets the kernel size of the blur.
  59290. */
  59291. get blurKernelSize(): number;
  59292. /**
  59293. * Sets the glow intensity.
  59294. */
  59295. set intensity(value: number);
  59296. /**
  59297. * Gets the glow intensity.
  59298. */
  59299. get intensity(): number;
  59300. private _options;
  59301. private _intensity;
  59302. private _horizontalBlurPostprocess1;
  59303. private _verticalBlurPostprocess1;
  59304. private _horizontalBlurPostprocess2;
  59305. private _verticalBlurPostprocess2;
  59306. private _blurTexture1;
  59307. private _blurTexture2;
  59308. private _postProcesses1;
  59309. private _postProcesses2;
  59310. private _includedOnlyMeshes;
  59311. private _excludedMeshes;
  59312. private _meshesUsingTheirOwnMaterials;
  59313. /**
  59314. * Callback used to let the user override the color selection on a per mesh basis
  59315. */
  59316. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  59317. /**
  59318. * Callback used to let the user override the texture selection on a per mesh basis
  59319. */
  59320. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  59321. /**
  59322. * Instantiates a new glow Layer and references it to the scene.
  59323. * @param name The name of the layer
  59324. * @param scene The scene to use the layer in
  59325. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  59326. */
  59327. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  59328. /**
  59329. * Get the effect name of the layer.
  59330. * @return The effect name
  59331. */
  59332. getEffectName(): string;
  59333. /**
  59334. * Create the merge effect. This is the shader use to blit the information back
  59335. * to the main canvas at the end of the scene rendering.
  59336. */
  59337. protected _createMergeEffect(): Effect;
  59338. /**
  59339. * Creates the render target textures and post processes used in the glow layer.
  59340. */
  59341. protected _createTextureAndPostProcesses(): void;
  59342. /**
  59343. * Checks for the readiness of the element composing the layer.
  59344. * @param subMesh the mesh to check for
  59345. * @param useInstances specify wether or not to use instances to render the mesh
  59346. * @param emissiveTexture the associated emissive texture used to generate the glow
  59347. * @return true if ready otherwise, false
  59348. */
  59349. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59350. /**
  59351. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  59352. */
  59353. needStencil(): boolean;
  59354. /**
  59355. * Returns true if the mesh can be rendered, otherwise false.
  59356. * @param mesh The mesh to render
  59357. * @param material The material used on the mesh
  59358. * @returns true if it can be rendered otherwise false
  59359. */
  59360. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  59361. /**
  59362. * Implementation specific of rendering the generating effect on the main canvas.
  59363. * @param effect The effect used to render through
  59364. */
  59365. protected _internalRender(effect: Effect): void;
  59366. /**
  59367. * Sets the required values for both the emissive texture and and the main color.
  59368. */
  59369. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  59370. /**
  59371. * Returns true if the mesh should render, otherwise false.
  59372. * @param mesh The mesh to render
  59373. * @returns true if it should render otherwise false
  59374. */
  59375. protected _shouldRenderMesh(mesh: Mesh): boolean;
  59376. /**
  59377. * Adds specific effects defines.
  59378. * @param defines The defines to add specifics to.
  59379. */
  59380. protected _addCustomEffectDefines(defines: string[]): void;
  59381. /**
  59382. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  59383. * @param mesh The mesh to exclude from the glow layer
  59384. */
  59385. addExcludedMesh(mesh: Mesh): void;
  59386. /**
  59387. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  59388. * @param mesh The mesh to remove
  59389. */
  59390. removeExcludedMesh(mesh: Mesh): void;
  59391. /**
  59392. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  59393. * @param mesh The mesh to include in the glow layer
  59394. */
  59395. addIncludedOnlyMesh(mesh: Mesh): void;
  59396. /**
  59397. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  59398. * @param mesh The mesh to remove
  59399. */
  59400. removeIncludedOnlyMesh(mesh: Mesh): void;
  59401. /**
  59402. * Determine if a given mesh will be used in the glow layer
  59403. * @param mesh The mesh to test
  59404. * @returns true if the mesh will be highlighted by the current glow layer
  59405. */
  59406. hasMesh(mesh: AbstractMesh): boolean;
  59407. /**
  59408. * Defines whether the current material of the mesh should be use to render the effect.
  59409. * @param mesh defines the current mesh to render
  59410. */
  59411. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  59412. /**
  59413. * Add a mesh to be rendered through its own material and not with emissive only.
  59414. * @param mesh The mesh for which we need to use its material
  59415. */
  59416. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  59417. /**
  59418. * Remove a mesh from being rendered through its own material and not with emissive only.
  59419. * @param mesh The mesh for which we need to not use its material
  59420. */
  59421. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  59422. /**
  59423. * Free any resources and references associated to a mesh.
  59424. * Internal use
  59425. * @param mesh The mesh to free.
  59426. * @hidden
  59427. */
  59428. _disposeMesh(mesh: Mesh): void;
  59429. /**
  59430. * Gets the class name of the effect layer
  59431. * @returns the string with the class name of the effect layer
  59432. */
  59433. getClassName(): string;
  59434. /**
  59435. * Serializes this glow layer
  59436. * @returns a serialized glow layer object
  59437. */
  59438. serialize(): any;
  59439. /**
  59440. * Creates a Glow Layer from parsed glow layer data
  59441. * @param parsedGlowLayer defines glow layer data
  59442. * @param scene defines the current scene
  59443. * @param rootUrl defines the root URL containing the glow layer information
  59444. * @returns a parsed Glow Layer
  59445. */
  59446. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  59447. }
  59448. }
  59449. declare module BABYLON {
  59450. /** @hidden */
  59451. export var glowBlurPostProcessPixelShader: {
  59452. name: string;
  59453. shader: string;
  59454. };
  59455. }
  59456. declare module BABYLON {
  59457. interface AbstractScene {
  59458. /**
  59459. * Return a the first highlight layer of the scene with a given name.
  59460. * @param name The name of the highlight layer to look for.
  59461. * @return The highlight layer if found otherwise null.
  59462. */
  59463. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  59464. }
  59465. /**
  59466. * Highlight layer options. This helps customizing the behaviour
  59467. * of the highlight layer.
  59468. */
  59469. export interface IHighlightLayerOptions {
  59470. /**
  59471. * Multiplication factor apply to the canvas size to compute the render target size
  59472. * used to generated the glowing objects (the smaller the faster).
  59473. */
  59474. mainTextureRatio: number;
  59475. /**
  59476. * Enforces a fixed size texture to ensure resize independant blur.
  59477. */
  59478. mainTextureFixedSize?: number;
  59479. /**
  59480. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  59481. * of the picture to blur (the smaller the faster).
  59482. */
  59483. blurTextureSizeRatio: number;
  59484. /**
  59485. * How big in texel of the blur texture is the vertical blur.
  59486. */
  59487. blurVerticalSize: number;
  59488. /**
  59489. * How big in texel of the blur texture is the horizontal blur.
  59490. */
  59491. blurHorizontalSize: number;
  59492. /**
  59493. * Alpha blending mode used to apply the blur. Default is combine.
  59494. */
  59495. alphaBlendingMode: number;
  59496. /**
  59497. * The camera attached to the layer.
  59498. */
  59499. camera: Nullable<Camera>;
  59500. /**
  59501. * Should we display highlight as a solid stroke?
  59502. */
  59503. isStroke?: boolean;
  59504. /**
  59505. * The rendering group to draw the layer in.
  59506. */
  59507. renderingGroupId: number;
  59508. }
  59509. /**
  59510. * The highlight layer Helps adding a glow effect around a mesh.
  59511. *
  59512. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  59513. * glowy meshes to your scene.
  59514. *
  59515. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  59516. */
  59517. export class HighlightLayer extends EffectLayer {
  59518. name: string;
  59519. /**
  59520. * Effect Name of the highlight layer.
  59521. */
  59522. static readonly EffectName: string;
  59523. /**
  59524. * The neutral color used during the preparation of the glow effect.
  59525. * This is black by default as the blend operation is a blend operation.
  59526. */
  59527. static NeutralColor: Color4;
  59528. /**
  59529. * Stencil value used for glowing meshes.
  59530. */
  59531. static GlowingMeshStencilReference: number;
  59532. /**
  59533. * Stencil value used for the other meshes in the scene.
  59534. */
  59535. static NormalMeshStencilReference: number;
  59536. /**
  59537. * Specifies whether or not the inner glow is ACTIVE in the layer.
  59538. */
  59539. innerGlow: boolean;
  59540. /**
  59541. * Specifies whether or not the outer glow is ACTIVE in the layer.
  59542. */
  59543. outerGlow: boolean;
  59544. /**
  59545. * Specifies the horizontal size of the blur.
  59546. */
  59547. set blurHorizontalSize(value: number);
  59548. /**
  59549. * Specifies the vertical size of the blur.
  59550. */
  59551. set blurVerticalSize(value: number);
  59552. /**
  59553. * Gets the horizontal size of the blur.
  59554. */
  59555. get blurHorizontalSize(): number;
  59556. /**
  59557. * Gets the vertical size of the blur.
  59558. */
  59559. get blurVerticalSize(): number;
  59560. /**
  59561. * An event triggered when the highlight layer is being blurred.
  59562. */
  59563. onBeforeBlurObservable: Observable<HighlightLayer>;
  59564. /**
  59565. * An event triggered when the highlight layer has been blurred.
  59566. */
  59567. onAfterBlurObservable: Observable<HighlightLayer>;
  59568. private _instanceGlowingMeshStencilReference;
  59569. private _options;
  59570. private _downSamplePostprocess;
  59571. private _horizontalBlurPostprocess;
  59572. private _verticalBlurPostprocess;
  59573. private _blurTexture;
  59574. private _meshes;
  59575. private _excludedMeshes;
  59576. /**
  59577. * Instantiates a new highlight Layer and references it to the scene..
  59578. * @param name The name of the layer
  59579. * @param scene The scene to use the layer in
  59580. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  59581. */
  59582. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  59583. /**
  59584. * Get the effect name of the layer.
  59585. * @return The effect name
  59586. */
  59587. getEffectName(): string;
  59588. /**
  59589. * Create the merge effect. This is the shader use to blit the information back
  59590. * to the main canvas at the end of the scene rendering.
  59591. */
  59592. protected _createMergeEffect(): Effect;
  59593. /**
  59594. * Creates the render target textures and post processes used in the highlight layer.
  59595. */
  59596. protected _createTextureAndPostProcesses(): void;
  59597. /**
  59598. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  59599. */
  59600. needStencil(): boolean;
  59601. /**
  59602. * Checks for the readiness of the element composing the layer.
  59603. * @param subMesh the mesh to check for
  59604. * @param useInstances specify wether or not to use instances to render the mesh
  59605. * @param emissiveTexture the associated emissive texture used to generate the glow
  59606. * @return true if ready otherwise, false
  59607. */
  59608. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59609. /**
  59610. * Implementation specific of rendering the generating effect on the main canvas.
  59611. * @param effect The effect used to render through
  59612. */
  59613. protected _internalRender(effect: Effect): void;
  59614. /**
  59615. * Returns true if the layer contains information to display, otherwise false.
  59616. */
  59617. shouldRender(): boolean;
  59618. /**
  59619. * Returns true if the mesh should render, otherwise false.
  59620. * @param mesh The mesh to render
  59621. * @returns true if it should render otherwise false
  59622. */
  59623. protected _shouldRenderMesh(mesh: Mesh): boolean;
  59624. /**
  59625. * Returns true if the mesh can be rendered, otherwise false.
  59626. * @param mesh The mesh to render
  59627. * @param material The material used on the mesh
  59628. * @returns true if it can be rendered otherwise false
  59629. */
  59630. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  59631. /**
  59632. * Adds specific effects defines.
  59633. * @param defines The defines to add specifics to.
  59634. */
  59635. protected _addCustomEffectDefines(defines: string[]): void;
  59636. /**
  59637. * Sets the required values for both the emissive texture and and the main color.
  59638. */
  59639. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  59640. /**
  59641. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  59642. * @param mesh The mesh to exclude from the highlight layer
  59643. */
  59644. addExcludedMesh(mesh: Mesh): void;
  59645. /**
  59646. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  59647. * @param mesh The mesh to highlight
  59648. */
  59649. removeExcludedMesh(mesh: Mesh): void;
  59650. /**
  59651. * Determine if a given mesh will be highlighted by the current HighlightLayer
  59652. * @param mesh mesh to test
  59653. * @returns true if the mesh will be highlighted by the current HighlightLayer
  59654. */
  59655. hasMesh(mesh: AbstractMesh): boolean;
  59656. /**
  59657. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  59658. * @param mesh The mesh to highlight
  59659. * @param color The color of the highlight
  59660. * @param glowEmissiveOnly Extract the glow from the emissive texture
  59661. */
  59662. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  59663. /**
  59664. * Remove a mesh from the highlight layer in order to make it stop glowing.
  59665. * @param mesh The mesh to highlight
  59666. */
  59667. removeMesh(mesh: Mesh): void;
  59668. /**
  59669. * Remove all the meshes currently referenced in the highlight layer
  59670. */
  59671. removeAllMeshes(): void;
  59672. /**
  59673. * Force the stencil to the normal expected value for none glowing parts
  59674. */
  59675. private _defaultStencilReference;
  59676. /**
  59677. * Free any resources and references associated to a mesh.
  59678. * Internal use
  59679. * @param mesh The mesh to free.
  59680. * @hidden
  59681. */
  59682. _disposeMesh(mesh: Mesh): void;
  59683. /**
  59684. * Dispose the highlight layer and free resources.
  59685. */
  59686. dispose(): void;
  59687. /**
  59688. * Gets the class name of the effect layer
  59689. * @returns the string with the class name of the effect layer
  59690. */
  59691. getClassName(): string;
  59692. /**
  59693. * Serializes this Highlight layer
  59694. * @returns a serialized Highlight layer object
  59695. */
  59696. serialize(): any;
  59697. /**
  59698. * Creates a Highlight layer from parsed Highlight layer data
  59699. * @param parsedHightlightLayer defines the Highlight layer data
  59700. * @param scene defines the current scene
  59701. * @param rootUrl defines the root URL containing the Highlight layer information
  59702. * @returns a parsed Highlight layer
  59703. */
  59704. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  59705. }
  59706. }
  59707. declare module BABYLON {
  59708. interface AbstractScene {
  59709. /**
  59710. * The list of layers (background and foreground) of the scene
  59711. */
  59712. layers: Array<Layer>;
  59713. }
  59714. /**
  59715. * Defines the layer scene component responsible to manage any layers
  59716. * in a given scene.
  59717. */
  59718. export class LayerSceneComponent implements ISceneComponent {
  59719. /**
  59720. * The component name helpfull to identify the component in the list of scene components.
  59721. */
  59722. readonly name: string;
  59723. /**
  59724. * The scene the component belongs to.
  59725. */
  59726. scene: Scene;
  59727. private _engine;
  59728. /**
  59729. * Creates a new instance of the component for the given scene
  59730. * @param scene Defines the scene to register the component in
  59731. */
  59732. constructor(scene: Scene);
  59733. /**
  59734. * Registers the component in a given scene
  59735. */
  59736. register(): void;
  59737. /**
  59738. * Rebuilds the elements related to this component in case of
  59739. * context lost for instance.
  59740. */
  59741. rebuild(): void;
  59742. /**
  59743. * Disposes the component and the associated ressources.
  59744. */
  59745. dispose(): void;
  59746. private _draw;
  59747. private _drawCameraPredicate;
  59748. private _drawCameraBackground;
  59749. private _drawCameraForeground;
  59750. private _drawRenderTargetPredicate;
  59751. private _drawRenderTargetBackground;
  59752. private _drawRenderTargetForeground;
  59753. /**
  59754. * Adds all the elements from the container to the scene
  59755. * @param container the container holding the elements
  59756. */
  59757. addFromContainer(container: AbstractScene): void;
  59758. /**
  59759. * Removes all the elements in the container from the scene
  59760. * @param container contains the elements to remove
  59761. * @param dispose if the removed element should be disposed (default: false)
  59762. */
  59763. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  59764. }
  59765. }
  59766. declare module BABYLON {
  59767. /** @hidden */
  59768. export var layerPixelShader: {
  59769. name: string;
  59770. shader: string;
  59771. };
  59772. }
  59773. declare module BABYLON {
  59774. /** @hidden */
  59775. export var layerVertexShader: {
  59776. name: string;
  59777. shader: string;
  59778. };
  59779. }
  59780. declare module BABYLON {
  59781. /**
  59782. * This represents a full screen 2d layer.
  59783. * This can be useful to display a picture in the background of your scene for instance.
  59784. * @see https://www.babylonjs-playground.com/#08A2BS#1
  59785. */
  59786. export class Layer {
  59787. /**
  59788. * Define the name of the layer.
  59789. */
  59790. name: string;
  59791. /**
  59792. * Define the texture the layer should display.
  59793. */
  59794. texture: Nullable<Texture>;
  59795. /**
  59796. * Is the layer in background or foreground.
  59797. */
  59798. isBackground: boolean;
  59799. /**
  59800. * Define the color of the layer (instead of texture).
  59801. */
  59802. color: Color4;
  59803. /**
  59804. * Define the scale of the layer in order to zoom in out of the texture.
  59805. */
  59806. scale: Vector2;
  59807. /**
  59808. * Define an offset for the layer in order to shift the texture.
  59809. */
  59810. offset: Vector2;
  59811. /**
  59812. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  59813. */
  59814. alphaBlendingMode: number;
  59815. /**
  59816. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  59817. * Alpha test will not mix with the background color in case of transparency.
  59818. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  59819. */
  59820. alphaTest: boolean;
  59821. /**
  59822. * Define a mask to restrict the layer to only some of the scene cameras.
  59823. */
  59824. layerMask: number;
  59825. /**
  59826. * Define the list of render target the layer is visible into.
  59827. */
  59828. renderTargetTextures: RenderTargetTexture[];
  59829. /**
  59830. * Define if the layer is only used in renderTarget or if it also
  59831. * renders in the main frame buffer of the canvas.
  59832. */
  59833. renderOnlyInRenderTargetTextures: boolean;
  59834. private _scene;
  59835. private _vertexBuffers;
  59836. private _indexBuffer;
  59837. private _effect;
  59838. private _previousDefines;
  59839. /**
  59840. * An event triggered when the layer is disposed.
  59841. */
  59842. onDisposeObservable: Observable<Layer>;
  59843. private _onDisposeObserver;
  59844. /**
  59845. * Back compatibility with callback before the onDisposeObservable existed.
  59846. * The set callback will be triggered when the layer has been disposed.
  59847. */
  59848. set onDispose(callback: () => void);
  59849. /**
  59850. * An event triggered before rendering the scene
  59851. */
  59852. onBeforeRenderObservable: Observable<Layer>;
  59853. private _onBeforeRenderObserver;
  59854. /**
  59855. * Back compatibility with callback before the onBeforeRenderObservable existed.
  59856. * The set callback will be triggered just before rendering the layer.
  59857. */
  59858. set onBeforeRender(callback: () => void);
  59859. /**
  59860. * An event triggered after rendering the scene
  59861. */
  59862. onAfterRenderObservable: Observable<Layer>;
  59863. private _onAfterRenderObserver;
  59864. /**
  59865. * Back compatibility with callback before the onAfterRenderObservable existed.
  59866. * The set callback will be triggered just after rendering the layer.
  59867. */
  59868. set onAfterRender(callback: () => void);
  59869. /**
  59870. * Instantiates a new layer.
  59871. * This represents a full screen 2d layer.
  59872. * This can be useful to display a picture in the background of your scene for instance.
  59873. * @see https://www.babylonjs-playground.com/#08A2BS#1
  59874. * @param name Define the name of the layer in the scene
  59875. * @param imgUrl Define the url of the texture to display in the layer
  59876. * @param scene Define the scene the layer belongs to
  59877. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  59878. * @param color Defines a color for the layer
  59879. */
  59880. constructor(
  59881. /**
  59882. * Define the name of the layer.
  59883. */
  59884. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  59885. private _createIndexBuffer;
  59886. /** @hidden */
  59887. _rebuild(): void;
  59888. /**
  59889. * Renders the layer in the scene.
  59890. */
  59891. render(): void;
  59892. /**
  59893. * Disposes and releases the associated ressources.
  59894. */
  59895. dispose(): void;
  59896. }
  59897. }
  59898. declare module BABYLON {
  59899. /** @hidden */
  59900. export var lensFlarePixelShader: {
  59901. name: string;
  59902. shader: string;
  59903. };
  59904. }
  59905. declare module BABYLON {
  59906. /** @hidden */
  59907. export var lensFlareVertexShader: {
  59908. name: string;
  59909. shader: string;
  59910. };
  59911. }
  59912. declare module BABYLON {
  59913. /**
  59914. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  59915. * It is usually composed of several `lensFlare`.
  59916. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59917. */
  59918. export class LensFlareSystem {
  59919. /**
  59920. * Define the name of the lens flare system
  59921. */
  59922. name: string;
  59923. /**
  59924. * List of lens flares used in this system.
  59925. */
  59926. lensFlares: LensFlare[];
  59927. /**
  59928. * Define a limit from the border the lens flare can be visible.
  59929. */
  59930. borderLimit: number;
  59931. /**
  59932. * Define a viewport border we do not want to see the lens flare in.
  59933. */
  59934. viewportBorder: number;
  59935. /**
  59936. * Define a predicate which could limit the list of meshes able to occlude the effect.
  59937. */
  59938. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  59939. /**
  59940. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  59941. */
  59942. layerMask: number;
  59943. /**
  59944. * Define the id of the lens flare system in the scene.
  59945. * (equal to name by default)
  59946. */
  59947. id: string;
  59948. private _scene;
  59949. private _emitter;
  59950. private _vertexBuffers;
  59951. private _indexBuffer;
  59952. private _effect;
  59953. private _positionX;
  59954. private _positionY;
  59955. private _isEnabled;
  59956. /** @hidden */
  59957. static _SceneComponentInitialization: (scene: Scene) => void;
  59958. /**
  59959. * Instantiates a lens flare system.
  59960. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  59961. * It is usually composed of several `lensFlare`.
  59962. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  59963. * @param name Define the name of the lens flare system in the scene
  59964. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  59965. * @param scene Define the scene the lens flare system belongs to
  59966. */
  59967. constructor(
  59968. /**
  59969. * Define the name of the lens flare system
  59970. */
  59971. name: string, emitter: any, scene: Scene);
  59972. /**
  59973. * Define if the lens flare system is enabled.
  59974. */
  59975. get isEnabled(): boolean;
  59976. set isEnabled(value: boolean);
  59977. /**
  59978. * Get the scene the effects belongs to.
  59979. * @returns the scene holding the lens flare system
  59980. */
  59981. getScene(): Scene;
  59982. /**
  59983. * Get the emitter of the lens flare system.
  59984. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  59985. * @returns the emitter of the lens flare system
  59986. */
  59987. getEmitter(): any;
  59988. /**
  59989. * Set the emitter of the lens flare system.
  59990. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  59991. * @param newEmitter Define the new emitter of the system
  59992. */
  59993. setEmitter(newEmitter: any): void;
  59994. /**
  59995. * Get the lens flare system emitter position.
  59996. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  59997. * @returns the position
  59998. */
  59999. getEmitterPosition(): Vector3;
  60000. /**
  60001. * @hidden
  60002. */
  60003. computeEffectivePosition(globalViewport: Viewport): boolean;
  60004. /** @hidden */
  60005. _isVisible(): boolean;
  60006. /**
  60007. * @hidden
  60008. */
  60009. render(): boolean;
  60010. /**
  60011. * Dispose and release the lens flare with its associated resources.
  60012. */
  60013. dispose(): void;
  60014. /**
  60015. * Parse a lens flare system from a JSON repressentation
  60016. * @param parsedLensFlareSystem Define the JSON to parse
  60017. * @param scene Define the scene the parsed system should be instantiated in
  60018. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  60019. * @returns the parsed system
  60020. */
  60021. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  60022. /**
  60023. * Serialize the current Lens Flare System into a JSON representation.
  60024. * @returns the serialized JSON
  60025. */
  60026. serialize(): any;
  60027. }
  60028. }
  60029. declare module BABYLON {
  60030. /**
  60031. * This represents one of the lens effect in a `lensFlareSystem`.
  60032. * It controls one of the indiviual texture used in the effect.
  60033. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60034. */
  60035. export class LensFlare {
  60036. /**
  60037. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  60038. */
  60039. size: number;
  60040. /**
  60041. * 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.
  60042. */
  60043. position: number;
  60044. /**
  60045. * Define the lens color.
  60046. */
  60047. color: Color3;
  60048. /**
  60049. * Define the lens texture.
  60050. */
  60051. texture: Nullable<Texture>;
  60052. /**
  60053. * Define the alpha mode to render this particular lens.
  60054. */
  60055. alphaMode: number;
  60056. private _system;
  60057. /**
  60058. * Creates a new Lens Flare.
  60059. * This represents one of the lens effect in a `lensFlareSystem`.
  60060. * It controls one of the indiviual texture used in the effect.
  60061. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60062. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  60063. * @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.
  60064. * @param color Define the lens color
  60065. * @param imgUrl Define the lens texture url
  60066. * @param system Define the `lensFlareSystem` this flare is part of
  60067. * @returns The newly created Lens Flare
  60068. */
  60069. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  60070. /**
  60071. * Instantiates a new Lens Flare.
  60072. * This represents one of the lens effect in a `lensFlareSystem`.
  60073. * It controls one of the indiviual texture used in the effect.
  60074. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60075. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  60076. * @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.
  60077. * @param color Define the lens color
  60078. * @param imgUrl Define the lens texture url
  60079. * @param system Define the `lensFlareSystem` this flare is part of
  60080. */
  60081. constructor(
  60082. /**
  60083. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  60084. */
  60085. size: number,
  60086. /**
  60087. * 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.
  60088. */
  60089. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  60090. /**
  60091. * Dispose and release the lens flare with its associated resources.
  60092. */
  60093. dispose(): void;
  60094. }
  60095. }
  60096. declare module BABYLON {
  60097. interface AbstractScene {
  60098. /**
  60099. * The list of lens flare system added to the scene
  60100. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  60101. */
  60102. lensFlareSystems: Array<LensFlareSystem>;
  60103. /**
  60104. * Removes the given lens flare system from this scene.
  60105. * @param toRemove The lens flare system to remove
  60106. * @returns The index of the removed lens flare system
  60107. */
  60108. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  60109. /**
  60110. * Adds the given lens flare system to this scene
  60111. * @param newLensFlareSystem The lens flare system to add
  60112. */
  60113. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  60114. /**
  60115. * Gets a lens flare system using its name
  60116. * @param name defines the name to look for
  60117. * @returns the lens flare system or null if not found
  60118. */
  60119. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  60120. /**
  60121. * Gets a lens flare system using its id
  60122. * @param id defines the id to look for
  60123. * @returns the lens flare system or null if not found
  60124. */
  60125. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  60126. }
  60127. /**
  60128. * Defines the lens flare scene component responsible to manage any lens flares
  60129. * in a given scene.
  60130. */
  60131. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  60132. /**
  60133. * The component name helpfull to identify the component in the list of scene components.
  60134. */
  60135. readonly name: string;
  60136. /**
  60137. * The scene the component belongs to.
  60138. */
  60139. scene: Scene;
  60140. /**
  60141. * Creates a new instance of the component for the given scene
  60142. * @param scene Defines the scene to register the component in
  60143. */
  60144. constructor(scene: Scene);
  60145. /**
  60146. * Registers the component in a given scene
  60147. */
  60148. register(): void;
  60149. /**
  60150. * Rebuilds the elements related to this component in case of
  60151. * context lost for instance.
  60152. */
  60153. rebuild(): void;
  60154. /**
  60155. * Adds all the elements from the container to the scene
  60156. * @param container the container holding the elements
  60157. */
  60158. addFromContainer(container: AbstractScene): void;
  60159. /**
  60160. * Removes all the elements in the container from the scene
  60161. * @param container contains the elements to remove
  60162. * @param dispose if the removed element should be disposed (default: false)
  60163. */
  60164. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  60165. /**
  60166. * Serializes the component data to the specified json object
  60167. * @param serializationObject The object to serialize to
  60168. */
  60169. serialize(serializationObject: any): void;
  60170. /**
  60171. * Disposes the component and the associated ressources.
  60172. */
  60173. dispose(): void;
  60174. private _draw;
  60175. }
  60176. }
  60177. declare module BABYLON {
  60178. /** @hidden */
  60179. export var depthPixelShader: {
  60180. name: string;
  60181. shader: string;
  60182. };
  60183. }
  60184. declare module BABYLON {
  60185. /** @hidden */
  60186. export var depthVertexShader: {
  60187. name: string;
  60188. shader: string;
  60189. };
  60190. }
  60191. declare module BABYLON {
  60192. /**
  60193. * This represents a depth renderer in Babylon.
  60194. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  60195. */
  60196. export class DepthRenderer {
  60197. private _scene;
  60198. private _depthMap;
  60199. private _effect;
  60200. private readonly _storeNonLinearDepth;
  60201. private readonly _clearColor;
  60202. /** Get if the depth renderer is using packed depth or not */
  60203. readonly isPacked: boolean;
  60204. private _cachedDefines;
  60205. private _camera;
  60206. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  60207. enabled: boolean;
  60208. /**
  60209. * Specifiess that the depth renderer will only be used within
  60210. * the camera it is created for.
  60211. * This can help forcing its rendering during the camera processing.
  60212. */
  60213. useOnlyInActiveCamera: boolean;
  60214. /** @hidden */
  60215. static _SceneComponentInitialization: (scene: Scene) => void;
  60216. /**
  60217. * Instantiates a depth renderer
  60218. * @param scene The scene the renderer belongs to
  60219. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  60220. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  60221. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  60222. */
  60223. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  60224. /**
  60225. * Creates the depth rendering effect and checks if the effect is ready.
  60226. * @param subMesh The submesh to be used to render the depth map of
  60227. * @param useInstances If multiple world instances should be used
  60228. * @returns if the depth renderer is ready to render the depth map
  60229. */
  60230. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  60231. /**
  60232. * Gets the texture which the depth map will be written to.
  60233. * @returns The depth map texture
  60234. */
  60235. getDepthMap(): RenderTargetTexture;
  60236. /**
  60237. * Disposes of the depth renderer.
  60238. */
  60239. dispose(): void;
  60240. }
  60241. }
  60242. declare module BABYLON {
  60243. /** @hidden */
  60244. export var minmaxReduxPixelShader: {
  60245. name: string;
  60246. shader: string;
  60247. };
  60248. }
  60249. declare module BABYLON {
  60250. /**
  60251. * This class computes a min/max reduction from a texture: it means it computes the minimum
  60252. * and maximum values from all values of the texture.
  60253. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  60254. * The source values are read from the red channel of the texture.
  60255. */
  60256. export class MinMaxReducer {
  60257. /**
  60258. * Observable triggered when the computation has been performed
  60259. */
  60260. onAfterReductionPerformed: Observable<{
  60261. min: number;
  60262. max: number;
  60263. }>;
  60264. protected _camera: Camera;
  60265. protected _sourceTexture: Nullable<RenderTargetTexture>;
  60266. protected _reductionSteps: Nullable<Array<PostProcess>>;
  60267. protected _postProcessManager: PostProcessManager;
  60268. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  60269. protected _forceFullscreenViewport: boolean;
  60270. /**
  60271. * Creates a min/max reducer
  60272. * @param camera The camera to use for the post processes
  60273. */
  60274. constructor(camera: Camera);
  60275. /**
  60276. * Gets the texture used to read the values from.
  60277. */
  60278. get sourceTexture(): Nullable<RenderTargetTexture>;
  60279. /**
  60280. * Sets the source texture to read the values from.
  60281. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  60282. * because in such textures '1' value must not be taken into account to compute the maximum
  60283. * as this value is used to clear the texture.
  60284. * Note that the computation is not activated by calling this function, you must call activate() for that!
  60285. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  60286. * @param depthRedux Indicates if the texture is a depth texture or not
  60287. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  60288. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  60289. */
  60290. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  60291. /**
  60292. * Defines the refresh rate of the computation.
  60293. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  60294. */
  60295. get refreshRate(): number;
  60296. set refreshRate(value: number);
  60297. protected _activated: boolean;
  60298. /**
  60299. * Gets the activation status of the reducer
  60300. */
  60301. get activated(): boolean;
  60302. /**
  60303. * Activates the reduction computation.
  60304. * When activated, the observers registered in onAfterReductionPerformed are
  60305. * called after the compuation is performed
  60306. */
  60307. activate(): void;
  60308. /**
  60309. * Deactivates the reduction computation.
  60310. */
  60311. deactivate(): void;
  60312. /**
  60313. * Disposes the min/max reducer
  60314. * @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.
  60315. */
  60316. dispose(disposeAll?: boolean): void;
  60317. }
  60318. }
  60319. declare module BABYLON {
  60320. /**
  60321. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  60322. */
  60323. export class DepthReducer extends MinMaxReducer {
  60324. private _depthRenderer;
  60325. private _depthRendererId;
  60326. /**
  60327. * Gets the depth renderer used for the computation.
  60328. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  60329. */
  60330. get depthRenderer(): Nullable<DepthRenderer>;
  60331. /**
  60332. * Creates a depth reducer
  60333. * @param camera The camera used to render the depth texture
  60334. */
  60335. constructor(camera: Camera);
  60336. /**
  60337. * Sets the depth renderer to use to generate the depth map
  60338. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  60339. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  60340. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  60341. */
  60342. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  60343. /** @hidden */
  60344. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  60345. /**
  60346. * Activates the reduction computation.
  60347. * When activated, the observers registered in onAfterReductionPerformed are
  60348. * called after the compuation is performed
  60349. */
  60350. activate(): void;
  60351. /**
  60352. * Deactivates the reduction computation.
  60353. */
  60354. deactivate(): void;
  60355. /**
  60356. * Disposes the depth reducer
  60357. * @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.
  60358. */
  60359. dispose(disposeAll?: boolean): void;
  60360. }
  60361. }
  60362. declare module BABYLON {
  60363. /**
  60364. * A CSM implementation allowing casting shadows on large scenes.
  60365. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  60366. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  60367. */
  60368. export class CascadedShadowGenerator extends ShadowGenerator {
  60369. private static readonly frustumCornersNDCSpace;
  60370. /**
  60371. * Name of the CSM class
  60372. */
  60373. static CLASSNAME: string;
  60374. /**
  60375. * Defines the default number of cascades used by the CSM.
  60376. */
  60377. static readonly DEFAULT_CASCADES_COUNT: number;
  60378. /**
  60379. * Defines the minimum number of cascades used by the CSM.
  60380. */
  60381. static readonly MIN_CASCADES_COUNT: number;
  60382. /**
  60383. * Defines the maximum number of cascades used by the CSM.
  60384. */
  60385. static readonly MAX_CASCADES_COUNT: number;
  60386. protected _validateFilter(filter: number): number;
  60387. /**
  60388. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  60389. */
  60390. penumbraDarkness: number;
  60391. private _numCascades;
  60392. /**
  60393. * Gets or set the number of cascades used by the CSM.
  60394. */
  60395. get numCascades(): number;
  60396. set numCascades(value: number);
  60397. /**
  60398. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  60399. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  60400. */
  60401. stabilizeCascades: boolean;
  60402. private _freezeShadowCastersBoundingInfo;
  60403. private _freezeShadowCastersBoundingInfoObservable;
  60404. /**
  60405. * Enables or disables the shadow casters bounding info computation.
  60406. * If your shadow casters don't move, you can disable this feature.
  60407. * If it is enabled, the bounding box computation is done every frame.
  60408. */
  60409. get freezeShadowCastersBoundingInfo(): boolean;
  60410. set freezeShadowCastersBoundingInfo(freeze: boolean);
  60411. private _scbiMin;
  60412. private _scbiMax;
  60413. protected _computeShadowCastersBoundingInfo(): void;
  60414. protected _shadowCastersBoundingInfo: BoundingInfo;
  60415. /**
  60416. * Gets or sets the shadow casters bounding info.
  60417. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  60418. * so that the system won't overwrite the bounds you provide
  60419. */
  60420. get shadowCastersBoundingInfo(): BoundingInfo;
  60421. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  60422. protected _breaksAreDirty: boolean;
  60423. protected _minDistance: number;
  60424. protected _maxDistance: number;
  60425. /**
  60426. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  60427. *
  60428. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  60429. * If you don't know these values, simply leave them to their defaults and don't call this function.
  60430. * @param min minimal distance for the breaks (default to 0.)
  60431. * @param max maximal distance for the breaks (default to 1.)
  60432. */
  60433. setMinMaxDistance(min: number, max: number): void;
  60434. /** Gets the minimal distance used in the cascade break computation */
  60435. get minDistance(): number;
  60436. /** Gets the maximal distance used in the cascade break computation */
  60437. get maxDistance(): number;
  60438. /**
  60439. * Gets the class name of that object
  60440. * @returns "CascadedShadowGenerator"
  60441. */
  60442. getClassName(): string;
  60443. private _cascadeMinExtents;
  60444. private _cascadeMaxExtents;
  60445. /**
  60446. * Gets a cascade minimum extents
  60447. * @param cascadeIndex index of the cascade
  60448. * @returns the minimum cascade extents
  60449. */
  60450. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  60451. /**
  60452. * Gets a cascade maximum extents
  60453. * @param cascadeIndex index of the cascade
  60454. * @returns the maximum cascade extents
  60455. */
  60456. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  60457. private _cascades;
  60458. private _currentLayer;
  60459. private _viewSpaceFrustumsZ;
  60460. private _viewMatrices;
  60461. private _projectionMatrices;
  60462. private _transformMatrices;
  60463. private _transformMatricesAsArray;
  60464. private _frustumLengths;
  60465. private _lightSizeUVCorrection;
  60466. private _depthCorrection;
  60467. private _frustumCornersWorldSpace;
  60468. private _frustumCenter;
  60469. private _shadowCameraPos;
  60470. private _shadowMaxZ;
  60471. /**
  60472. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  60473. * It defaults to camera.maxZ
  60474. */
  60475. get shadowMaxZ(): number;
  60476. /**
  60477. * Sets the shadow max z distance.
  60478. */
  60479. set shadowMaxZ(value: number);
  60480. protected _debug: boolean;
  60481. /**
  60482. * Gets or sets the debug flag.
  60483. * When enabled, the cascades are materialized by different colors on the screen.
  60484. */
  60485. get debug(): boolean;
  60486. set debug(dbg: boolean);
  60487. private _depthClamp;
  60488. /**
  60489. * Gets or sets the depth clamping value.
  60490. *
  60491. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  60492. * to account for the shadow casters far away.
  60493. *
  60494. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  60495. */
  60496. get depthClamp(): boolean;
  60497. set depthClamp(value: boolean);
  60498. private _cascadeBlendPercentage;
  60499. /**
  60500. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  60501. * It defaults to 0.1 (10% blending).
  60502. */
  60503. get cascadeBlendPercentage(): number;
  60504. set cascadeBlendPercentage(value: number);
  60505. private _lambda;
  60506. /**
  60507. * Gets or set the lambda parameter.
  60508. * This parameter is used to split the camera frustum and create the cascades.
  60509. * 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.
  60510. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  60511. */
  60512. get lambda(): number;
  60513. set lambda(value: number);
  60514. /**
  60515. * Gets the view matrix corresponding to a given cascade
  60516. * @param cascadeNum cascade to retrieve the view matrix from
  60517. * @returns the cascade view matrix
  60518. */
  60519. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  60520. /**
  60521. * Gets the projection matrix corresponding to a given cascade
  60522. * @param cascadeNum cascade to retrieve the projection matrix from
  60523. * @returns the cascade projection matrix
  60524. */
  60525. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  60526. /**
  60527. * Gets the transformation matrix corresponding to a given cascade
  60528. * @param cascadeNum cascade to retrieve the transformation matrix from
  60529. * @returns the cascade transformation matrix
  60530. */
  60531. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  60532. private _depthRenderer;
  60533. /**
  60534. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  60535. *
  60536. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  60537. *
  60538. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  60539. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  60540. * @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
  60541. */
  60542. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  60543. private _depthReducer;
  60544. private _autoCalcDepthBounds;
  60545. /**
  60546. * Gets or sets the autoCalcDepthBounds property.
  60547. *
  60548. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  60549. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  60550. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  60551. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  60552. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  60553. */
  60554. get autoCalcDepthBounds(): boolean;
  60555. set autoCalcDepthBounds(value: boolean);
  60556. /**
  60557. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  60558. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  60559. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  60560. * for setting the refresh rate on the renderer yourself!
  60561. */
  60562. get autoCalcDepthBoundsRefreshRate(): number;
  60563. set autoCalcDepthBoundsRefreshRate(value: number);
  60564. /**
  60565. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  60566. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  60567. * you change the camera near/far planes!
  60568. */
  60569. splitFrustum(): void;
  60570. private _splitFrustum;
  60571. private _computeMatrices;
  60572. private _computeFrustumInWorldSpace;
  60573. private _computeCascadeFrustum;
  60574. /**
  60575. * Support test.
  60576. */
  60577. static get IsSupported(): boolean;
  60578. /** @hidden */
  60579. static _SceneComponentInitialization: (scene: Scene) => void;
  60580. /**
  60581. * Creates a Cascaded Shadow Generator object.
  60582. * A ShadowGenerator is the required tool to use the shadows.
  60583. * Each directional light casting shadows needs to use its own ShadowGenerator.
  60584. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  60585. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  60586. * @param light The directional light object generating the shadows.
  60587. * @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.
  60588. */
  60589. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  60590. protected _initializeGenerator(): void;
  60591. protected _createTargetRenderTexture(): void;
  60592. protected _initializeShadowMap(): void;
  60593. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  60594. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  60595. /**
  60596. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  60597. * @param defines Defines of the material we want to update
  60598. * @param lightIndex Index of the light in the enabled light list of the material
  60599. */
  60600. prepareDefines(defines: any, lightIndex: number): void;
  60601. /**
  60602. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  60603. * defined in the generator but impacting the effect).
  60604. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  60605. * @param effect The effect we are binfing the information for
  60606. */
  60607. bindShadowLight(lightIndex: string, effect: Effect): void;
  60608. /**
  60609. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  60610. * (eq to view projection * shadow projection matrices)
  60611. * @returns The transform matrix used to create the shadow map
  60612. */
  60613. getTransformMatrix(): Matrix;
  60614. /**
  60615. * Disposes the ShadowGenerator.
  60616. * Returns nothing.
  60617. */
  60618. dispose(): void;
  60619. /**
  60620. * Serializes the shadow generator setup to a json object.
  60621. * @returns The serialized JSON object
  60622. */
  60623. serialize(): any;
  60624. /**
  60625. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  60626. * @param parsedShadowGenerator The JSON object to parse
  60627. * @param scene The scene to create the shadow map for
  60628. * @returns The parsed shadow generator
  60629. */
  60630. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  60631. }
  60632. }
  60633. declare module BABYLON {
  60634. /**
  60635. * Defines the shadow generator component responsible to manage any shadow generators
  60636. * in a given scene.
  60637. */
  60638. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  60639. /**
  60640. * The component name helpfull to identify the component in the list of scene components.
  60641. */
  60642. readonly name: string;
  60643. /**
  60644. * The scene the component belongs to.
  60645. */
  60646. scene: Scene;
  60647. /**
  60648. * Creates a new instance of the component for the given scene
  60649. * @param scene Defines the scene to register the component in
  60650. */
  60651. constructor(scene: Scene);
  60652. /**
  60653. * Registers the component in a given scene
  60654. */
  60655. register(): void;
  60656. /**
  60657. * Rebuilds the elements related to this component in case of
  60658. * context lost for instance.
  60659. */
  60660. rebuild(): void;
  60661. /**
  60662. * Serializes the component data to the specified json object
  60663. * @param serializationObject The object to serialize to
  60664. */
  60665. serialize(serializationObject: any): void;
  60666. /**
  60667. * Adds all the elements from the container to the scene
  60668. * @param container the container holding the elements
  60669. */
  60670. addFromContainer(container: AbstractScene): void;
  60671. /**
  60672. * Removes all the elements in the container from the scene
  60673. * @param container contains the elements to remove
  60674. * @param dispose if the removed element should be disposed (default: false)
  60675. */
  60676. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  60677. /**
  60678. * Rebuilds the elements related to this component in case of
  60679. * context lost for instance.
  60680. */
  60681. dispose(): void;
  60682. private _gatherRenderTargets;
  60683. }
  60684. }
  60685. declare module BABYLON {
  60686. /**
  60687. * A point light is a light defined by an unique point in world space.
  60688. * The light is emitted in every direction from this point.
  60689. * A good example of a point light is a standard light bulb.
  60690. * Documentation: https://doc.babylonjs.com/babylon101/lights
  60691. */
  60692. export class PointLight extends ShadowLight {
  60693. private _shadowAngle;
  60694. /**
  60695. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  60696. * This specifies what angle the shadow will use to be created.
  60697. *
  60698. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  60699. */
  60700. get shadowAngle(): number;
  60701. /**
  60702. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  60703. * This specifies what angle the shadow will use to be created.
  60704. *
  60705. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  60706. */
  60707. set shadowAngle(value: number);
  60708. /**
  60709. * Gets the direction if it has been set.
  60710. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  60711. */
  60712. get direction(): Vector3;
  60713. /**
  60714. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  60715. */
  60716. set direction(value: Vector3);
  60717. /**
  60718. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  60719. * A PointLight emits the light in every direction.
  60720. * It can cast shadows.
  60721. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  60722. * ```javascript
  60723. * var pointLight = new PointLight("pl", camera.position, scene);
  60724. * ```
  60725. * Documentation : https://doc.babylonjs.com/babylon101/lights
  60726. * @param name The light friendly name
  60727. * @param position The position of the point light in the scene
  60728. * @param scene The scene the lights belongs to
  60729. */
  60730. constructor(name: string, position: Vector3, scene: Scene);
  60731. /**
  60732. * Returns the string "PointLight"
  60733. * @returns the class name
  60734. */
  60735. getClassName(): string;
  60736. /**
  60737. * Returns the integer 0.
  60738. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  60739. */
  60740. getTypeID(): number;
  60741. /**
  60742. * Specifies wether or not the shadowmap should be a cube texture.
  60743. * @returns true if the shadowmap needs to be a cube texture.
  60744. */
  60745. needCube(): boolean;
  60746. /**
  60747. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  60748. * @param faceIndex The index of the face we are computed the direction to generate shadow
  60749. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  60750. */
  60751. getShadowDirection(faceIndex?: number): Vector3;
  60752. /**
  60753. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  60754. * - fov = PI / 2
  60755. * - aspect ratio : 1.0
  60756. * - z-near and far equal to the active camera minZ and maxZ.
  60757. * Returns the PointLight.
  60758. */
  60759. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  60760. protected _buildUniformLayout(): void;
  60761. /**
  60762. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  60763. * @param effect The effect to update
  60764. * @param lightIndex The index of the light in the effect to update
  60765. * @returns The point light
  60766. */
  60767. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  60768. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  60769. /**
  60770. * Prepares the list of defines specific to the light type.
  60771. * @param defines the list of defines
  60772. * @param lightIndex defines the index of the light for the effect
  60773. */
  60774. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  60775. }
  60776. }
  60777. declare module BABYLON {
  60778. /**
  60779. * Header information of HDR texture files.
  60780. */
  60781. export interface HDRInfo {
  60782. /**
  60783. * The height of the texture in pixels.
  60784. */
  60785. height: number;
  60786. /**
  60787. * The width of the texture in pixels.
  60788. */
  60789. width: number;
  60790. /**
  60791. * The index of the beginning of the data in the binary file.
  60792. */
  60793. dataPosition: number;
  60794. }
  60795. /**
  60796. * This groups tools to convert HDR texture to native colors array.
  60797. */
  60798. export class HDRTools {
  60799. private static Ldexp;
  60800. private static Rgbe2float;
  60801. private static readStringLine;
  60802. /**
  60803. * Reads header information from an RGBE texture stored in a native array.
  60804. * More information on this format are available here:
  60805. * https://en.wikipedia.org/wiki/RGBE_image_format
  60806. *
  60807. * @param uint8array The binary file stored in native array.
  60808. * @return The header information.
  60809. */
  60810. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  60811. /**
  60812. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  60813. * This RGBE texture needs to store the information as a panorama.
  60814. *
  60815. * More information on this format are available here:
  60816. * https://en.wikipedia.org/wiki/RGBE_image_format
  60817. *
  60818. * @param buffer The binary file stored in an array buffer.
  60819. * @param size The expected size of the extracted cubemap.
  60820. * @return The Cube Map information.
  60821. */
  60822. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  60823. /**
  60824. * Returns the pixels data extracted from an RGBE texture.
  60825. * This pixels will be stored left to right up to down in the R G B order in one array.
  60826. *
  60827. * More information on this format are available here:
  60828. * https://en.wikipedia.org/wiki/RGBE_image_format
  60829. *
  60830. * @param uint8array The binary file stored in an array buffer.
  60831. * @param hdrInfo The header information of the file.
  60832. * @return The pixels data in RGB right to left up to down order.
  60833. */
  60834. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  60835. private static RGBE_ReadPixels_RLE;
  60836. private static RGBE_ReadPixels_NOT_RLE;
  60837. }
  60838. }
  60839. declare module BABYLON {
  60840. /**
  60841. * Effect Render Options
  60842. */
  60843. export interface IEffectRendererOptions {
  60844. /**
  60845. * Defines the vertices positions.
  60846. */
  60847. positions?: number[];
  60848. /**
  60849. * Defines the indices.
  60850. */
  60851. indices?: number[];
  60852. }
  60853. /**
  60854. * Helper class to render one or more effects.
  60855. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  60856. */
  60857. export class EffectRenderer {
  60858. private engine;
  60859. private static _DefaultOptions;
  60860. private _vertexBuffers;
  60861. private _indexBuffer;
  60862. private _fullscreenViewport;
  60863. /**
  60864. * Creates an effect renderer
  60865. * @param engine the engine to use for rendering
  60866. * @param options defines the options of the effect renderer
  60867. */
  60868. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  60869. /**
  60870. * Sets the current viewport in normalized coordinates 0-1
  60871. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  60872. */
  60873. setViewport(viewport?: Viewport): void;
  60874. /**
  60875. * Binds the embedded attributes buffer to the effect.
  60876. * @param effect Defines the effect to bind the attributes for
  60877. */
  60878. bindBuffers(effect: Effect): void;
  60879. /**
  60880. * Sets the current effect wrapper to use during draw.
  60881. * The effect needs to be ready before calling this api.
  60882. * This also sets the default full screen position attribute.
  60883. * @param effectWrapper Defines the effect to draw with
  60884. */
  60885. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  60886. /**
  60887. * Restores engine states
  60888. */
  60889. restoreStates(): void;
  60890. /**
  60891. * Draws a full screen quad.
  60892. */
  60893. draw(): void;
  60894. private isRenderTargetTexture;
  60895. /**
  60896. * renders one or more effects to a specified texture
  60897. * @param effectWrapper the effect to renderer
  60898. * @param outputTexture texture to draw to, if null it will render to the screen.
  60899. */
  60900. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  60901. /**
  60902. * Disposes of the effect renderer
  60903. */
  60904. dispose(): void;
  60905. }
  60906. /**
  60907. * Options to create an EffectWrapper
  60908. */
  60909. interface EffectWrapperCreationOptions {
  60910. /**
  60911. * Engine to use to create the effect
  60912. */
  60913. engine: ThinEngine;
  60914. /**
  60915. * Fragment shader for the effect
  60916. */
  60917. fragmentShader: string;
  60918. /**
  60919. * Use the shader store instead of direct source code
  60920. */
  60921. useShaderStore?: boolean;
  60922. /**
  60923. * Vertex shader for the effect
  60924. */
  60925. vertexShader?: string;
  60926. /**
  60927. * Attributes to use in the shader
  60928. */
  60929. attributeNames?: Array<string>;
  60930. /**
  60931. * Uniforms to use in the shader
  60932. */
  60933. uniformNames?: Array<string>;
  60934. /**
  60935. * Texture sampler names to use in the shader
  60936. */
  60937. samplerNames?: Array<string>;
  60938. /**
  60939. * Defines to use in the shader
  60940. */
  60941. defines?: Array<string>;
  60942. /**
  60943. * Callback when effect is compiled
  60944. */
  60945. onCompiled?: Nullable<(effect: Effect) => void>;
  60946. /**
  60947. * The friendly name of the effect displayed in Spector.
  60948. */
  60949. name?: string;
  60950. }
  60951. /**
  60952. * Wraps an effect to be used for rendering
  60953. */
  60954. export class EffectWrapper {
  60955. /**
  60956. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  60957. */
  60958. onApplyObservable: Observable<{}>;
  60959. /**
  60960. * The underlying effect
  60961. */
  60962. effect: Effect;
  60963. /**
  60964. * Creates an effect to be renderer
  60965. * @param creationOptions options to create the effect
  60966. */
  60967. constructor(creationOptions: EffectWrapperCreationOptions);
  60968. /**
  60969. * Disposes of the effect wrapper
  60970. */
  60971. dispose(): void;
  60972. }
  60973. }
  60974. declare module BABYLON {
  60975. /** @hidden */
  60976. export var hdrFilteringVertexShader: {
  60977. name: string;
  60978. shader: string;
  60979. };
  60980. }
  60981. declare module BABYLON {
  60982. /** @hidden */
  60983. export var hdrFilteringPixelShader: {
  60984. name: string;
  60985. shader: string;
  60986. };
  60987. }
  60988. declare module BABYLON {
  60989. /**
  60990. * Options for texture filtering
  60991. */
  60992. interface IHDRFilteringOptions {
  60993. /**
  60994. * Scales pixel intensity for the input HDR map.
  60995. */
  60996. hdrScale?: number;
  60997. /**
  60998. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  60999. */
  61000. quality?: number;
  61001. }
  61002. /**
  61003. * Filters HDR maps to get correct renderings of PBR reflections
  61004. */
  61005. export class HDRFiltering {
  61006. private _engine;
  61007. private _effectRenderer;
  61008. private _effectWrapper;
  61009. private _lodGenerationOffset;
  61010. private _lodGenerationScale;
  61011. /**
  61012. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  61013. * you care about baking speed.
  61014. */
  61015. quality: number;
  61016. /**
  61017. * Scales pixel intensity for the input HDR map.
  61018. */
  61019. hdrScale: number;
  61020. /**
  61021. * Instantiates HDR filter for reflection maps
  61022. *
  61023. * @param engine Thin engine
  61024. * @param options Options
  61025. */
  61026. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  61027. private _createRenderTarget;
  61028. private _prefilterInternal;
  61029. private _createEffect;
  61030. /**
  61031. * Get a value indicating if the filter is ready to be used
  61032. * @param texture Texture to filter
  61033. * @returns true if the filter is ready
  61034. */
  61035. isReady(texture: BaseTexture): boolean;
  61036. /**
  61037. * Prefilters a cube texture to have mipmap levels representing roughness values.
  61038. * Prefiltering will be invoked at the end of next rendering pass.
  61039. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  61040. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  61041. * @param texture Texture to filter
  61042. * @param onFinished Callback when filtering is done
  61043. * @return Promise called when prefiltering is done
  61044. */
  61045. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  61046. }
  61047. }
  61048. declare module BABYLON {
  61049. /**
  61050. * This represents a texture coming from an HDR input.
  61051. *
  61052. * The only supported format is currently panorama picture stored in RGBE format.
  61053. * Example of such files can be found on HDRLib: http://hdrlib.com/
  61054. */
  61055. export class HDRCubeTexture extends BaseTexture {
  61056. private static _facesMapping;
  61057. private _generateHarmonics;
  61058. private _noMipmap;
  61059. private _prefilterOnLoad;
  61060. private _textureMatrix;
  61061. private _size;
  61062. private _onLoad;
  61063. private _onError;
  61064. /**
  61065. * The texture URL.
  61066. */
  61067. url: string;
  61068. protected _isBlocking: boolean;
  61069. /**
  61070. * Sets wether or not the texture is blocking during loading.
  61071. */
  61072. set isBlocking(value: boolean);
  61073. /**
  61074. * Gets wether or not the texture is blocking during loading.
  61075. */
  61076. get isBlocking(): boolean;
  61077. protected _rotationY: number;
  61078. /**
  61079. * Sets texture matrix rotation angle around Y axis in radians.
  61080. */
  61081. set rotationY(value: number);
  61082. /**
  61083. * Gets texture matrix rotation angle around Y axis radians.
  61084. */
  61085. get rotationY(): number;
  61086. /**
  61087. * Gets or sets the center of the bounding box associated with the cube texture
  61088. * It must define where the camera used to render the texture was set
  61089. */
  61090. boundingBoxPosition: Vector3;
  61091. private _boundingBoxSize;
  61092. /**
  61093. * Gets or sets the size of the bounding box associated with the cube texture
  61094. * When defined, the cubemap will switch to local mode
  61095. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  61096. * @example https://www.babylonjs-playground.com/#RNASML
  61097. */
  61098. set boundingBoxSize(value: Vector3);
  61099. get boundingBoxSize(): Vector3;
  61100. /**
  61101. * Instantiates an HDRTexture from the following parameters.
  61102. *
  61103. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  61104. * @param sceneOrEngine The scene or engine the texture will be used in
  61105. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  61106. * @param noMipmap Forces to not generate the mipmap if true
  61107. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  61108. * @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)
  61109. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  61110. */
  61111. 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>);
  61112. /**
  61113. * Get the current class name of the texture useful for serialization or dynamic coding.
  61114. * @returns "HDRCubeTexture"
  61115. */
  61116. getClassName(): string;
  61117. /**
  61118. * Occurs when the file is raw .hdr file.
  61119. */
  61120. private loadTexture;
  61121. clone(): HDRCubeTexture;
  61122. delayLoad(): void;
  61123. /**
  61124. * Get the texture reflection matrix used to rotate/transform the reflection.
  61125. * @returns the reflection matrix
  61126. */
  61127. getReflectionTextureMatrix(): Matrix;
  61128. /**
  61129. * Set the texture reflection matrix used to rotate/transform the reflection.
  61130. * @param value Define the reflection matrix to set
  61131. */
  61132. setReflectionTextureMatrix(value: Matrix): void;
  61133. /**
  61134. * Parses a JSON representation of an HDR Texture in order to create the texture
  61135. * @param parsedTexture Define the JSON representation
  61136. * @param scene Define the scene the texture should be created in
  61137. * @param rootUrl Define the root url in case we need to load relative dependencies
  61138. * @returns the newly created texture after parsing
  61139. */
  61140. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  61141. serialize(): any;
  61142. }
  61143. }
  61144. declare module BABYLON {
  61145. /**
  61146. * Class used to control physics engine
  61147. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  61148. */
  61149. export class PhysicsEngine implements IPhysicsEngine {
  61150. private _physicsPlugin;
  61151. /**
  61152. * Global value used to control the smallest number supported by the simulation
  61153. */
  61154. static Epsilon: number;
  61155. private _impostors;
  61156. private _joints;
  61157. private _subTimeStep;
  61158. /**
  61159. * Gets the gravity vector used by the simulation
  61160. */
  61161. gravity: Vector3;
  61162. /**
  61163. * Factory used to create the default physics plugin.
  61164. * @returns The default physics plugin
  61165. */
  61166. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  61167. /**
  61168. * Creates a new Physics Engine
  61169. * @param gravity defines the gravity vector used by the simulation
  61170. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  61171. */
  61172. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  61173. /**
  61174. * Sets the gravity vector used by the simulation
  61175. * @param gravity defines the gravity vector to use
  61176. */
  61177. setGravity(gravity: Vector3): void;
  61178. /**
  61179. * Set the time step of the physics engine.
  61180. * Default is 1/60.
  61181. * To slow it down, enter 1/600 for example.
  61182. * To speed it up, 1/30
  61183. * @param newTimeStep defines the new timestep to apply to this world.
  61184. */
  61185. setTimeStep(newTimeStep?: number): void;
  61186. /**
  61187. * Get the time step of the physics engine.
  61188. * @returns the current time step
  61189. */
  61190. getTimeStep(): number;
  61191. /**
  61192. * Set the sub time step of the physics engine.
  61193. * Default is 0 meaning there is no sub steps
  61194. * To increase physics resolution precision, set a small value (like 1 ms)
  61195. * @param subTimeStep defines the new sub timestep used for physics resolution.
  61196. */
  61197. setSubTimeStep(subTimeStep?: number): void;
  61198. /**
  61199. * Get the sub time step of the physics engine.
  61200. * @returns the current sub time step
  61201. */
  61202. getSubTimeStep(): number;
  61203. /**
  61204. * Release all resources
  61205. */
  61206. dispose(): void;
  61207. /**
  61208. * Gets the name of the current physics plugin
  61209. * @returns the name of the plugin
  61210. */
  61211. getPhysicsPluginName(): string;
  61212. /**
  61213. * Adding a new impostor for the impostor tracking.
  61214. * This will be done by the impostor itself.
  61215. * @param impostor the impostor to add
  61216. */
  61217. addImpostor(impostor: PhysicsImpostor): void;
  61218. /**
  61219. * Remove an impostor from the engine.
  61220. * This impostor and its mesh will not longer be updated by the physics engine.
  61221. * @param impostor the impostor to remove
  61222. */
  61223. removeImpostor(impostor: PhysicsImpostor): void;
  61224. /**
  61225. * Add a joint to the physics engine
  61226. * @param mainImpostor defines the main impostor to which the joint is added.
  61227. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  61228. * @param joint defines the joint that will connect both impostors.
  61229. */
  61230. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  61231. /**
  61232. * Removes a joint from the simulation
  61233. * @param mainImpostor defines the impostor used with the joint
  61234. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  61235. * @param joint defines the joint to remove
  61236. */
  61237. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  61238. /**
  61239. * Called by the scene. No need to call it.
  61240. * @param delta defines the timespam between frames
  61241. */
  61242. _step(delta: number): void;
  61243. /**
  61244. * Gets the current plugin used to run the simulation
  61245. * @returns current plugin
  61246. */
  61247. getPhysicsPlugin(): IPhysicsEnginePlugin;
  61248. /**
  61249. * Gets the list of physic impostors
  61250. * @returns an array of PhysicsImpostor
  61251. */
  61252. getImpostors(): Array<PhysicsImpostor>;
  61253. /**
  61254. * Gets the impostor for a physics enabled object
  61255. * @param object defines the object impersonated by the impostor
  61256. * @returns the PhysicsImpostor or null if not found
  61257. */
  61258. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  61259. /**
  61260. * Gets the impostor for a physics body object
  61261. * @param body defines physics body used by the impostor
  61262. * @returns the PhysicsImpostor or null if not found
  61263. */
  61264. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  61265. /**
  61266. * Does a raycast in the physics world
  61267. * @param from when should the ray start?
  61268. * @param to when should the ray end?
  61269. * @returns PhysicsRaycastResult
  61270. */
  61271. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  61272. }
  61273. }
  61274. declare module BABYLON {
  61275. /** @hidden */
  61276. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  61277. private _useDeltaForWorldStep;
  61278. world: any;
  61279. name: string;
  61280. private _physicsMaterials;
  61281. private _fixedTimeStep;
  61282. private _cannonRaycastResult;
  61283. private _raycastResult;
  61284. private _physicsBodysToRemoveAfterStep;
  61285. private _firstFrame;
  61286. BJSCANNON: any;
  61287. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  61288. setGravity(gravity: Vector3): void;
  61289. setTimeStep(timeStep: number): void;
  61290. getTimeStep(): number;
  61291. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  61292. private _removeMarkedPhysicsBodiesFromWorld;
  61293. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61294. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61295. generatePhysicsBody(impostor: PhysicsImpostor): void;
  61296. private _processChildMeshes;
  61297. removePhysicsBody(impostor: PhysicsImpostor): void;
  61298. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  61299. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  61300. private _addMaterial;
  61301. private _checkWithEpsilon;
  61302. private _createShape;
  61303. private _createHeightmap;
  61304. private _minus90X;
  61305. private _plus90X;
  61306. private _tmpPosition;
  61307. private _tmpDeltaPosition;
  61308. private _tmpUnityRotation;
  61309. private _updatePhysicsBodyTransformation;
  61310. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  61311. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  61312. isSupported(): boolean;
  61313. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61314. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61315. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61316. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61317. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  61318. getBodyMass(impostor: PhysicsImpostor): number;
  61319. getBodyFriction(impostor: PhysicsImpostor): number;
  61320. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  61321. getBodyRestitution(impostor: PhysicsImpostor): number;
  61322. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  61323. sleepBody(impostor: PhysicsImpostor): void;
  61324. wakeUpBody(impostor: PhysicsImpostor): void;
  61325. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  61326. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  61327. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  61328. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  61329. getRadius(impostor: PhysicsImpostor): number;
  61330. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  61331. dispose(): void;
  61332. private _extendNamespace;
  61333. /**
  61334. * Does a raycast in the physics world
  61335. * @param from when should the ray start?
  61336. * @param to when should the ray end?
  61337. * @returns PhysicsRaycastResult
  61338. */
  61339. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  61340. }
  61341. }
  61342. declare module BABYLON {
  61343. /** @hidden */
  61344. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  61345. private _useDeltaForWorldStep;
  61346. world: any;
  61347. name: string;
  61348. BJSOIMO: any;
  61349. private _raycastResult;
  61350. private _fixedTimeStep;
  61351. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  61352. setGravity(gravity: Vector3): void;
  61353. setTimeStep(timeStep: number): void;
  61354. getTimeStep(): number;
  61355. private _tmpImpostorsArray;
  61356. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  61357. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61358. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61359. generatePhysicsBody(impostor: PhysicsImpostor): void;
  61360. private _tmpPositionVector;
  61361. removePhysicsBody(impostor: PhysicsImpostor): void;
  61362. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  61363. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  61364. isSupported(): boolean;
  61365. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  61366. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  61367. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61368. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61369. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61370. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61371. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  61372. getBodyMass(impostor: PhysicsImpostor): number;
  61373. getBodyFriction(impostor: PhysicsImpostor): number;
  61374. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  61375. getBodyRestitution(impostor: PhysicsImpostor): number;
  61376. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  61377. sleepBody(impostor: PhysicsImpostor): void;
  61378. wakeUpBody(impostor: PhysicsImpostor): void;
  61379. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  61380. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  61381. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  61382. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  61383. getRadius(impostor: PhysicsImpostor): number;
  61384. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  61385. dispose(): void;
  61386. /**
  61387. * Does a raycast in the physics world
  61388. * @param from when should the ray start?
  61389. * @param to when should the ray end?
  61390. * @returns PhysicsRaycastResult
  61391. */
  61392. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  61393. }
  61394. }
  61395. declare module BABYLON {
  61396. /**
  61397. * AmmoJS Physics plugin
  61398. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  61399. * @see https://github.com/kripken/ammo.js/
  61400. */
  61401. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  61402. private _useDeltaForWorldStep;
  61403. /**
  61404. * Reference to the Ammo library
  61405. */
  61406. bjsAMMO: any;
  61407. /**
  61408. * Created ammoJS world which physics bodies are added to
  61409. */
  61410. world: any;
  61411. /**
  61412. * Name of the plugin
  61413. */
  61414. name: string;
  61415. private _timeStep;
  61416. private _fixedTimeStep;
  61417. private _maxSteps;
  61418. private _tmpQuaternion;
  61419. private _tmpAmmoTransform;
  61420. private _tmpAmmoQuaternion;
  61421. private _tmpAmmoConcreteContactResultCallback;
  61422. private _collisionConfiguration;
  61423. private _dispatcher;
  61424. private _overlappingPairCache;
  61425. private _solver;
  61426. private _softBodySolver;
  61427. private _tmpAmmoVectorA;
  61428. private _tmpAmmoVectorB;
  61429. private _tmpAmmoVectorC;
  61430. private _tmpAmmoVectorD;
  61431. private _tmpContactCallbackResult;
  61432. private _tmpAmmoVectorRCA;
  61433. private _tmpAmmoVectorRCB;
  61434. private _raycastResult;
  61435. private static readonly DISABLE_COLLISION_FLAG;
  61436. private static readonly KINEMATIC_FLAG;
  61437. private static readonly DISABLE_DEACTIVATION_FLAG;
  61438. /**
  61439. * Initializes the ammoJS plugin
  61440. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  61441. * @param ammoInjection can be used to inject your own ammo reference
  61442. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  61443. */
  61444. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  61445. /**
  61446. * Sets the gravity of the physics world (m/(s^2))
  61447. * @param gravity Gravity to set
  61448. */
  61449. setGravity(gravity: Vector3): void;
  61450. /**
  61451. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  61452. * @param timeStep timestep to use in seconds
  61453. */
  61454. setTimeStep(timeStep: number): void;
  61455. /**
  61456. * 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)
  61457. * @param fixedTimeStep fixedTimeStep to use in seconds
  61458. */
  61459. setFixedTimeStep(fixedTimeStep: number): void;
  61460. /**
  61461. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  61462. * @param maxSteps the maximum number of steps by the physics engine per frame
  61463. */
  61464. setMaxSteps(maxSteps: number): void;
  61465. /**
  61466. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  61467. * @returns the current timestep in seconds
  61468. */
  61469. getTimeStep(): number;
  61470. /**
  61471. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  61472. */
  61473. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  61474. private _isImpostorInContact;
  61475. private _isImpostorPairInContact;
  61476. private _stepSimulation;
  61477. /**
  61478. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  61479. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  61480. * After the step the babylon meshes are set to the position of the physics imposters
  61481. * @param delta amount of time to step forward
  61482. * @param impostors array of imposters to update before/after the step
  61483. */
  61484. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  61485. /**
  61486. * Update babylon mesh to match physics world object
  61487. * @param impostor imposter to match
  61488. */
  61489. private _afterSoftStep;
  61490. /**
  61491. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  61492. * @param impostor imposter to match
  61493. */
  61494. private _ropeStep;
  61495. /**
  61496. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  61497. * @param impostor imposter to match
  61498. */
  61499. private _softbodyOrClothStep;
  61500. private _tmpMatrix;
  61501. /**
  61502. * Applies an impulse on the imposter
  61503. * @param impostor imposter to apply impulse to
  61504. * @param force amount of force to be applied to the imposter
  61505. * @param contactPoint the location to apply the impulse on the imposter
  61506. */
  61507. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61508. /**
  61509. * Applies a force on the imposter
  61510. * @param impostor imposter to apply force
  61511. * @param force amount of force to be applied to the imposter
  61512. * @param contactPoint the location to apply the force on the imposter
  61513. */
  61514. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  61515. /**
  61516. * Creates a physics body using the plugin
  61517. * @param impostor the imposter to create the physics body on
  61518. */
  61519. generatePhysicsBody(impostor: PhysicsImpostor): void;
  61520. /**
  61521. * Removes the physics body from the imposter and disposes of the body's memory
  61522. * @param impostor imposter to remove the physics body from
  61523. */
  61524. removePhysicsBody(impostor: PhysicsImpostor): void;
  61525. /**
  61526. * Generates a joint
  61527. * @param impostorJoint the imposter joint to create the joint with
  61528. */
  61529. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  61530. /**
  61531. * Removes a joint
  61532. * @param impostorJoint the imposter joint to remove the joint from
  61533. */
  61534. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  61535. private _addMeshVerts;
  61536. /**
  61537. * Initialise the soft body vertices to match its object's (mesh) vertices
  61538. * Softbody vertices (nodes) are in world space and to match this
  61539. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  61540. * @param impostor to create the softbody for
  61541. */
  61542. private _softVertexData;
  61543. /**
  61544. * Create an impostor's soft body
  61545. * @param impostor to create the softbody for
  61546. */
  61547. private _createSoftbody;
  61548. /**
  61549. * Create cloth for an impostor
  61550. * @param impostor to create the softbody for
  61551. */
  61552. private _createCloth;
  61553. /**
  61554. * Create rope for an impostor
  61555. * @param impostor to create the softbody for
  61556. */
  61557. private _createRope;
  61558. /**
  61559. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  61560. * @param impostor to create the custom physics shape for
  61561. */
  61562. private _createCustom;
  61563. private _addHullVerts;
  61564. private _createShape;
  61565. /**
  61566. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  61567. * @param impostor imposter containing the physics body and babylon object
  61568. */
  61569. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  61570. /**
  61571. * Sets the babylon object's position/rotation from the physics body's position/rotation
  61572. * @param impostor imposter containing the physics body and babylon object
  61573. * @param newPosition new position
  61574. * @param newRotation new rotation
  61575. */
  61576. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  61577. /**
  61578. * If this plugin is supported
  61579. * @returns true if its supported
  61580. */
  61581. isSupported(): boolean;
  61582. /**
  61583. * Sets the linear velocity of the physics body
  61584. * @param impostor imposter to set the velocity on
  61585. * @param velocity velocity to set
  61586. */
  61587. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61588. /**
  61589. * Sets the angular velocity of the physics body
  61590. * @param impostor imposter to set the velocity on
  61591. * @param velocity velocity to set
  61592. */
  61593. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  61594. /**
  61595. * gets the linear velocity
  61596. * @param impostor imposter to get linear velocity from
  61597. * @returns linear velocity
  61598. */
  61599. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61600. /**
  61601. * gets the angular velocity
  61602. * @param impostor imposter to get angular velocity from
  61603. * @returns angular velocity
  61604. */
  61605. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  61606. /**
  61607. * Sets the mass of physics body
  61608. * @param impostor imposter to set the mass on
  61609. * @param mass mass to set
  61610. */
  61611. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  61612. /**
  61613. * Gets the mass of the physics body
  61614. * @param impostor imposter to get the mass from
  61615. * @returns mass
  61616. */
  61617. getBodyMass(impostor: PhysicsImpostor): number;
  61618. /**
  61619. * Gets friction of the impostor
  61620. * @param impostor impostor to get friction from
  61621. * @returns friction value
  61622. */
  61623. getBodyFriction(impostor: PhysicsImpostor): number;
  61624. /**
  61625. * Sets friction of the impostor
  61626. * @param impostor impostor to set friction on
  61627. * @param friction friction value
  61628. */
  61629. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  61630. /**
  61631. * Gets restitution of the impostor
  61632. * @param impostor impostor to get restitution from
  61633. * @returns restitution value
  61634. */
  61635. getBodyRestitution(impostor: PhysicsImpostor): number;
  61636. /**
  61637. * Sets resitution of the impostor
  61638. * @param impostor impostor to set resitution on
  61639. * @param restitution resitution value
  61640. */
  61641. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  61642. /**
  61643. * Gets pressure inside the impostor
  61644. * @param impostor impostor to get pressure from
  61645. * @returns pressure value
  61646. */
  61647. getBodyPressure(impostor: PhysicsImpostor): number;
  61648. /**
  61649. * Sets pressure inside a soft body impostor
  61650. * Cloth and rope must remain 0 pressure
  61651. * @param impostor impostor to set pressure on
  61652. * @param pressure pressure value
  61653. */
  61654. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  61655. /**
  61656. * Gets stiffness of the impostor
  61657. * @param impostor impostor to get stiffness from
  61658. * @returns pressure value
  61659. */
  61660. getBodyStiffness(impostor: PhysicsImpostor): number;
  61661. /**
  61662. * Sets stiffness of the impostor
  61663. * @param impostor impostor to set stiffness on
  61664. * @param stiffness stiffness value from 0 to 1
  61665. */
  61666. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  61667. /**
  61668. * Gets velocityIterations of the impostor
  61669. * @param impostor impostor to get velocity iterations from
  61670. * @returns velocityIterations value
  61671. */
  61672. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  61673. /**
  61674. * Sets velocityIterations of the impostor
  61675. * @param impostor impostor to set velocity iterations on
  61676. * @param velocityIterations velocityIterations value
  61677. */
  61678. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  61679. /**
  61680. * Gets positionIterations of the impostor
  61681. * @param impostor impostor to get position iterations from
  61682. * @returns positionIterations value
  61683. */
  61684. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  61685. /**
  61686. * Sets positionIterations of the impostor
  61687. * @param impostor impostor to set position on
  61688. * @param positionIterations positionIterations value
  61689. */
  61690. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  61691. /**
  61692. * Append an anchor to a cloth object
  61693. * @param impostor is the cloth impostor to add anchor to
  61694. * @param otherImpostor is the rigid impostor to anchor to
  61695. * @param width ratio across width from 0 to 1
  61696. * @param height ratio up height from 0 to 1
  61697. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  61698. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  61699. */
  61700. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  61701. /**
  61702. * Append an hook to a rope object
  61703. * @param impostor is the rope impostor to add hook to
  61704. * @param otherImpostor is the rigid impostor to hook to
  61705. * @param length ratio along the rope from 0 to 1
  61706. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  61707. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  61708. */
  61709. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  61710. /**
  61711. * Sleeps the physics body and stops it from being active
  61712. * @param impostor impostor to sleep
  61713. */
  61714. sleepBody(impostor: PhysicsImpostor): void;
  61715. /**
  61716. * Activates the physics body
  61717. * @param impostor impostor to activate
  61718. */
  61719. wakeUpBody(impostor: PhysicsImpostor): void;
  61720. /**
  61721. * Updates the distance parameters of the joint
  61722. * @param joint joint to update
  61723. * @param maxDistance maximum distance of the joint
  61724. * @param minDistance minimum distance of the joint
  61725. */
  61726. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  61727. /**
  61728. * Sets a motor on the joint
  61729. * @param joint joint to set motor on
  61730. * @param speed speed of the motor
  61731. * @param maxForce maximum force of the motor
  61732. * @param motorIndex index of the motor
  61733. */
  61734. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  61735. /**
  61736. * Sets the motors limit
  61737. * @param joint joint to set limit on
  61738. * @param upperLimit upper limit
  61739. * @param lowerLimit lower limit
  61740. */
  61741. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  61742. /**
  61743. * Syncs the position and rotation of a mesh with the impostor
  61744. * @param mesh mesh to sync
  61745. * @param impostor impostor to update the mesh with
  61746. */
  61747. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  61748. /**
  61749. * Gets the radius of the impostor
  61750. * @param impostor impostor to get radius from
  61751. * @returns the radius
  61752. */
  61753. getRadius(impostor: PhysicsImpostor): number;
  61754. /**
  61755. * Gets the box size of the impostor
  61756. * @param impostor impostor to get box size from
  61757. * @param result the resulting box size
  61758. */
  61759. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  61760. /**
  61761. * Disposes of the impostor
  61762. */
  61763. dispose(): void;
  61764. /**
  61765. * Does a raycast in the physics world
  61766. * @param from when should the ray start?
  61767. * @param to when should the ray end?
  61768. * @returns PhysicsRaycastResult
  61769. */
  61770. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  61771. }
  61772. }
  61773. declare module BABYLON {
  61774. interface AbstractScene {
  61775. /**
  61776. * The list of reflection probes added to the scene
  61777. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  61778. */
  61779. reflectionProbes: Array<ReflectionProbe>;
  61780. /**
  61781. * Removes the given reflection probe from this scene.
  61782. * @param toRemove The reflection probe to remove
  61783. * @returns The index of the removed reflection probe
  61784. */
  61785. removeReflectionProbe(toRemove: ReflectionProbe): number;
  61786. /**
  61787. * Adds the given reflection probe to this scene.
  61788. * @param newReflectionProbe The reflection probe to add
  61789. */
  61790. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  61791. }
  61792. /**
  61793. * Class used to generate realtime reflection / refraction cube textures
  61794. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  61795. */
  61796. export class ReflectionProbe {
  61797. /** defines the name of the probe */
  61798. name: string;
  61799. private _scene;
  61800. private _renderTargetTexture;
  61801. private _projectionMatrix;
  61802. private _viewMatrix;
  61803. private _target;
  61804. private _add;
  61805. private _attachedMesh;
  61806. private _invertYAxis;
  61807. /** Gets or sets probe position (center of the cube map) */
  61808. position: Vector3;
  61809. /**
  61810. * Creates a new reflection probe
  61811. * @param name defines the name of the probe
  61812. * @param size defines the texture resolution (for each face)
  61813. * @param scene defines the hosting scene
  61814. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  61815. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  61816. */
  61817. constructor(
  61818. /** defines the name of the probe */
  61819. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  61820. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  61821. get samples(): number;
  61822. set samples(value: number);
  61823. /** Gets or sets the refresh rate to use (on every frame by default) */
  61824. get refreshRate(): number;
  61825. set refreshRate(value: number);
  61826. /**
  61827. * Gets the hosting scene
  61828. * @returns a Scene
  61829. */
  61830. getScene(): Scene;
  61831. /** Gets the internal CubeTexture used to render to */
  61832. get cubeTexture(): RenderTargetTexture;
  61833. /** Gets the list of meshes to render */
  61834. get renderList(): Nullable<AbstractMesh[]>;
  61835. /**
  61836. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  61837. * @param mesh defines the mesh to attach to
  61838. */
  61839. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  61840. /**
  61841. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  61842. * @param renderingGroupId The rendering group id corresponding to its index
  61843. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  61844. */
  61845. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  61846. /**
  61847. * Clean all associated resources
  61848. */
  61849. dispose(): void;
  61850. /**
  61851. * Converts the reflection probe information to a readable string for debug purpose.
  61852. * @param fullDetails Supports for multiple levels of logging within scene loading
  61853. * @returns the human readable reflection probe info
  61854. */
  61855. toString(fullDetails?: boolean): string;
  61856. /**
  61857. * Get the class name of the relfection probe.
  61858. * @returns "ReflectionProbe"
  61859. */
  61860. getClassName(): string;
  61861. /**
  61862. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  61863. * @returns The JSON representation of the texture
  61864. */
  61865. serialize(): any;
  61866. /**
  61867. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  61868. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  61869. * @param scene Define the scene the parsed reflection probe should be instantiated in
  61870. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  61871. * @returns The parsed reflection probe if successful
  61872. */
  61873. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  61874. }
  61875. }
  61876. declare module BABYLON {
  61877. /** @hidden */
  61878. export var _BabylonLoaderRegistered: boolean;
  61879. /**
  61880. * Helps setting up some configuration for the babylon file loader.
  61881. */
  61882. export class BabylonFileLoaderConfiguration {
  61883. /**
  61884. * The loader does not allow injecting custom physix engine into the plugins.
  61885. * Unfortunately in ES6, we need to manually inject them into the plugin.
  61886. * So you could set this variable to your engine import to make it work.
  61887. */
  61888. static LoaderInjectedPhysicsEngine: any;
  61889. }
  61890. }
  61891. declare module BABYLON {
  61892. /**
  61893. * The Physically based simple base material of BJS.
  61894. *
  61895. * This enables better naming and convention enforcements on top of the pbrMaterial.
  61896. * It is used as the base class for both the specGloss and metalRough conventions.
  61897. */
  61898. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  61899. /**
  61900. * Number of Simultaneous lights allowed on the material.
  61901. */
  61902. maxSimultaneousLights: number;
  61903. /**
  61904. * If sets to true, disables all the lights affecting the material.
  61905. */
  61906. disableLighting: boolean;
  61907. /**
  61908. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  61909. */
  61910. environmentTexture: BaseTexture;
  61911. /**
  61912. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  61913. */
  61914. invertNormalMapX: boolean;
  61915. /**
  61916. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  61917. */
  61918. invertNormalMapY: boolean;
  61919. /**
  61920. * Normal map used in the model.
  61921. */
  61922. normalTexture: BaseTexture;
  61923. /**
  61924. * Emissivie color used to self-illuminate the model.
  61925. */
  61926. emissiveColor: Color3;
  61927. /**
  61928. * Emissivie texture used to self-illuminate the model.
  61929. */
  61930. emissiveTexture: BaseTexture;
  61931. /**
  61932. * Occlusion Channel Strenght.
  61933. */
  61934. occlusionStrength: number;
  61935. /**
  61936. * Occlusion Texture of the material (adding extra occlusion effects).
  61937. */
  61938. occlusionTexture: BaseTexture;
  61939. /**
  61940. * Defines the alpha limits in alpha test mode.
  61941. */
  61942. alphaCutOff: number;
  61943. /**
  61944. * Gets the current double sided mode.
  61945. */
  61946. get doubleSided(): boolean;
  61947. /**
  61948. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  61949. */
  61950. set doubleSided(value: boolean);
  61951. /**
  61952. * Stores the pre-calculated light information of a mesh in a texture.
  61953. */
  61954. lightmapTexture: BaseTexture;
  61955. /**
  61956. * If true, the light map contains occlusion information instead of lighting info.
  61957. */
  61958. useLightmapAsShadowmap: boolean;
  61959. /**
  61960. * Instantiates a new PBRMaterial instance.
  61961. *
  61962. * @param name The material name
  61963. * @param scene The scene the material will be use in.
  61964. */
  61965. constructor(name: string, scene: Scene);
  61966. getClassName(): string;
  61967. }
  61968. }
  61969. declare module BABYLON {
  61970. /**
  61971. * The PBR material of BJS following the metal roughness convention.
  61972. *
  61973. * This fits to the PBR convention in the GLTF definition:
  61974. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  61975. */
  61976. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  61977. /**
  61978. * The base color has two different interpretations depending on the value of metalness.
  61979. * When the material is a metal, the base color is the specific measured reflectance value
  61980. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  61981. * of the material.
  61982. */
  61983. baseColor: Color3;
  61984. /**
  61985. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  61986. * well as opacity information in the alpha channel.
  61987. */
  61988. baseTexture: BaseTexture;
  61989. /**
  61990. * Specifies the metallic scalar value of the material.
  61991. * Can also be used to scale the metalness values of the metallic texture.
  61992. */
  61993. metallic: number;
  61994. /**
  61995. * Specifies the roughness scalar value of the material.
  61996. * Can also be used to scale the roughness values of the metallic texture.
  61997. */
  61998. roughness: number;
  61999. /**
  62000. * Texture containing both the metallic value in the B channel and the
  62001. * roughness value in the G channel to keep better precision.
  62002. */
  62003. metallicRoughnessTexture: BaseTexture;
  62004. /**
  62005. * Instantiates a new PBRMetalRoughnessMaterial instance.
  62006. *
  62007. * @param name The material name
  62008. * @param scene The scene the material will be use in.
  62009. */
  62010. constructor(name: string, scene: Scene);
  62011. /**
  62012. * Return the currrent class name of the material.
  62013. */
  62014. getClassName(): string;
  62015. /**
  62016. * Makes a duplicate of the current material.
  62017. * @param name - name to use for the new material.
  62018. */
  62019. clone(name: string): PBRMetallicRoughnessMaterial;
  62020. /**
  62021. * Serialize the material to a parsable JSON object.
  62022. */
  62023. serialize(): any;
  62024. /**
  62025. * Parses a JSON object correponding to the serialize function.
  62026. */
  62027. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  62028. }
  62029. }
  62030. declare module BABYLON {
  62031. /**
  62032. * The PBR material of BJS following the specular glossiness convention.
  62033. *
  62034. * This fits to the PBR convention in the GLTF definition:
  62035. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  62036. */
  62037. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  62038. /**
  62039. * Specifies the diffuse color of the material.
  62040. */
  62041. diffuseColor: Color3;
  62042. /**
  62043. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  62044. * channel.
  62045. */
  62046. diffuseTexture: BaseTexture;
  62047. /**
  62048. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  62049. */
  62050. specularColor: Color3;
  62051. /**
  62052. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  62053. */
  62054. glossiness: number;
  62055. /**
  62056. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  62057. */
  62058. specularGlossinessTexture: BaseTexture;
  62059. /**
  62060. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  62061. *
  62062. * @param name The material name
  62063. * @param scene The scene the material will be use in.
  62064. */
  62065. constructor(name: string, scene: Scene);
  62066. /**
  62067. * Return the currrent class name of the material.
  62068. */
  62069. getClassName(): string;
  62070. /**
  62071. * Makes a duplicate of the current material.
  62072. * @param name - name to use for the new material.
  62073. */
  62074. clone(name: string): PBRSpecularGlossinessMaterial;
  62075. /**
  62076. * Serialize the material to a parsable JSON object.
  62077. */
  62078. serialize(): any;
  62079. /**
  62080. * Parses a JSON object correponding to the serialize function.
  62081. */
  62082. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  62083. }
  62084. }
  62085. declare module BABYLON {
  62086. /**
  62087. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  62088. * It can help converting any input color in a desired output one. This can then be used to create effects
  62089. * from sepia, black and white to sixties or futuristic rendering...
  62090. *
  62091. * The only supported format is currently 3dl.
  62092. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  62093. */
  62094. export class ColorGradingTexture extends BaseTexture {
  62095. /**
  62096. * The texture URL.
  62097. */
  62098. url: string;
  62099. /**
  62100. * Empty line regex stored for GC.
  62101. */
  62102. private static _noneEmptyLineRegex;
  62103. private _textureMatrix;
  62104. private _onLoad;
  62105. /**
  62106. * Instantiates a ColorGradingTexture from the following parameters.
  62107. *
  62108. * @param url The location of the color gradind data (currently only supporting 3dl)
  62109. * @param sceneOrEngine The scene or engine the texture will be used in
  62110. * @param onLoad defines a callback triggered when the texture has been loaded
  62111. */
  62112. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  62113. /**
  62114. * Fires the onload event from the constructor if requested.
  62115. */
  62116. private _triggerOnLoad;
  62117. /**
  62118. * Returns the texture matrix used in most of the material.
  62119. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  62120. */
  62121. getTextureMatrix(): Matrix;
  62122. /**
  62123. * Occurs when the file being loaded is a .3dl LUT file.
  62124. */
  62125. private load3dlTexture;
  62126. /**
  62127. * Starts the loading process of the texture.
  62128. */
  62129. private loadTexture;
  62130. /**
  62131. * Clones the color gradind texture.
  62132. */
  62133. clone(): ColorGradingTexture;
  62134. /**
  62135. * Called during delayed load for textures.
  62136. */
  62137. delayLoad(): void;
  62138. /**
  62139. * Parses a color grading texture serialized by Babylon.
  62140. * @param parsedTexture The texture information being parsedTexture
  62141. * @param scene The scene to load the texture in
  62142. * @param rootUrl The root url of the data assets to load
  62143. * @return A color gradind texture
  62144. */
  62145. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  62146. /**
  62147. * Serializes the LUT texture to json format.
  62148. */
  62149. serialize(): any;
  62150. }
  62151. }
  62152. declare module BABYLON {
  62153. /**
  62154. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  62155. */
  62156. export class EquiRectangularCubeTexture extends BaseTexture {
  62157. /** The six faces of the cube. */
  62158. private static _FacesMapping;
  62159. private _noMipmap;
  62160. private _onLoad;
  62161. private _onError;
  62162. /** The size of the cubemap. */
  62163. private _size;
  62164. /** The buffer of the image. */
  62165. private _buffer;
  62166. /** The width of the input image. */
  62167. private _width;
  62168. /** The height of the input image. */
  62169. private _height;
  62170. /** The URL to the image. */
  62171. url: string;
  62172. /**
  62173. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  62174. * @param url The location of the image
  62175. * @param scene The scene the texture will be used in
  62176. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  62177. * @param noMipmap Forces to not generate the mipmap if true
  62178. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  62179. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  62180. * @param onLoad — defines a callback called when texture is loaded
  62181. * @param onError — defines a callback called if there is an error
  62182. */
  62183. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  62184. /**
  62185. * Load the image data, by putting the image on a canvas and extracting its buffer.
  62186. */
  62187. private loadImage;
  62188. /**
  62189. * Convert the image buffer into a cubemap and create a CubeTexture.
  62190. */
  62191. private loadTexture;
  62192. /**
  62193. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  62194. * @param buffer The ArrayBuffer that should be converted.
  62195. * @returns The buffer as Float32Array.
  62196. */
  62197. private getFloat32ArrayFromArrayBuffer;
  62198. /**
  62199. * Get the current class name of the texture useful for serialization or dynamic coding.
  62200. * @returns "EquiRectangularCubeTexture"
  62201. */
  62202. getClassName(): string;
  62203. /**
  62204. * Create a clone of the current EquiRectangularCubeTexture and return it.
  62205. * @returns A clone of the current EquiRectangularCubeTexture.
  62206. */
  62207. clone(): EquiRectangularCubeTexture;
  62208. }
  62209. }
  62210. declare module BABYLON {
  62211. /**
  62212. * Defines the options related to the creation of an HtmlElementTexture
  62213. */
  62214. export interface IHtmlElementTextureOptions {
  62215. /**
  62216. * Defines wether mip maps should be created or not.
  62217. */
  62218. generateMipMaps?: boolean;
  62219. /**
  62220. * Defines the sampling mode of the texture.
  62221. */
  62222. samplingMode?: number;
  62223. /**
  62224. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  62225. */
  62226. engine: Nullable<ThinEngine>;
  62227. /**
  62228. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  62229. */
  62230. scene: Nullable<Scene>;
  62231. }
  62232. /**
  62233. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  62234. * To be as efficient as possible depending on your constraints nothing aside the first upload
  62235. * is automatically managed.
  62236. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  62237. * in your application.
  62238. *
  62239. * As the update is not automatic, you need to call them manually.
  62240. */
  62241. export class HtmlElementTexture extends BaseTexture {
  62242. /**
  62243. * The texture URL.
  62244. */
  62245. element: HTMLVideoElement | HTMLCanvasElement;
  62246. private static readonly DefaultOptions;
  62247. private _textureMatrix;
  62248. private _isVideo;
  62249. private _generateMipMaps;
  62250. private _samplingMode;
  62251. /**
  62252. * Instantiates a HtmlElementTexture from the following parameters.
  62253. *
  62254. * @param name Defines the name of the texture
  62255. * @param element Defines the video or canvas the texture is filled with
  62256. * @param options Defines the other none mandatory texture creation options
  62257. */
  62258. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  62259. private _createInternalTexture;
  62260. /**
  62261. * Returns the texture matrix used in most of the material.
  62262. */
  62263. getTextureMatrix(): Matrix;
  62264. /**
  62265. * Updates the content of the texture.
  62266. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  62267. */
  62268. update(invertY?: Nullable<boolean>): void;
  62269. }
  62270. }
  62271. declare module BABYLON {
  62272. /**
  62273. * Based on jsTGALoader - Javascript loader for TGA file
  62274. * By Vincent Thibault
  62275. * @see http://blog.robrowser.com/javascript-tga-loader.html
  62276. */
  62277. export class TGATools {
  62278. private static _TYPE_INDEXED;
  62279. private static _TYPE_RGB;
  62280. private static _TYPE_GREY;
  62281. private static _TYPE_RLE_INDEXED;
  62282. private static _TYPE_RLE_RGB;
  62283. private static _TYPE_RLE_GREY;
  62284. private static _ORIGIN_MASK;
  62285. private static _ORIGIN_SHIFT;
  62286. private static _ORIGIN_BL;
  62287. private static _ORIGIN_BR;
  62288. private static _ORIGIN_UL;
  62289. private static _ORIGIN_UR;
  62290. /**
  62291. * Gets the header of a TGA file
  62292. * @param data defines the TGA data
  62293. * @returns the header
  62294. */
  62295. static GetTGAHeader(data: Uint8Array): any;
  62296. /**
  62297. * Uploads TGA content to a Babylon Texture
  62298. * @hidden
  62299. */
  62300. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  62301. /** @hidden */
  62302. 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;
  62303. /** @hidden */
  62304. 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;
  62305. /** @hidden */
  62306. 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;
  62307. /** @hidden */
  62308. 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;
  62309. /** @hidden */
  62310. 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;
  62311. /** @hidden */
  62312. 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;
  62313. }
  62314. }
  62315. declare module BABYLON {
  62316. /**
  62317. * Implementation of the TGA Texture Loader.
  62318. * @hidden
  62319. */
  62320. export class _TGATextureLoader implements IInternalTextureLoader {
  62321. /**
  62322. * Defines wether the loader supports cascade loading the different faces.
  62323. */
  62324. readonly supportCascades: boolean;
  62325. /**
  62326. * This returns if the loader support the current file information.
  62327. * @param extension defines the file extension of the file being loaded
  62328. * @returns true if the loader can load the specified file
  62329. */
  62330. canLoad(extension: string): boolean;
  62331. /**
  62332. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  62333. * @param data contains the texture data
  62334. * @param texture defines the BabylonJS internal texture
  62335. * @param createPolynomials will be true if polynomials have been requested
  62336. * @param onLoad defines the callback to trigger once the texture is ready
  62337. * @param onError defines the callback to trigger in case of error
  62338. */
  62339. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  62340. /**
  62341. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  62342. * @param data contains the texture data
  62343. * @param texture defines the BabylonJS internal texture
  62344. * @param callback defines the method to call once ready to upload
  62345. */
  62346. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  62347. }
  62348. }
  62349. declare module BABYLON {
  62350. /**
  62351. * Info about the .basis files
  62352. */
  62353. class BasisFileInfo {
  62354. /**
  62355. * If the file has alpha
  62356. */
  62357. hasAlpha: boolean;
  62358. /**
  62359. * Info about each image of the basis file
  62360. */
  62361. images: Array<{
  62362. levels: Array<{
  62363. width: number;
  62364. height: number;
  62365. transcodedPixels: ArrayBufferView;
  62366. }>;
  62367. }>;
  62368. }
  62369. /**
  62370. * Result of transcoding a basis file
  62371. */
  62372. class TranscodeResult {
  62373. /**
  62374. * Info about the .basis file
  62375. */
  62376. fileInfo: BasisFileInfo;
  62377. /**
  62378. * Format to use when loading the file
  62379. */
  62380. format: number;
  62381. }
  62382. /**
  62383. * Configuration options for the Basis transcoder
  62384. */
  62385. export class BasisTranscodeConfiguration {
  62386. /**
  62387. * Supported compression formats used to determine the supported output format of the transcoder
  62388. */
  62389. supportedCompressionFormats?: {
  62390. /**
  62391. * etc1 compression format
  62392. */
  62393. etc1?: boolean;
  62394. /**
  62395. * s3tc compression format
  62396. */
  62397. s3tc?: boolean;
  62398. /**
  62399. * pvrtc compression format
  62400. */
  62401. pvrtc?: boolean;
  62402. /**
  62403. * etc2 compression format
  62404. */
  62405. etc2?: boolean;
  62406. };
  62407. /**
  62408. * If mipmap levels should be loaded for transcoded images (Default: true)
  62409. */
  62410. loadMipmapLevels?: boolean;
  62411. /**
  62412. * Index of a single image to load (Default: all images)
  62413. */
  62414. loadSingleImage?: number;
  62415. }
  62416. /**
  62417. * Used to load .Basis files
  62418. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  62419. */
  62420. export class BasisTools {
  62421. private static _IgnoreSupportedFormats;
  62422. /**
  62423. * URL to use when loading the basis transcoder
  62424. */
  62425. static JSModuleURL: string;
  62426. /**
  62427. * URL to use when loading the wasm module for the transcoder
  62428. */
  62429. static WasmModuleURL: string;
  62430. /**
  62431. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  62432. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  62433. * @returns internal format corresponding to the Basis format
  62434. */
  62435. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  62436. private static _WorkerPromise;
  62437. private static _Worker;
  62438. private static _actionId;
  62439. private static _CreateWorkerAsync;
  62440. /**
  62441. * Transcodes a loaded image file to compressed pixel data
  62442. * @param data image data to transcode
  62443. * @param config configuration options for the transcoding
  62444. * @returns a promise resulting in the transcoded image
  62445. */
  62446. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  62447. /**
  62448. * Loads a texture from the transcode result
  62449. * @param texture texture load to
  62450. * @param transcodeResult the result of transcoding the basis file to load from
  62451. */
  62452. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  62453. }
  62454. }
  62455. declare module BABYLON {
  62456. /**
  62457. * Loader for .basis file format
  62458. */
  62459. export class _BasisTextureLoader implements IInternalTextureLoader {
  62460. /**
  62461. * Defines whether the loader supports cascade loading the different faces.
  62462. */
  62463. readonly supportCascades: boolean;
  62464. /**
  62465. * This returns if the loader support the current file information.
  62466. * @param extension defines the file extension of the file being loaded
  62467. * @returns true if the loader can load the specified file
  62468. */
  62469. canLoad(extension: string): boolean;
  62470. /**
  62471. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  62472. * @param data contains the texture data
  62473. * @param texture defines the BabylonJS internal texture
  62474. * @param createPolynomials will be true if polynomials have been requested
  62475. * @param onLoad defines the callback to trigger once the texture is ready
  62476. * @param onError defines the callback to trigger in case of error
  62477. */
  62478. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  62479. /**
  62480. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  62481. * @param data contains the texture data
  62482. * @param texture defines the BabylonJS internal texture
  62483. * @param callback defines the method to call once ready to upload
  62484. */
  62485. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  62486. }
  62487. }
  62488. declare module BABYLON {
  62489. /**
  62490. * Defines the basic options interface of a TexturePacker Frame
  62491. */
  62492. export interface ITexturePackerFrame {
  62493. /**
  62494. * The frame ID
  62495. */
  62496. id: number;
  62497. /**
  62498. * The frames Scale
  62499. */
  62500. scale: Vector2;
  62501. /**
  62502. * The Frames offset
  62503. */
  62504. offset: Vector2;
  62505. }
  62506. /**
  62507. * This is a support class for frame Data on texture packer sets.
  62508. */
  62509. export class TexturePackerFrame implements ITexturePackerFrame {
  62510. /**
  62511. * The frame ID
  62512. */
  62513. id: number;
  62514. /**
  62515. * The frames Scale
  62516. */
  62517. scale: Vector2;
  62518. /**
  62519. * The Frames offset
  62520. */
  62521. offset: Vector2;
  62522. /**
  62523. * Initializes a texture package frame.
  62524. * @param id The numerical frame identifier
  62525. * @param scale Scalar Vector2 for UV frame
  62526. * @param offset Vector2 for the frame position in UV units.
  62527. * @returns TexturePackerFrame
  62528. */
  62529. constructor(id: number, scale: Vector2, offset: Vector2);
  62530. }
  62531. }
  62532. declare module BABYLON {
  62533. /**
  62534. * Defines the basic options interface of a TexturePacker
  62535. */
  62536. export interface ITexturePackerOptions {
  62537. /**
  62538. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  62539. */
  62540. map?: string[];
  62541. /**
  62542. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  62543. */
  62544. uvsIn?: string;
  62545. /**
  62546. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  62547. */
  62548. uvsOut?: string;
  62549. /**
  62550. * number representing the layout style. Defaults to LAYOUT_STRIP
  62551. */
  62552. layout?: number;
  62553. /**
  62554. * number of columns if using custom column count layout(2). This defaults to 4.
  62555. */
  62556. colnum?: number;
  62557. /**
  62558. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  62559. */
  62560. updateInputMeshes?: boolean;
  62561. /**
  62562. * boolean flag to dispose all the source textures. Defaults to true.
  62563. */
  62564. disposeSources?: boolean;
  62565. /**
  62566. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  62567. */
  62568. fillBlanks?: boolean;
  62569. /**
  62570. * string value representing the context fill style color. Defaults to 'black'.
  62571. */
  62572. customFillColor?: string;
  62573. /**
  62574. * Width and Height Value of each Frame in the TexturePacker Sets
  62575. */
  62576. frameSize?: number;
  62577. /**
  62578. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  62579. */
  62580. paddingRatio?: number;
  62581. /**
  62582. * Number that declares the fill method for the padding gutter.
  62583. */
  62584. paddingMode?: number;
  62585. /**
  62586. * If in SUBUV_COLOR padding mode what color to use.
  62587. */
  62588. paddingColor?: Color3 | Color4;
  62589. }
  62590. /**
  62591. * Defines the basic interface of a TexturePacker JSON File
  62592. */
  62593. export interface ITexturePackerJSON {
  62594. /**
  62595. * The frame ID
  62596. */
  62597. name: string;
  62598. /**
  62599. * The base64 channel data
  62600. */
  62601. sets: any;
  62602. /**
  62603. * The options of the Packer
  62604. */
  62605. options: ITexturePackerOptions;
  62606. /**
  62607. * The frame data of the Packer
  62608. */
  62609. frames: Array<number>;
  62610. }
  62611. /**
  62612. * This is a support class that generates a series of packed texture sets.
  62613. * @see https://doc.babylonjs.com/babylon101/materials
  62614. */
  62615. export class TexturePacker {
  62616. /** Packer Layout Constant 0 */
  62617. static readonly LAYOUT_STRIP: number;
  62618. /** Packer Layout Constant 1 */
  62619. static readonly LAYOUT_POWER2: number;
  62620. /** Packer Layout Constant 2 */
  62621. static readonly LAYOUT_COLNUM: number;
  62622. /** Packer Layout Constant 0 */
  62623. static readonly SUBUV_WRAP: number;
  62624. /** Packer Layout Constant 1 */
  62625. static readonly SUBUV_EXTEND: number;
  62626. /** Packer Layout Constant 2 */
  62627. static readonly SUBUV_COLOR: number;
  62628. /** The Name of the Texture Package */
  62629. name: string;
  62630. /** The scene scope of the TexturePacker */
  62631. scene: Scene;
  62632. /** The Meshes to target */
  62633. meshes: AbstractMesh[];
  62634. /** Arguments passed with the Constructor */
  62635. options: ITexturePackerOptions;
  62636. /** The promise that is started upon initialization */
  62637. promise: Nullable<Promise<TexturePacker | string>>;
  62638. /** The Container object for the channel sets that are generated */
  62639. sets: object;
  62640. /** The Container array for the frames that are generated */
  62641. frames: TexturePackerFrame[];
  62642. /** The expected number of textures the system is parsing. */
  62643. private _expecting;
  62644. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  62645. private _paddingValue;
  62646. /**
  62647. * Initializes a texture package series from an array of meshes or a single mesh.
  62648. * @param name The name of the package
  62649. * @param meshes The target meshes to compose the package from
  62650. * @param options The arguments that texture packer should follow while building.
  62651. * @param scene The scene which the textures are scoped to.
  62652. * @returns TexturePacker
  62653. */
  62654. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  62655. /**
  62656. * Starts the package process
  62657. * @param resolve The promises resolution function
  62658. * @returns TexturePacker
  62659. */
  62660. private _createFrames;
  62661. /**
  62662. * Calculates the Size of the Channel Sets
  62663. * @returns Vector2
  62664. */
  62665. private _calculateSize;
  62666. /**
  62667. * Calculates the UV data for the frames.
  62668. * @param baseSize the base frameSize
  62669. * @param padding the base frame padding
  62670. * @param dtSize size of the Dynamic Texture for that channel
  62671. * @param dtUnits is 1/dtSize
  62672. * @param update flag to update the input meshes
  62673. */
  62674. private _calculateMeshUVFrames;
  62675. /**
  62676. * Calculates the frames Offset.
  62677. * @param index of the frame
  62678. * @returns Vector2
  62679. */
  62680. private _getFrameOffset;
  62681. /**
  62682. * Updates a Mesh to the frame data
  62683. * @param mesh that is the target
  62684. * @param frameID or the frame index
  62685. */
  62686. private _updateMeshUV;
  62687. /**
  62688. * Updates a Meshes materials to use the texture packer channels
  62689. * @param m is the mesh to target
  62690. * @param force all channels on the packer to be set.
  62691. */
  62692. private _updateTextureReferences;
  62693. /**
  62694. * Public method to set a Mesh to a frame
  62695. * @param m that is the target
  62696. * @param frameID or the frame index
  62697. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  62698. */
  62699. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  62700. /**
  62701. * Starts the async promise to compile the texture packer.
  62702. * @returns Promise<void>
  62703. */
  62704. processAsync(): Promise<void>;
  62705. /**
  62706. * Disposes all textures associated with this packer
  62707. */
  62708. dispose(): void;
  62709. /**
  62710. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  62711. * @param imageType is the image type to use.
  62712. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  62713. */
  62714. download(imageType?: string, quality?: number): void;
  62715. /**
  62716. * Public method to load a texturePacker JSON file.
  62717. * @param data of the JSON file in string format.
  62718. */
  62719. updateFromJSON(data: string): void;
  62720. }
  62721. }
  62722. declare module BABYLON {
  62723. /**
  62724. * 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.
  62725. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  62726. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  62727. */
  62728. export class CustomProceduralTexture extends ProceduralTexture {
  62729. private _animate;
  62730. private _time;
  62731. private _config;
  62732. private _texturePath;
  62733. /**
  62734. * Instantiates a new Custom Procedural Texture.
  62735. * 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.
  62736. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  62737. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  62738. * @param name Define the name of the texture
  62739. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  62740. * @param size Define the size of the texture to create
  62741. * @param scene Define the scene the texture belongs to
  62742. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  62743. * @param generateMipMaps Define if the texture should creates mip maps or not
  62744. */
  62745. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  62746. private _loadJson;
  62747. /**
  62748. * Is the texture ready to be used ? (rendered at least once)
  62749. * @returns true if ready, otherwise, false.
  62750. */
  62751. isReady(): boolean;
  62752. /**
  62753. * Render the texture to its associated render target.
  62754. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  62755. */
  62756. render(useCameraPostProcess?: boolean): void;
  62757. /**
  62758. * Update the list of dependant textures samplers in the shader.
  62759. */
  62760. updateTextures(): void;
  62761. /**
  62762. * Update the uniform values of the procedural texture in the shader.
  62763. */
  62764. updateShaderUniforms(): void;
  62765. /**
  62766. * Define if the texture animates or not.
  62767. */
  62768. get animate(): boolean;
  62769. set animate(value: boolean);
  62770. }
  62771. }
  62772. declare module BABYLON {
  62773. /** @hidden */
  62774. export var noisePixelShader: {
  62775. name: string;
  62776. shader: string;
  62777. };
  62778. }
  62779. declare module BABYLON {
  62780. /**
  62781. * Class used to generate noise procedural textures
  62782. */
  62783. export class NoiseProceduralTexture extends ProceduralTexture {
  62784. /** Gets or sets the start time (default is 0) */
  62785. time: number;
  62786. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  62787. brightness: number;
  62788. /** Defines the number of octaves to process */
  62789. octaves: number;
  62790. /** Defines the level of persistence (0.8 by default) */
  62791. persistence: number;
  62792. /** Gets or sets animation speed factor (default is 1) */
  62793. animationSpeedFactor: number;
  62794. /**
  62795. * Creates a new NoiseProceduralTexture
  62796. * @param name defines the name fo the texture
  62797. * @param size defines the size of the texture (default is 256)
  62798. * @param scene defines the hosting scene
  62799. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  62800. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  62801. */
  62802. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  62803. private _updateShaderUniforms;
  62804. protected _getDefines(): string;
  62805. /** Generate the current state of the procedural texture */
  62806. render(useCameraPostProcess?: boolean): void;
  62807. /**
  62808. * Serializes this noise procedural texture
  62809. * @returns a serialized noise procedural texture object
  62810. */
  62811. serialize(): any;
  62812. /**
  62813. * Clone the texture.
  62814. * @returns the cloned texture
  62815. */
  62816. clone(): NoiseProceduralTexture;
  62817. /**
  62818. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  62819. * @param parsedTexture defines parsed texture data
  62820. * @param scene defines the current scene
  62821. * @param rootUrl defines the root URL containing noise procedural texture information
  62822. * @returns a parsed NoiseProceduralTexture
  62823. */
  62824. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  62825. }
  62826. }
  62827. declare module BABYLON {
  62828. /**
  62829. * Raw cube texture where the raw buffers are passed in
  62830. */
  62831. export class RawCubeTexture extends CubeTexture {
  62832. /**
  62833. * Creates a cube texture where the raw buffers are passed in.
  62834. * @param scene defines the scene the texture is attached to
  62835. * @param data defines the array of data to use to create each face
  62836. * @param size defines the size of the textures
  62837. * @param format defines the format of the data
  62838. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  62839. * @param generateMipMaps defines if the engine should generate the mip levels
  62840. * @param invertY defines if data must be stored with Y axis inverted
  62841. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  62842. * @param compression defines the compression used (null by default)
  62843. */
  62844. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  62845. /**
  62846. * Updates the raw cube texture.
  62847. * @param data defines the data to store
  62848. * @param format defines the data format
  62849. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  62850. * @param invertY defines if data must be stored with Y axis inverted
  62851. * @param compression defines the compression used (null by default)
  62852. * @param level defines which level of the texture to update
  62853. */
  62854. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  62855. /**
  62856. * Updates a raw cube texture with RGBD encoded data.
  62857. * @param data defines the array of data [mipmap][face] to use to create each face
  62858. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  62859. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  62860. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  62861. * @returns a promsie that resolves when the operation is complete
  62862. */
  62863. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  62864. /**
  62865. * Clones the raw cube texture.
  62866. * @return a new cube texture
  62867. */
  62868. clone(): CubeTexture;
  62869. /** @hidden */
  62870. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  62871. }
  62872. }
  62873. declare module BABYLON {
  62874. /**
  62875. * Class used to store 2D array textures containing user data
  62876. */
  62877. export class RawTexture2DArray extends Texture {
  62878. /** Gets or sets the texture format to use */
  62879. format: number;
  62880. /**
  62881. * Create a new RawTexture2DArray
  62882. * @param data defines the data of the texture
  62883. * @param width defines the width of the texture
  62884. * @param height defines the height of the texture
  62885. * @param depth defines the number of layers of the texture
  62886. * @param format defines the texture format to use
  62887. * @param scene defines the hosting scene
  62888. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  62889. * @param invertY defines if texture must be stored with Y axis inverted
  62890. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  62891. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  62892. */
  62893. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  62894. /** Gets or sets the texture format to use */
  62895. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  62896. /**
  62897. * Update the texture with new data
  62898. * @param data defines the data to store in the texture
  62899. */
  62900. update(data: ArrayBufferView): void;
  62901. }
  62902. }
  62903. declare module BABYLON {
  62904. /**
  62905. * Class used to store 3D textures containing user data
  62906. */
  62907. export class RawTexture3D extends Texture {
  62908. /** Gets or sets the texture format to use */
  62909. format: number;
  62910. /**
  62911. * Create a new RawTexture3D
  62912. * @param data defines the data of the texture
  62913. * @param width defines the width of the texture
  62914. * @param height defines the height of the texture
  62915. * @param depth defines the depth of the texture
  62916. * @param format defines the texture format to use
  62917. * @param scene defines the hosting scene
  62918. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  62919. * @param invertY defines if texture must be stored with Y axis inverted
  62920. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  62921. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  62922. */
  62923. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  62924. /** Gets or sets the texture format to use */
  62925. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  62926. /**
  62927. * Update the texture with new data
  62928. * @param data defines the data to store in the texture
  62929. */
  62930. update(data: ArrayBufferView): void;
  62931. }
  62932. }
  62933. declare module BABYLON {
  62934. /**
  62935. * Creates a refraction texture used by refraction channel of the standard material.
  62936. * It is like a mirror but to see through a material.
  62937. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  62938. */
  62939. export class RefractionTexture extends RenderTargetTexture {
  62940. /**
  62941. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  62942. * 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.
  62943. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  62944. */
  62945. refractionPlane: Plane;
  62946. /**
  62947. * Define how deep under the surface we should see.
  62948. */
  62949. depth: number;
  62950. /**
  62951. * Creates a refraction texture used by refraction channel of the standard material.
  62952. * It is like a mirror but to see through a material.
  62953. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  62954. * @param name Define the texture name
  62955. * @param size Define the size of the underlying texture
  62956. * @param scene Define the scene the refraction belongs to
  62957. * @param generateMipMaps Define if we need to generate mips level for the refraction
  62958. */
  62959. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  62960. /**
  62961. * Clone the refraction texture.
  62962. * @returns the cloned texture
  62963. */
  62964. clone(): RefractionTexture;
  62965. /**
  62966. * Serialize the texture to a JSON representation you could use in Parse later on
  62967. * @returns the serialized JSON representation
  62968. */
  62969. serialize(): any;
  62970. }
  62971. }
  62972. declare module BABYLON {
  62973. /**
  62974. * Block used to add support for vertex skinning (bones)
  62975. */
  62976. export class BonesBlock extends NodeMaterialBlock {
  62977. /**
  62978. * Creates a new BonesBlock
  62979. * @param name defines the block name
  62980. */
  62981. constructor(name: string);
  62982. /**
  62983. * Initialize the block and prepare the context for build
  62984. * @param state defines the state that will be used for the build
  62985. */
  62986. initialize(state: NodeMaterialBuildState): void;
  62987. /**
  62988. * Gets the current class name
  62989. * @returns the class name
  62990. */
  62991. getClassName(): string;
  62992. /**
  62993. * Gets the matrix indices input component
  62994. */
  62995. get matricesIndices(): NodeMaterialConnectionPoint;
  62996. /**
  62997. * Gets the matrix weights input component
  62998. */
  62999. get matricesWeights(): NodeMaterialConnectionPoint;
  63000. /**
  63001. * Gets the extra matrix indices input component
  63002. */
  63003. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  63004. /**
  63005. * Gets the extra matrix weights input component
  63006. */
  63007. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  63008. /**
  63009. * Gets the world input component
  63010. */
  63011. get world(): NodeMaterialConnectionPoint;
  63012. /**
  63013. * Gets the output component
  63014. */
  63015. get output(): NodeMaterialConnectionPoint;
  63016. autoConfigure(material: NodeMaterial): void;
  63017. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  63018. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63019. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63020. protected _buildBlock(state: NodeMaterialBuildState): this;
  63021. }
  63022. }
  63023. declare module BABYLON {
  63024. /**
  63025. * Block used to add support for instances
  63026. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  63027. */
  63028. export class InstancesBlock extends NodeMaterialBlock {
  63029. /**
  63030. * Creates a new InstancesBlock
  63031. * @param name defines the block name
  63032. */
  63033. constructor(name: string);
  63034. /**
  63035. * Gets the current class name
  63036. * @returns the class name
  63037. */
  63038. getClassName(): string;
  63039. /**
  63040. * Gets the first world row input component
  63041. */
  63042. get world0(): NodeMaterialConnectionPoint;
  63043. /**
  63044. * Gets the second world row input component
  63045. */
  63046. get world1(): NodeMaterialConnectionPoint;
  63047. /**
  63048. * Gets the third world row input component
  63049. */
  63050. get world2(): NodeMaterialConnectionPoint;
  63051. /**
  63052. * Gets the forth world row input component
  63053. */
  63054. get world3(): NodeMaterialConnectionPoint;
  63055. /**
  63056. * Gets the world input component
  63057. */
  63058. get world(): NodeMaterialConnectionPoint;
  63059. /**
  63060. * Gets the output component
  63061. */
  63062. get output(): NodeMaterialConnectionPoint;
  63063. /**
  63064. * Gets the isntanceID component
  63065. */
  63066. get instanceID(): NodeMaterialConnectionPoint;
  63067. autoConfigure(material: NodeMaterial): void;
  63068. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  63069. protected _buildBlock(state: NodeMaterialBuildState): this;
  63070. }
  63071. }
  63072. declare module BABYLON {
  63073. /**
  63074. * Block used to add morph targets support to vertex shader
  63075. */
  63076. export class MorphTargetsBlock extends NodeMaterialBlock {
  63077. private _repeatableContentAnchor;
  63078. /**
  63079. * Create a new MorphTargetsBlock
  63080. * @param name defines the block name
  63081. */
  63082. constructor(name: string);
  63083. /**
  63084. * Gets the current class name
  63085. * @returns the class name
  63086. */
  63087. getClassName(): string;
  63088. /**
  63089. * Gets the position input component
  63090. */
  63091. get position(): NodeMaterialConnectionPoint;
  63092. /**
  63093. * Gets the normal input component
  63094. */
  63095. get normal(): NodeMaterialConnectionPoint;
  63096. /**
  63097. * Gets the tangent input component
  63098. */
  63099. get tangent(): NodeMaterialConnectionPoint;
  63100. /**
  63101. * Gets the tangent input component
  63102. */
  63103. get uv(): NodeMaterialConnectionPoint;
  63104. /**
  63105. * Gets the position output component
  63106. */
  63107. get positionOutput(): NodeMaterialConnectionPoint;
  63108. /**
  63109. * Gets the normal output component
  63110. */
  63111. get normalOutput(): NodeMaterialConnectionPoint;
  63112. /**
  63113. * Gets the tangent output component
  63114. */
  63115. get tangentOutput(): NodeMaterialConnectionPoint;
  63116. /**
  63117. * Gets the tangent output component
  63118. */
  63119. get uvOutput(): NodeMaterialConnectionPoint;
  63120. initialize(state: NodeMaterialBuildState): void;
  63121. autoConfigure(material: NodeMaterial): void;
  63122. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63123. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63124. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  63125. protected _buildBlock(state: NodeMaterialBuildState): this;
  63126. }
  63127. }
  63128. declare module BABYLON {
  63129. /**
  63130. * Block used to get data information from a light
  63131. */
  63132. export class LightInformationBlock extends NodeMaterialBlock {
  63133. private _lightDataUniformName;
  63134. private _lightColorUniformName;
  63135. private _lightTypeDefineName;
  63136. /**
  63137. * Gets or sets the light associated with this block
  63138. */
  63139. light: Nullable<Light>;
  63140. /**
  63141. * Creates a new LightInformationBlock
  63142. * @param name defines the block name
  63143. */
  63144. constructor(name: string);
  63145. /**
  63146. * Gets the current class name
  63147. * @returns the class name
  63148. */
  63149. getClassName(): string;
  63150. /**
  63151. * Gets the world position input component
  63152. */
  63153. get worldPosition(): NodeMaterialConnectionPoint;
  63154. /**
  63155. * Gets the direction output component
  63156. */
  63157. get direction(): NodeMaterialConnectionPoint;
  63158. /**
  63159. * Gets the direction output component
  63160. */
  63161. get color(): NodeMaterialConnectionPoint;
  63162. /**
  63163. * Gets the direction output component
  63164. */
  63165. get intensity(): NodeMaterialConnectionPoint;
  63166. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63167. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63168. protected _buildBlock(state: NodeMaterialBuildState): this;
  63169. serialize(): any;
  63170. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63171. }
  63172. }
  63173. declare module BABYLON {
  63174. /**
  63175. * Block used to add image processing support to fragment shader
  63176. */
  63177. export class ImageProcessingBlock extends NodeMaterialBlock {
  63178. /**
  63179. * Create a new ImageProcessingBlock
  63180. * @param name defines the block name
  63181. */
  63182. constructor(name: string);
  63183. /**
  63184. * Gets the current class name
  63185. * @returns the class name
  63186. */
  63187. getClassName(): string;
  63188. /**
  63189. * Gets the color input component
  63190. */
  63191. get color(): NodeMaterialConnectionPoint;
  63192. /**
  63193. * Gets the output component
  63194. */
  63195. get output(): NodeMaterialConnectionPoint;
  63196. /**
  63197. * Initialize the block and prepare the context for build
  63198. * @param state defines the state that will be used for the build
  63199. */
  63200. initialize(state: NodeMaterialBuildState): void;
  63201. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  63202. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63203. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63204. protected _buildBlock(state: NodeMaterialBuildState): this;
  63205. }
  63206. }
  63207. declare module BABYLON {
  63208. /**
  63209. * Block used to pertub normals based on a normal map
  63210. */
  63211. export class PerturbNormalBlock extends NodeMaterialBlock {
  63212. private _tangentSpaceParameterName;
  63213. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  63214. invertX: boolean;
  63215. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  63216. invertY: boolean;
  63217. /**
  63218. * Create a new PerturbNormalBlock
  63219. * @param name defines the block name
  63220. */
  63221. constructor(name: string);
  63222. /**
  63223. * Gets the current class name
  63224. * @returns the class name
  63225. */
  63226. getClassName(): string;
  63227. /**
  63228. * Gets the world position input component
  63229. */
  63230. get worldPosition(): NodeMaterialConnectionPoint;
  63231. /**
  63232. * Gets the world normal input component
  63233. */
  63234. get worldNormal(): NodeMaterialConnectionPoint;
  63235. /**
  63236. * Gets the world tangent input component
  63237. */
  63238. get worldTangent(): NodeMaterialConnectionPoint;
  63239. /**
  63240. * Gets the uv input component
  63241. */
  63242. get uv(): NodeMaterialConnectionPoint;
  63243. /**
  63244. * Gets the normal map color input component
  63245. */
  63246. get normalMapColor(): NodeMaterialConnectionPoint;
  63247. /**
  63248. * Gets the strength input component
  63249. */
  63250. get strength(): NodeMaterialConnectionPoint;
  63251. /**
  63252. * Gets the output component
  63253. */
  63254. get output(): NodeMaterialConnectionPoint;
  63255. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63256. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63257. autoConfigure(material: NodeMaterial): void;
  63258. protected _buildBlock(state: NodeMaterialBuildState): this;
  63259. protected _dumpPropertiesCode(): string;
  63260. serialize(): any;
  63261. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63262. }
  63263. }
  63264. declare module BABYLON {
  63265. /**
  63266. * Block used to discard a pixel if a value is smaller than a cutoff
  63267. */
  63268. export class DiscardBlock extends NodeMaterialBlock {
  63269. /**
  63270. * Create a new DiscardBlock
  63271. * @param name defines the block name
  63272. */
  63273. constructor(name: string);
  63274. /**
  63275. * Gets the current class name
  63276. * @returns the class name
  63277. */
  63278. getClassName(): string;
  63279. /**
  63280. * Gets the color input component
  63281. */
  63282. get value(): NodeMaterialConnectionPoint;
  63283. /**
  63284. * Gets the cutoff input component
  63285. */
  63286. get cutoff(): NodeMaterialConnectionPoint;
  63287. protected _buildBlock(state: NodeMaterialBuildState): this;
  63288. }
  63289. }
  63290. declare module BABYLON {
  63291. /**
  63292. * Block used to test if the fragment shader is front facing
  63293. */
  63294. export class FrontFacingBlock extends NodeMaterialBlock {
  63295. /**
  63296. * Creates a new FrontFacingBlock
  63297. * @param name defines the block name
  63298. */
  63299. constructor(name: string);
  63300. /**
  63301. * Gets the current class name
  63302. * @returns the class name
  63303. */
  63304. getClassName(): string;
  63305. /**
  63306. * Gets the output component
  63307. */
  63308. get output(): NodeMaterialConnectionPoint;
  63309. protected _buildBlock(state: NodeMaterialBuildState): this;
  63310. }
  63311. }
  63312. declare module BABYLON {
  63313. /**
  63314. * Block used to get the derivative value on x and y of a given input
  63315. */
  63316. export class DerivativeBlock extends NodeMaterialBlock {
  63317. /**
  63318. * Create a new DerivativeBlock
  63319. * @param name defines the block name
  63320. */
  63321. constructor(name: string);
  63322. /**
  63323. * Gets the current class name
  63324. * @returns the class name
  63325. */
  63326. getClassName(): string;
  63327. /**
  63328. * Gets the input component
  63329. */
  63330. get input(): NodeMaterialConnectionPoint;
  63331. /**
  63332. * Gets the derivative output on x
  63333. */
  63334. get dx(): NodeMaterialConnectionPoint;
  63335. /**
  63336. * Gets the derivative output on y
  63337. */
  63338. get dy(): NodeMaterialConnectionPoint;
  63339. protected _buildBlock(state: NodeMaterialBuildState): this;
  63340. }
  63341. }
  63342. declare module BABYLON {
  63343. /**
  63344. * Block used to make gl_FragCoord available
  63345. */
  63346. export class FragCoordBlock extends NodeMaterialBlock {
  63347. /**
  63348. * Creates a new FragCoordBlock
  63349. * @param name defines the block name
  63350. */
  63351. constructor(name: string);
  63352. /**
  63353. * Gets the current class name
  63354. * @returns the class name
  63355. */
  63356. getClassName(): string;
  63357. /**
  63358. * Gets the xy component
  63359. */
  63360. get xy(): NodeMaterialConnectionPoint;
  63361. /**
  63362. * Gets the xyz component
  63363. */
  63364. get xyz(): NodeMaterialConnectionPoint;
  63365. /**
  63366. * Gets the xyzw component
  63367. */
  63368. get xyzw(): NodeMaterialConnectionPoint;
  63369. /**
  63370. * Gets the x component
  63371. */
  63372. get x(): NodeMaterialConnectionPoint;
  63373. /**
  63374. * Gets the y component
  63375. */
  63376. get y(): NodeMaterialConnectionPoint;
  63377. /**
  63378. * Gets the z component
  63379. */
  63380. get z(): NodeMaterialConnectionPoint;
  63381. /**
  63382. * Gets the w component
  63383. */
  63384. get output(): NodeMaterialConnectionPoint;
  63385. protected writeOutputs(state: NodeMaterialBuildState): string;
  63386. protected _buildBlock(state: NodeMaterialBuildState): this;
  63387. }
  63388. }
  63389. declare module BABYLON {
  63390. /**
  63391. * Block used to get the screen sizes
  63392. */
  63393. export class ScreenSizeBlock extends NodeMaterialBlock {
  63394. private _varName;
  63395. private _scene;
  63396. /**
  63397. * Creates a new ScreenSizeBlock
  63398. * @param name defines the block name
  63399. */
  63400. constructor(name: string);
  63401. /**
  63402. * Gets the current class name
  63403. * @returns the class name
  63404. */
  63405. getClassName(): string;
  63406. /**
  63407. * Gets the xy component
  63408. */
  63409. get xy(): NodeMaterialConnectionPoint;
  63410. /**
  63411. * Gets the x component
  63412. */
  63413. get x(): NodeMaterialConnectionPoint;
  63414. /**
  63415. * Gets the y component
  63416. */
  63417. get y(): NodeMaterialConnectionPoint;
  63418. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63419. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  63420. protected _buildBlock(state: NodeMaterialBuildState): this;
  63421. }
  63422. }
  63423. declare module BABYLON {
  63424. /**
  63425. * Block used to add support for scene fog
  63426. */
  63427. export class FogBlock extends NodeMaterialBlock {
  63428. private _fogDistanceName;
  63429. private _fogParameters;
  63430. /**
  63431. * Create a new FogBlock
  63432. * @param name defines the block name
  63433. */
  63434. constructor(name: string);
  63435. /**
  63436. * Gets the current class name
  63437. * @returns the class name
  63438. */
  63439. getClassName(): string;
  63440. /**
  63441. * Gets the world position input component
  63442. */
  63443. get worldPosition(): NodeMaterialConnectionPoint;
  63444. /**
  63445. * Gets the view input component
  63446. */
  63447. get view(): NodeMaterialConnectionPoint;
  63448. /**
  63449. * Gets the color input component
  63450. */
  63451. get input(): NodeMaterialConnectionPoint;
  63452. /**
  63453. * Gets the fog color input component
  63454. */
  63455. get fogColor(): NodeMaterialConnectionPoint;
  63456. /**
  63457. * Gets the output component
  63458. */
  63459. get output(): NodeMaterialConnectionPoint;
  63460. autoConfigure(material: NodeMaterial): void;
  63461. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63462. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63463. protected _buildBlock(state: NodeMaterialBuildState): this;
  63464. }
  63465. }
  63466. declare module BABYLON {
  63467. /**
  63468. * Block used to add light in the fragment shader
  63469. */
  63470. export class LightBlock extends NodeMaterialBlock {
  63471. private _lightId;
  63472. /**
  63473. * Gets or sets the light associated with this block
  63474. */
  63475. light: Nullable<Light>;
  63476. /**
  63477. * Create a new LightBlock
  63478. * @param name defines the block name
  63479. */
  63480. constructor(name: string);
  63481. /**
  63482. * Gets the current class name
  63483. * @returns the class name
  63484. */
  63485. getClassName(): string;
  63486. /**
  63487. * Gets the world position input component
  63488. */
  63489. get worldPosition(): NodeMaterialConnectionPoint;
  63490. /**
  63491. * Gets the world normal input component
  63492. */
  63493. get worldNormal(): NodeMaterialConnectionPoint;
  63494. /**
  63495. * Gets the camera (or eye) position component
  63496. */
  63497. get cameraPosition(): NodeMaterialConnectionPoint;
  63498. /**
  63499. * Gets the glossiness component
  63500. */
  63501. get glossiness(): NodeMaterialConnectionPoint;
  63502. /**
  63503. * Gets the glossinness power component
  63504. */
  63505. get glossPower(): NodeMaterialConnectionPoint;
  63506. /**
  63507. * Gets the diffuse color component
  63508. */
  63509. get diffuseColor(): NodeMaterialConnectionPoint;
  63510. /**
  63511. * Gets the specular color component
  63512. */
  63513. get specularColor(): NodeMaterialConnectionPoint;
  63514. /**
  63515. * Gets the diffuse output component
  63516. */
  63517. get diffuseOutput(): NodeMaterialConnectionPoint;
  63518. /**
  63519. * Gets the specular output component
  63520. */
  63521. get specularOutput(): NodeMaterialConnectionPoint;
  63522. /**
  63523. * Gets the shadow output component
  63524. */
  63525. get shadow(): NodeMaterialConnectionPoint;
  63526. autoConfigure(material: NodeMaterial): void;
  63527. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  63528. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  63529. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  63530. private _injectVertexCode;
  63531. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63532. serialize(): any;
  63533. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63534. }
  63535. }
  63536. declare module BABYLON {
  63537. /**
  63538. * Block used to read a reflection texture from a sampler
  63539. */
  63540. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  63541. /**
  63542. * Create a new ReflectionTextureBlock
  63543. * @param name defines the block name
  63544. */
  63545. constructor(name: string);
  63546. /**
  63547. * Gets the current class name
  63548. * @returns the class name
  63549. */
  63550. getClassName(): string;
  63551. /**
  63552. * Gets the world position input component
  63553. */
  63554. get position(): NodeMaterialConnectionPoint;
  63555. /**
  63556. * Gets the world position input component
  63557. */
  63558. get worldPosition(): NodeMaterialConnectionPoint;
  63559. /**
  63560. * Gets the world normal input component
  63561. */
  63562. get worldNormal(): NodeMaterialConnectionPoint;
  63563. /**
  63564. * Gets the world input component
  63565. */
  63566. get world(): NodeMaterialConnectionPoint;
  63567. /**
  63568. * Gets the camera (or eye) position component
  63569. */
  63570. get cameraPosition(): NodeMaterialConnectionPoint;
  63571. /**
  63572. * Gets the view input component
  63573. */
  63574. get view(): NodeMaterialConnectionPoint;
  63575. /**
  63576. * Gets the rgb output component
  63577. */
  63578. get rgb(): NodeMaterialConnectionPoint;
  63579. /**
  63580. * Gets the rgba output component
  63581. */
  63582. get rgba(): NodeMaterialConnectionPoint;
  63583. /**
  63584. * Gets the r output component
  63585. */
  63586. get r(): NodeMaterialConnectionPoint;
  63587. /**
  63588. * Gets the g output component
  63589. */
  63590. get g(): NodeMaterialConnectionPoint;
  63591. /**
  63592. * Gets the b output component
  63593. */
  63594. get b(): NodeMaterialConnectionPoint;
  63595. /**
  63596. * Gets the a output component
  63597. */
  63598. get a(): NodeMaterialConnectionPoint;
  63599. autoConfigure(material: NodeMaterial): void;
  63600. protected _buildBlock(state: NodeMaterialBuildState): this;
  63601. }
  63602. }
  63603. declare module BABYLON {
  63604. /**
  63605. * Block used to add 2 vectors
  63606. */
  63607. export class AddBlock extends NodeMaterialBlock {
  63608. /**
  63609. * Creates a new AddBlock
  63610. * @param name defines the block name
  63611. */
  63612. constructor(name: string);
  63613. /**
  63614. * Gets the current class name
  63615. * @returns the class name
  63616. */
  63617. getClassName(): string;
  63618. /**
  63619. * Gets the left operand input component
  63620. */
  63621. get left(): NodeMaterialConnectionPoint;
  63622. /**
  63623. * Gets the right operand input component
  63624. */
  63625. get right(): 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 scale a vector by a float
  63636. */
  63637. export class ScaleBlock extends NodeMaterialBlock {
  63638. /**
  63639. * Creates a new ScaleBlock
  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 input component
  63650. */
  63651. get input(): NodeMaterialConnectionPoint;
  63652. /**
  63653. * Gets the factor input component
  63654. */
  63655. get factor(): NodeMaterialConnectionPoint;
  63656. /**
  63657. * Gets the output component
  63658. */
  63659. get output(): NodeMaterialConnectionPoint;
  63660. protected _buildBlock(state: NodeMaterialBuildState): this;
  63661. }
  63662. }
  63663. declare module BABYLON {
  63664. /**
  63665. * Block used to clamp a float
  63666. */
  63667. export class ClampBlock extends NodeMaterialBlock {
  63668. /** Gets or sets the minimum range */
  63669. minimum: number;
  63670. /** Gets or sets the maximum range */
  63671. maximum: number;
  63672. /**
  63673. * Creates a new ClampBlock
  63674. * @param name defines the block name
  63675. */
  63676. constructor(name: string);
  63677. /**
  63678. * Gets the current class name
  63679. * @returns the class name
  63680. */
  63681. getClassName(): string;
  63682. /**
  63683. * Gets the value input component
  63684. */
  63685. get value(): NodeMaterialConnectionPoint;
  63686. /**
  63687. * Gets the output component
  63688. */
  63689. get output(): NodeMaterialConnectionPoint;
  63690. protected _buildBlock(state: NodeMaterialBuildState): this;
  63691. protected _dumpPropertiesCode(): string;
  63692. serialize(): any;
  63693. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63694. }
  63695. }
  63696. declare module BABYLON {
  63697. /**
  63698. * Block used to apply a cross product between 2 vectors
  63699. */
  63700. export class CrossBlock extends NodeMaterialBlock {
  63701. /**
  63702. * Creates a new CrossBlock
  63703. * @param name defines the block name
  63704. */
  63705. constructor(name: string);
  63706. /**
  63707. * Gets the current class name
  63708. * @returns the class name
  63709. */
  63710. getClassName(): string;
  63711. /**
  63712. * Gets the left operand input component
  63713. */
  63714. get left(): NodeMaterialConnectionPoint;
  63715. /**
  63716. * Gets the right operand input component
  63717. */
  63718. get right(): NodeMaterialConnectionPoint;
  63719. /**
  63720. * Gets the output component
  63721. */
  63722. get output(): NodeMaterialConnectionPoint;
  63723. protected _buildBlock(state: NodeMaterialBuildState): this;
  63724. }
  63725. }
  63726. declare module BABYLON {
  63727. /**
  63728. * Block used to apply a dot product between 2 vectors
  63729. */
  63730. export class DotBlock extends NodeMaterialBlock {
  63731. /**
  63732. * Creates a new DotBlock
  63733. * @param name defines the block name
  63734. */
  63735. constructor(name: string);
  63736. /**
  63737. * Gets the current class name
  63738. * @returns the class name
  63739. */
  63740. getClassName(): string;
  63741. /**
  63742. * Gets the left operand input component
  63743. */
  63744. get left(): NodeMaterialConnectionPoint;
  63745. /**
  63746. * Gets the right operand input component
  63747. */
  63748. get right(): NodeMaterialConnectionPoint;
  63749. /**
  63750. * Gets the output component
  63751. */
  63752. get output(): NodeMaterialConnectionPoint;
  63753. protected _buildBlock(state: NodeMaterialBuildState): this;
  63754. }
  63755. }
  63756. declare module BABYLON {
  63757. /**
  63758. * Block used to normalize a vector
  63759. */
  63760. export class NormalizeBlock extends NodeMaterialBlock {
  63761. /**
  63762. * Creates a new NormalizeBlock
  63763. * @param name defines the block name
  63764. */
  63765. constructor(name: string);
  63766. /**
  63767. * Gets the current class name
  63768. * @returns the class name
  63769. */
  63770. getClassName(): string;
  63771. /**
  63772. * Gets the input component
  63773. */
  63774. get input(): NodeMaterialConnectionPoint;
  63775. /**
  63776. * Gets the output component
  63777. */
  63778. get output(): NodeMaterialConnectionPoint;
  63779. protected _buildBlock(state: NodeMaterialBuildState): this;
  63780. }
  63781. }
  63782. declare module BABYLON {
  63783. /**
  63784. * Block used to create a Color3/4 out of individual inputs (one for each component)
  63785. */
  63786. export class ColorMergerBlock extends NodeMaterialBlock {
  63787. /**
  63788. * Create a new ColorMergerBlock
  63789. * @param name defines the block name
  63790. */
  63791. constructor(name: string);
  63792. /**
  63793. * Gets the current class name
  63794. * @returns the class name
  63795. */
  63796. getClassName(): string;
  63797. /**
  63798. * Gets the rgb component (input)
  63799. */
  63800. get rgbIn(): NodeMaterialConnectionPoint;
  63801. /**
  63802. * Gets the r component (input)
  63803. */
  63804. get r(): NodeMaterialConnectionPoint;
  63805. /**
  63806. * Gets the g component (input)
  63807. */
  63808. get g(): NodeMaterialConnectionPoint;
  63809. /**
  63810. * Gets the b component (input)
  63811. */
  63812. get b(): NodeMaterialConnectionPoint;
  63813. /**
  63814. * Gets the a component (input)
  63815. */
  63816. get a(): NodeMaterialConnectionPoint;
  63817. /**
  63818. * Gets the rgba component (output)
  63819. */
  63820. get rgba(): NodeMaterialConnectionPoint;
  63821. /**
  63822. * Gets the rgb component (output)
  63823. */
  63824. get rgbOut(): NodeMaterialConnectionPoint;
  63825. /**
  63826. * Gets the rgb component (output)
  63827. * @deprecated Please use rgbOut instead.
  63828. */
  63829. get rgb(): NodeMaterialConnectionPoint;
  63830. protected _buildBlock(state: NodeMaterialBuildState): this;
  63831. }
  63832. }
  63833. declare module BABYLON {
  63834. /**
  63835. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  63836. */
  63837. export class VectorSplitterBlock extends NodeMaterialBlock {
  63838. /**
  63839. * Create a new VectorSplitterBlock
  63840. * @param name defines the block name
  63841. */
  63842. constructor(name: string);
  63843. /**
  63844. * Gets the current class name
  63845. * @returns the class name
  63846. */
  63847. getClassName(): string;
  63848. /**
  63849. * Gets the xyzw component (input)
  63850. */
  63851. get xyzw(): NodeMaterialConnectionPoint;
  63852. /**
  63853. * Gets the xyz component (input)
  63854. */
  63855. get xyzIn(): NodeMaterialConnectionPoint;
  63856. /**
  63857. * Gets the xy component (input)
  63858. */
  63859. get xyIn(): NodeMaterialConnectionPoint;
  63860. /**
  63861. * Gets the xyz component (output)
  63862. */
  63863. get xyzOut(): NodeMaterialConnectionPoint;
  63864. /**
  63865. * Gets the xy component (output)
  63866. */
  63867. get xyOut(): NodeMaterialConnectionPoint;
  63868. /**
  63869. * Gets the x component (output)
  63870. */
  63871. get x(): NodeMaterialConnectionPoint;
  63872. /**
  63873. * Gets the y component (output)
  63874. */
  63875. get y(): NodeMaterialConnectionPoint;
  63876. /**
  63877. * Gets the z component (output)
  63878. */
  63879. get z(): NodeMaterialConnectionPoint;
  63880. /**
  63881. * Gets the w component (output)
  63882. */
  63883. get w(): NodeMaterialConnectionPoint;
  63884. protected _inputRename(name: string): string;
  63885. protected _outputRename(name: string): string;
  63886. protected _buildBlock(state: NodeMaterialBuildState): this;
  63887. }
  63888. }
  63889. declare module BABYLON {
  63890. /**
  63891. * Block used to lerp between 2 values
  63892. */
  63893. export class LerpBlock extends NodeMaterialBlock {
  63894. /**
  63895. * Creates a new LerpBlock
  63896. * @param name defines the block name
  63897. */
  63898. constructor(name: string);
  63899. /**
  63900. * Gets the current class name
  63901. * @returns the class name
  63902. */
  63903. getClassName(): string;
  63904. /**
  63905. * Gets the left operand input component
  63906. */
  63907. get left(): NodeMaterialConnectionPoint;
  63908. /**
  63909. * Gets the right operand input component
  63910. */
  63911. get right(): NodeMaterialConnectionPoint;
  63912. /**
  63913. * Gets the gradient operand input component
  63914. */
  63915. get gradient(): NodeMaterialConnectionPoint;
  63916. /**
  63917. * Gets the output component
  63918. */
  63919. get output(): NodeMaterialConnectionPoint;
  63920. protected _buildBlock(state: NodeMaterialBuildState): this;
  63921. }
  63922. }
  63923. declare module BABYLON {
  63924. /**
  63925. * Block used to divide 2 vectors
  63926. */
  63927. export class DivideBlock extends NodeMaterialBlock {
  63928. /**
  63929. * Creates a new DivideBlock
  63930. * @param name defines the block name
  63931. */
  63932. constructor(name: string);
  63933. /**
  63934. * Gets the current class name
  63935. * @returns the class name
  63936. */
  63937. getClassName(): string;
  63938. /**
  63939. * Gets the left operand input component
  63940. */
  63941. get left(): NodeMaterialConnectionPoint;
  63942. /**
  63943. * Gets the right operand input component
  63944. */
  63945. get right(): NodeMaterialConnectionPoint;
  63946. /**
  63947. * Gets the output component
  63948. */
  63949. get output(): NodeMaterialConnectionPoint;
  63950. protected _buildBlock(state: NodeMaterialBuildState): this;
  63951. }
  63952. }
  63953. declare module BABYLON {
  63954. /**
  63955. * Block used to subtract 2 vectors
  63956. */
  63957. export class SubtractBlock extends NodeMaterialBlock {
  63958. /**
  63959. * Creates a new SubtractBlock
  63960. * @param name defines the block name
  63961. */
  63962. constructor(name: string);
  63963. /**
  63964. * Gets the current class name
  63965. * @returns the class name
  63966. */
  63967. getClassName(): string;
  63968. /**
  63969. * Gets the left operand input component
  63970. */
  63971. get left(): NodeMaterialConnectionPoint;
  63972. /**
  63973. * Gets the right operand input component
  63974. */
  63975. get right(): NodeMaterialConnectionPoint;
  63976. /**
  63977. * Gets the output component
  63978. */
  63979. get output(): NodeMaterialConnectionPoint;
  63980. protected _buildBlock(state: NodeMaterialBuildState): this;
  63981. }
  63982. }
  63983. declare module BABYLON {
  63984. /**
  63985. * Block used to step a value
  63986. */
  63987. export class StepBlock extends NodeMaterialBlock {
  63988. /**
  63989. * Creates a new StepBlock
  63990. * @param name defines the block name
  63991. */
  63992. constructor(name: string);
  63993. /**
  63994. * Gets the current class name
  63995. * @returns the class name
  63996. */
  63997. getClassName(): string;
  63998. /**
  63999. * Gets the value operand input component
  64000. */
  64001. get value(): NodeMaterialConnectionPoint;
  64002. /**
  64003. * Gets the edge operand input component
  64004. */
  64005. get edge(): NodeMaterialConnectionPoint;
  64006. /**
  64007. * Gets the output component
  64008. */
  64009. get output(): NodeMaterialConnectionPoint;
  64010. protected _buildBlock(state: NodeMaterialBuildState): this;
  64011. }
  64012. }
  64013. declare module BABYLON {
  64014. /**
  64015. * Block used to get the opposite (1 - x) of a value
  64016. */
  64017. export class OneMinusBlock extends NodeMaterialBlock {
  64018. /**
  64019. * Creates a new OneMinusBlock
  64020. * @param name defines the block name
  64021. */
  64022. constructor(name: string);
  64023. /**
  64024. * Gets the current class name
  64025. * @returns the class name
  64026. */
  64027. getClassName(): string;
  64028. /**
  64029. * Gets the input component
  64030. */
  64031. get input(): NodeMaterialConnectionPoint;
  64032. /**
  64033. * Gets the output component
  64034. */
  64035. get output(): NodeMaterialConnectionPoint;
  64036. protected _buildBlock(state: NodeMaterialBuildState): this;
  64037. }
  64038. }
  64039. declare module BABYLON {
  64040. /**
  64041. * Block used to get the view direction
  64042. */
  64043. export class ViewDirectionBlock extends NodeMaterialBlock {
  64044. /**
  64045. * Creates a new ViewDirectionBlock
  64046. * @param name defines the block name
  64047. */
  64048. constructor(name: string);
  64049. /**
  64050. * Gets the current class name
  64051. * @returns the class name
  64052. */
  64053. getClassName(): string;
  64054. /**
  64055. * Gets the world position component
  64056. */
  64057. get worldPosition(): NodeMaterialConnectionPoint;
  64058. /**
  64059. * Gets the camera position component
  64060. */
  64061. get cameraPosition(): NodeMaterialConnectionPoint;
  64062. /**
  64063. * Gets the output component
  64064. */
  64065. get output(): NodeMaterialConnectionPoint;
  64066. autoConfigure(material: NodeMaterial): void;
  64067. protected _buildBlock(state: NodeMaterialBuildState): this;
  64068. }
  64069. }
  64070. declare module BABYLON {
  64071. /**
  64072. * Block used to compute fresnel value
  64073. */
  64074. export class FresnelBlock extends NodeMaterialBlock {
  64075. /**
  64076. * Create a new FresnelBlock
  64077. * @param name defines the block name
  64078. */
  64079. constructor(name: string);
  64080. /**
  64081. * Gets the current class name
  64082. * @returns the class name
  64083. */
  64084. getClassName(): string;
  64085. /**
  64086. * Gets the world normal input component
  64087. */
  64088. get worldNormal(): NodeMaterialConnectionPoint;
  64089. /**
  64090. * Gets the view direction input component
  64091. */
  64092. get viewDirection(): NodeMaterialConnectionPoint;
  64093. /**
  64094. * Gets the bias input component
  64095. */
  64096. get bias(): NodeMaterialConnectionPoint;
  64097. /**
  64098. * Gets the camera (or eye) position component
  64099. */
  64100. get power(): NodeMaterialConnectionPoint;
  64101. /**
  64102. * Gets the fresnel output component
  64103. */
  64104. get fresnel(): NodeMaterialConnectionPoint;
  64105. autoConfigure(material: NodeMaterial): void;
  64106. protected _buildBlock(state: NodeMaterialBuildState): this;
  64107. }
  64108. }
  64109. declare module BABYLON {
  64110. /**
  64111. * Block used to get the max of 2 values
  64112. */
  64113. export class MaxBlock extends NodeMaterialBlock {
  64114. /**
  64115. * Creates a new MaxBlock
  64116. * @param name defines the block name
  64117. */
  64118. constructor(name: string);
  64119. /**
  64120. * Gets the current class name
  64121. * @returns the class name
  64122. */
  64123. getClassName(): string;
  64124. /**
  64125. * Gets the left operand input component
  64126. */
  64127. get left(): NodeMaterialConnectionPoint;
  64128. /**
  64129. * Gets the right operand input component
  64130. */
  64131. get right(): NodeMaterialConnectionPoint;
  64132. /**
  64133. * Gets the output component
  64134. */
  64135. get output(): NodeMaterialConnectionPoint;
  64136. protected _buildBlock(state: NodeMaterialBuildState): this;
  64137. }
  64138. }
  64139. declare module BABYLON {
  64140. /**
  64141. * Block used to get the min of 2 values
  64142. */
  64143. export class MinBlock extends NodeMaterialBlock {
  64144. /**
  64145. * Creates a new MinBlock
  64146. * @param name defines the block name
  64147. */
  64148. constructor(name: string);
  64149. /**
  64150. * Gets the current class name
  64151. * @returns the class name
  64152. */
  64153. getClassName(): string;
  64154. /**
  64155. * Gets the left operand input component
  64156. */
  64157. get left(): NodeMaterialConnectionPoint;
  64158. /**
  64159. * Gets the right operand input component
  64160. */
  64161. get right(): NodeMaterialConnectionPoint;
  64162. /**
  64163. * Gets the output component
  64164. */
  64165. get output(): NodeMaterialConnectionPoint;
  64166. protected _buildBlock(state: NodeMaterialBuildState): this;
  64167. }
  64168. }
  64169. declare module BABYLON {
  64170. /**
  64171. * Block used to get the distance between 2 values
  64172. */
  64173. export class DistanceBlock extends NodeMaterialBlock {
  64174. /**
  64175. * Creates a new DistanceBlock
  64176. * @param name defines the block name
  64177. */
  64178. constructor(name: string);
  64179. /**
  64180. * Gets the current class name
  64181. * @returns the class name
  64182. */
  64183. getClassName(): string;
  64184. /**
  64185. * Gets the left operand input component
  64186. */
  64187. get left(): NodeMaterialConnectionPoint;
  64188. /**
  64189. * Gets the right operand input component
  64190. */
  64191. get right(): NodeMaterialConnectionPoint;
  64192. /**
  64193. * Gets the output component
  64194. */
  64195. get output(): NodeMaterialConnectionPoint;
  64196. protected _buildBlock(state: NodeMaterialBuildState): this;
  64197. }
  64198. }
  64199. declare module BABYLON {
  64200. /**
  64201. * Block used to get the length of a vector
  64202. */
  64203. export class LengthBlock extends NodeMaterialBlock {
  64204. /**
  64205. * Creates a new LengthBlock
  64206. * @param name defines the block name
  64207. */
  64208. constructor(name: string);
  64209. /**
  64210. * Gets the current class name
  64211. * @returns the class name
  64212. */
  64213. getClassName(): string;
  64214. /**
  64215. * Gets the value input component
  64216. */
  64217. get value(): NodeMaterialConnectionPoint;
  64218. /**
  64219. * Gets the output component
  64220. */
  64221. get output(): NodeMaterialConnectionPoint;
  64222. protected _buildBlock(state: NodeMaterialBuildState): this;
  64223. }
  64224. }
  64225. declare module BABYLON {
  64226. /**
  64227. * Block used to get negative version of a value (i.e. x * -1)
  64228. */
  64229. export class NegateBlock extends NodeMaterialBlock {
  64230. /**
  64231. * Creates a new NegateBlock
  64232. * @param name defines the block name
  64233. */
  64234. constructor(name: string);
  64235. /**
  64236. * Gets the current class name
  64237. * @returns the class name
  64238. */
  64239. getClassName(): string;
  64240. /**
  64241. * Gets the value input component
  64242. */
  64243. get value(): NodeMaterialConnectionPoint;
  64244. /**
  64245. * Gets the output component
  64246. */
  64247. get output(): NodeMaterialConnectionPoint;
  64248. protected _buildBlock(state: NodeMaterialBuildState): this;
  64249. }
  64250. }
  64251. declare module BABYLON {
  64252. /**
  64253. * Block used to get the value of the first parameter raised to the power of the second
  64254. */
  64255. export class PowBlock extends NodeMaterialBlock {
  64256. /**
  64257. * Creates a new PowBlock
  64258. * @param name defines the block name
  64259. */
  64260. constructor(name: string);
  64261. /**
  64262. * Gets the current class name
  64263. * @returns the class name
  64264. */
  64265. getClassName(): string;
  64266. /**
  64267. * Gets the value operand input component
  64268. */
  64269. get value(): NodeMaterialConnectionPoint;
  64270. /**
  64271. * Gets the power operand input component
  64272. */
  64273. get power(): NodeMaterialConnectionPoint;
  64274. /**
  64275. * Gets the output component
  64276. */
  64277. get output(): NodeMaterialConnectionPoint;
  64278. protected _buildBlock(state: NodeMaterialBuildState): this;
  64279. }
  64280. }
  64281. declare module BABYLON {
  64282. /**
  64283. * Block used to get a random number
  64284. */
  64285. export class RandomNumberBlock extends NodeMaterialBlock {
  64286. /**
  64287. * Creates a new RandomNumberBlock
  64288. * @param name defines the block name
  64289. */
  64290. constructor(name: string);
  64291. /**
  64292. * Gets the current class name
  64293. * @returns the class name
  64294. */
  64295. getClassName(): string;
  64296. /**
  64297. * Gets the seed input component
  64298. */
  64299. get seed(): NodeMaterialConnectionPoint;
  64300. /**
  64301. * Gets the output component
  64302. */
  64303. get output(): NodeMaterialConnectionPoint;
  64304. protected _buildBlock(state: NodeMaterialBuildState): this;
  64305. }
  64306. }
  64307. declare module BABYLON {
  64308. /**
  64309. * Block used to compute arc tangent of 2 values
  64310. */
  64311. export class ArcTan2Block extends NodeMaterialBlock {
  64312. /**
  64313. * Creates a new ArcTan2Block
  64314. * @param name defines the block name
  64315. */
  64316. constructor(name: string);
  64317. /**
  64318. * Gets the current class name
  64319. * @returns the class name
  64320. */
  64321. getClassName(): string;
  64322. /**
  64323. * Gets the x operand input component
  64324. */
  64325. get x(): NodeMaterialConnectionPoint;
  64326. /**
  64327. * Gets the y operand input component
  64328. */
  64329. get y(): NodeMaterialConnectionPoint;
  64330. /**
  64331. * Gets the output component
  64332. */
  64333. get output(): NodeMaterialConnectionPoint;
  64334. protected _buildBlock(state: NodeMaterialBuildState): this;
  64335. }
  64336. }
  64337. declare module BABYLON {
  64338. /**
  64339. * Block used to smooth step a value
  64340. */
  64341. export class SmoothStepBlock extends NodeMaterialBlock {
  64342. /**
  64343. * Creates a new SmoothStepBlock
  64344. * @param name defines the block name
  64345. */
  64346. constructor(name: string);
  64347. /**
  64348. * Gets the current class name
  64349. * @returns the class name
  64350. */
  64351. getClassName(): string;
  64352. /**
  64353. * Gets the value operand input component
  64354. */
  64355. get value(): NodeMaterialConnectionPoint;
  64356. /**
  64357. * Gets the first edge operand input component
  64358. */
  64359. get edge0(): NodeMaterialConnectionPoint;
  64360. /**
  64361. * Gets the second edge operand input component
  64362. */
  64363. get edge1(): NodeMaterialConnectionPoint;
  64364. /**
  64365. * Gets the output component
  64366. */
  64367. get output(): NodeMaterialConnectionPoint;
  64368. protected _buildBlock(state: NodeMaterialBuildState): this;
  64369. }
  64370. }
  64371. declare module BABYLON {
  64372. /**
  64373. * Block used to get the reciprocal (1 / x) of a value
  64374. */
  64375. export class ReciprocalBlock extends NodeMaterialBlock {
  64376. /**
  64377. * Creates a new ReciprocalBlock
  64378. * @param name defines the block name
  64379. */
  64380. constructor(name: string);
  64381. /**
  64382. * Gets the current class name
  64383. * @returns the class name
  64384. */
  64385. getClassName(): string;
  64386. /**
  64387. * Gets the input component
  64388. */
  64389. get input(): NodeMaterialConnectionPoint;
  64390. /**
  64391. * Gets the output component
  64392. */
  64393. get output(): NodeMaterialConnectionPoint;
  64394. protected _buildBlock(state: NodeMaterialBuildState): this;
  64395. }
  64396. }
  64397. declare module BABYLON {
  64398. /**
  64399. * Block used to replace a color by another one
  64400. */
  64401. export class ReplaceColorBlock extends NodeMaterialBlock {
  64402. /**
  64403. * Creates a new ReplaceColorBlock
  64404. * @param name defines the block name
  64405. */
  64406. constructor(name: string);
  64407. /**
  64408. * Gets the current class name
  64409. * @returns the class name
  64410. */
  64411. getClassName(): string;
  64412. /**
  64413. * Gets the value input component
  64414. */
  64415. get value(): NodeMaterialConnectionPoint;
  64416. /**
  64417. * Gets the reference input component
  64418. */
  64419. get reference(): NodeMaterialConnectionPoint;
  64420. /**
  64421. * Gets the distance input component
  64422. */
  64423. get distance(): NodeMaterialConnectionPoint;
  64424. /**
  64425. * Gets the replacement input component
  64426. */
  64427. get replacement(): NodeMaterialConnectionPoint;
  64428. /**
  64429. * Gets the output component
  64430. */
  64431. get output(): NodeMaterialConnectionPoint;
  64432. protected _buildBlock(state: NodeMaterialBuildState): this;
  64433. }
  64434. }
  64435. declare module BABYLON {
  64436. /**
  64437. * Block used to posterize a value
  64438. * @see https://en.wikipedia.org/wiki/Posterization
  64439. */
  64440. export class PosterizeBlock extends NodeMaterialBlock {
  64441. /**
  64442. * Creates a new PosterizeBlock
  64443. * @param name defines the block name
  64444. */
  64445. constructor(name: string);
  64446. /**
  64447. * Gets the current class name
  64448. * @returns the class name
  64449. */
  64450. getClassName(): string;
  64451. /**
  64452. * Gets the value input component
  64453. */
  64454. get value(): NodeMaterialConnectionPoint;
  64455. /**
  64456. * Gets the steps input component
  64457. */
  64458. get steps(): NodeMaterialConnectionPoint;
  64459. /**
  64460. * Gets the output component
  64461. */
  64462. get output(): NodeMaterialConnectionPoint;
  64463. protected _buildBlock(state: NodeMaterialBuildState): this;
  64464. }
  64465. }
  64466. declare module BABYLON {
  64467. /**
  64468. * Operations supported by the Wave block
  64469. */
  64470. export enum WaveBlockKind {
  64471. /** SawTooth */
  64472. SawTooth = 0,
  64473. /** Square */
  64474. Square = 1,
  64475. /** Triangle */
  64476. Triangle = 2
  64477. }
  64478. /**
  64479. * Block used to apply wave operation to floats
  64480. */
  64481. export class WaveBlock extends NodeMaterialBlock {
  64482. /**
  64483. * Gets or sets the kibnd of wave to be applied by the block
  64484. */
  64485. kind: WaveBlockKind;
  64486. /**
  64487. * Creates a new WaveBlock
  64488. * @param name defines the block name
  64489. */
  64490. constructor(name: string);
  64491. /**
  64492. * Gets the current class name
  64493. * @returns the class name
  64494. */
  64495. getClassName(): string;
  64496. /**
  64497. * Gets the input component
  64498. */
  64499. get input(): NodeMaterialConnectionPoint;
  64500. /**
  64501. * Gets the output component
  64502. */
  64503. get output(): NodeMaterialConnectionPoint;
  64504. protected _buildBlock(state: NodeMaterialBuildState): this;
  64505. serialize(): any;
  64506. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64507. }
  64508. }
  64509. declare module BABYLON {
  64510. /**
  64511. * Class used to store a color step for the GradientBlock
  64512. */
  64513. export class GradientBlockColorStep {
  64514. private _step;
  64515. /**
  64516. * Gets value indicating which step this color is associated with (between 0 and 1)
  64517. */
  64518. get step(): number;
  64519. /**
  64520. * Sets a value indicating which step this color is associated with (between 0 and 1)
  64521. */
  64522. set step(val: number);
  64523. private _color;
  64524. /**
  64525. * Gets the color associated with this step
  64526. */
  64527. get color(): Color3;
  64528. /**
  64529. * Sets the color associated with this step
  64530. */
  64531. set color(val: Color3);
  64532. /**
  64533. * Creates a new GradientBlockColorStep
  64534. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  64535. * @param color defines the color associated with this step
  64536. */
  64537. constructor(step: number, color: Color3);
  64538. }
  64539. /**
  64540. * Block used to return a color from a gradient based on an input value between 0 and 1
  64541. */
  64542. export class GradientBlock extends NodeMaterialBlock {
  64543. /**
  64544. * Gets or sets the list of color steps
  64545. */
  64546. colorSteps: GradientBlockColorStep[];
  64547. /** Gets an observable raised when the value is changed */
  64548. onValueChangedObservable: Observable<GradientBlock>;
  64549. /** calls observable when the value is changed*/
  64550. colorStepsUpdated(): void;
  64551. /**
  64552. * Creates a new GradientBlock
  64553. * @param name defines the block name
  64554. */
  64555. constructor(name: string);
  64556. /**
  64557. * Gets the current class name
  64558. * @returns the class name
  64559. */
  64560. getClassName(): string;
  64561. /**
  64562. * Gets the gradient input component
  64563. */
  64564. get gradient(): NodeMaterialConnectionPoint;
  64565. /**
  64566. * Gets the output component
  64567. */
  64568. get output(): NodeMaterialConnectionPoint;
  64569. private _writeColorConstant;
  64570. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  64571. serialize(): any;
  64572. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64573. protected _dumpPropertiesCode(): string;
  64574. }
  64575. }
  64576. declare module BABYLON {
  64577. /**
  64578. * Block used to normalize lerp between 2 values
  64579. */
  64580. export class NLerpBlock extends NodeMaterialBlock {
  64581. /**
  64582. * Creates a new NLerpBlock
  64583. * @param name defines the block name
  64584. */
  64585. constructor(name: string);
  64586. /**
  64587. * Gets the current class name
  64588. * @returns the class name
  64589. */
  64590. getClassName(): string;
  64591. /**
  64592. * Gets the left operand input component
  64593. */
  64594. get left(): NodeMaterialConnectionPoint;
  64595. /**
  64596. * Gets the right operand input component
  64597. */
  64598. get right(): NodeMaterialConnectionPoint;
  64599. /**
  64600. * Gets the gradient operand input component
  64601. */
  64602. get gradient(): NodeMaterialConnectionPoint;
  64603. /**
  64604. * Gets the output component
  64605. */
  64606. get output(): NodeMaterialConnectionPoint;
  64607. protected _buildBlock(state: NodeMaterialBuildState): this;
  64608. }
  64609. }
  64610. declare module BABYLON {
  64611. /**
  64612. * block used to Generate a Worley Noise 3D Noise Pattern
  64613. */
  64614. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  64615. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  64616. manhattanDistance: boolean;
  64617. /**
  64618. * Creates a new WorleyNoise3DBlock
  64619. * @param name defines the block name
  64620. */
  64621. constructor(name: string);
  64622. /**
  64623. * Gets the current class name
  64624. * @returns the class name
  64625. */
  64626. getClassName(): string;
  64627. /**
  64628. * Gets the seed input component
  64629. */
  64630. get seed(): NodeMaterialConnectionPoint;
  64631. /**
  64632. * Gets the jitter input component
  64633. */
  64634. get jitter(): NodeMaterialConnectionPoint;
  64635. /**
  64636. * Gets the output component
  64637. */
  64638. get output(): NodeMaterialConnectionPoint;
  64639. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  64640. /**
  64641. * Exposes the properties to the UI?
  64642. */
  64643. protected _dumpPropertiesCode(): string;
  64644. /**
  64645. * Exposes the properties to the Seralize?
  64646. */
  64647. serialize(): any;
  64648. /**
  64649. * Exposes the properties to the deseralize?
  64650. */
  64651. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64652. }
  64653. }
  64654. declare module BABYLON {
  64655. /**
  64656. * block used to Generate a Simplex Perlin 3d Noise Pattern
  64657. */
  64658. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  64659. /**
  64660. * Creates a new SimplexPerlin3DBlock
  64661. * @param name defines the block name
  64662. */
  64663. constructor(name: string);
  64664. /**
  64665. * Gets the current class name
  64666. * @returns the class name
  64667. */
  64668. getClassName(): string;
  64669. /**
  64670. * Gets the seed operand input component
  64671. */
  64672. get seed(): NodeMaterialConnectionPoint;
  64673. /**
  64674. * Gets the output component
  64675. */
  64676. get output(): NodeMaterialConnectionPoint;
  64677. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  64678. }
  64679. }
  64680. declare module BABYLON {
  64681. /**
  64682. * Block used to blend normals
  64683. */
  64684. export class NormalBlendBlock extends NodeMaterialBlock {
  64685. /**
  64686. * Creates a new NormalBlendBlock
  64687. * @param name defines the block name
  64688. */
  64689. constructor(name: string);
  64690. /**
  64691. * Gets the current class name
  64692. * @returns the class name
  64693. */
  64694. getClassName(): string;
  64695. /**
  64696. * Gets the first input component
  64697. */
  64698. get normalMap0(): NodeMaterialConnectionPoint;
  64699. /**
  64700. * Gets the second input component
  64701. */
  64702. get normalMap1(): NodeMaterialConnectionPoint;
  64703. /**
  64704. * Gets the output component
  64705. */
  64706. get output(): NodeMaterialConnectionPoint;
  64707. protected _buildBlock(state: NodeMaterialBuildState): this;
  64708. }
  64709. }
  64710. declare module BABYLON {
  64711. /**
  64712. * Block used to rotate a 2d vector by a given angle
  64713. */
  64714. export class Rotate2dBlock extends NodeMaterialBlock {
  64715. /**
  64716. * Creates a new Rotate2dBlock
  64717. * @param name defines the block name
  64718. */
  64719. constructor(name: string);
  64720. /**
  64721. * Gets the current class name
  64722. * @returns the class name
  64723. */
  64724. getClassName(): string;
  64725. /**
  64726. * Gets the input vector
  64727. */
  64728. get input(): NodeMaterialConnectionPoint;
  64729. /**
  64730. * Gets the input angle
  64731. */
  64732. get angle(): NodeMaterialConnectionPoint;
  64733. /**
  64734. * Gets the output component
  64735. */
  64736. get output(): NodeMaterialConnectionPoint;
  64737. autoConfigure(material: NodeMaterial): void;
  64738. protected _buildBlock(state: NodeMaterialBuildState): this;
  64739. }
  64740. }
  64741. declare module BABYLON {
  64742. /**
  64743. * Block used to get the reflected vector from a direction and a normal
  64744. */
  64745. export class ReflectBlock extends NodeMaterialBlock {
  64746. /**
  64747. * Creates a new ReflectBlock
  64748. * @param name defines the block name
  64749. */
  64750. constructor(name: string);
  64751. /**
  64752. * Gets the current class name
  64753. * @returns the class name
  64754. */
  64755. getClassName(): string;
  64756. /**
  64757. * Gets the incident component
  64758. */
  64759. get incident(): NodeMaterialConnectionPoint;
  64760. /**
  64761. * Gets the normal component
  64762. */
  64763. get normal(): NodeMaterialConnectionPoint;
  64764. /**
  64765. * Gets the output component
  64766. */
  64767. get output(): NodeMaterialConnectionPoint;
  64768. protected _buildBlock(state: NodeMaterialBuildState): this;
  64769. }
  64770. }
  64771. declare module BABYLON {
  64772. /**
  64773. * Block used to get the refracted vector from a direction and a normal
  64774. */
  64775. export class RefractBlock extends NodeMaterialBlock {
  64776. /**
  64777. * Creates a new RefractBlock
  64778. * @param name defines the block name
  64779. */
  64780. constructor(name: string);
  64781. /**
  64782. * Gets the current class name
  64783. * @returns the class name
  64784. */
  64785. getClassName(): string;
  64786. /**
  64787. * Gets the incident component
  64788. */
  64789. get incident(): NodeMaterialConnectionPoint;
  64790. /**
  64791. * Gets the normal component
  64792. */
  64793. get normal(): NodeMaterialConnectionPoint;
  64794. /**
  64795. * Gets the index of refraction component
  64796. */
  64797. get ior(): NodeMaterialConnectionPoint;
  64798. /**
  64799. * Gets the output component
  64800. */
  64801. get output(): NodeMaterialConnectionPoint;
  64802. protected _buildBlock(state: NodeMaterialBuildState): this;
  64803. }
  64804. }
  64805. declare module BABYLON {
  64806. /**
  64807. * Block used to desaturate a color
  64808. */
  64809. export class DesaturateBlock extends NodeMaterialBlock {
  64810. /**
  64811. * Creates a new DesaturateBlock
  64812. * @param name defines the block name
  64813. */
  64814. constructor(name: string);
  64815. /**
  64816. * Gets the current class name
  64817. * @returns the class name
  64818. */
  64819. getClassName(): string;
  64820. /**
  64821. * Gets the color operand input component
  64822. */
  64823. get color(): NodeMaterialConnectionPoint;
  64824. /**
  64825. * Gets the level operand input component
  64826. */
  64827. get level(): NodeMaterialConnectionPoint;
  64828. /**
  64829. * Gets the output component
  64830. */
  64831. get output(): NodeMaterialConnectionPoint;
  64832. protected _buildBlock(state: NodeMaterialBuildState): this;
  64833. }
  64834. }
  64835. declare module BABYLON {
  64836. /**
  64837. * Block used to implement the ambient occlusion module of the PBR material
  64838. */
  64839. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  64840. /**
  64841. * Create a new AmbientOcclusionBlock
  64842. * @param name defines the block name
  64843. */
  64844. constructor(name: string);
  64845. /**
  64846. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  64847. */
  64848. useAmbientInGrayScale: boolean;
  64849. /**
  64850. * Initialize the block and prepare the context for build
  64851. * @param state defines the state that will be used for the build
  64852. */
  64853. initialize(state: NodeMaterialBuildState): void;
  64854. /**
  64855. * Gets the current class name
  64856. * @returns the class name
  64857. */
  64858. getClassName(): string;
  64859. /**
  64860. * Gets the texture input component
  64861. */
  64862. get texture(): NodeMaterialConnectionPoint;
  64863. /**
  64864. * Gets the texture intensity component
  64865. */
  64866. get intensity(): NodeMaterialConnectionPoint;
  64867. /**
  64868. * Gets the direct light intensity input component
  64869. */
  64870. get directLightIntensity(): NodeMaterialConnectionPoint;
  64871. /**
  64872. * Gets the ambient occlusion object output component
  64873. */
  64874. get ambientOcc(): NodeMaterialConnectionPoint;
  64875. /**
  64876. * Gets the main code of the block (fragment side)
  64877. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  64878. * @returns the shader code
  64879. */
  64880. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  64881. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64882. protected _buildBlock(state: NodeMaterialBuildState): this;
  64883. protected _dumpPropertiesCode(): string;
  64884. serialize(): any;
  64885. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64886. }
  64887. }
  64888. declare module BABYLON {
  64889. /**
  64890. * Block used to implement the reflection module of the PBR material
  64891. */
  64892. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  64893. /** @hidden */
  64894. _defineLODReflectionAlpha: string;
  64895. /** @hidden */
  64896. _defineLinearSpecularReflection: string;
  64897. private _vEnvironmentIrradianceName;
  64898. /** @hidden */
  64899. _vReflectionMicrosurfaceInfosName: string;
  64900. /** @hidden */
  64901. _vReflectionInfosName: string;
  64902. /** @hidden */
  64903. _vReflectionFilteringInfoName: string;
  64904. private _scene;
  64905. /**
  64906. * The three properties below are set by the main PBR block prior to calling methods of this class.
  64907. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  64908. * It's less burden on the user side in the editor part.
  64909. */
  64910. /** @hidden */
  64911. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  64912. /** @hidden */
  64913. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  64914. /** @hidden */
  64915. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  64916. /**
  64917. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  64918. * diffuse part of the IBL.
  64919. */
  64920. useSphericalHarmonics: boolean;
  64921. /**
  64922. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  64923. */
  64924. forceIrradianceInFragment: boolean;
  64925. /**
  64926. * Create a new ReflectionBlock
  64927. * @param name defines the block name
  64928. */
  64929. constructor(name: string);
  64930. /**
  64931. * Gets the current class name
  64932. * @returns the class name
  64933. */
  64934. getClassName(): string;
  64935. /**
  64936. * Gets the position input component
  64937. */
  64938. get position(): NodeMaterialConnectionPoint;
  64939. /**
  64940. * Gets the world position input component
  64941. */
  64942. get worldPosition(): NodeMaterialConnectionPoint;
  64943. /**
  64944. * Gets the world normal input component
  64945. */
  64946. get worldNormal(): NodeMaterialConnectionPoint;
  64947. /**
  64948. * Gets the world input component
  64949. */
  64950. get world(): NodeMaterialConnectionPoint;
  64951. /**
  64952. * Gets the camera (or eye) position component
  64953. */
  64954. get cameraPosition(): NodeMaterialConnectionPoint;
  64955. /**
  64956. * Gets the view input component
  64957. */
  64958. get view(): NodeMaterialConnectionPoint;
  64959. /**
  64960. * Gets the color input component
  64961. */
  64962. get color(): NodeMaterialConnectionPoint;
  64963. /**
  64964. * Gets the reflection object output component
  64965. */
  64966. get reflection(): NodeMaterialConnectionPoint;
  64967. /**
  64968. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  64969. */
  64970. get hasTexture(): boolean;
  64971. /**
  64972. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  64973. */
  64974. get reflectionColor(): string;
  64975. protected _getTexture(): Nullable<BaseTexture>;
  64976. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  64977. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  64978. /**
  64979. * Gets the code to inject in the vertex shader
  64980. * @param state current state of the node material building
  64981. * @returns the shader code
  64982. */
  64983. handleVertexSide(state: NodeMaterialBuildState): string;
  64984. /**
  64985. * Gets the main code of the block (fragment side)
  64986. * @param state current state of the node material building
  64987. * @param normalVarName name of the existing variable corresponding to the normal
  64988. * @returns the shader code
  64989. */
  64990. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  64991. protected _buildBlock(state: NodeMaterialBuildState): this;
  64992. protected _dumpPropertiesCode(): string;
  64993. serialize(): any;
  64994. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  64995. }
  64996. }
  64997. declare module BABYLON {
  64998. /**
  64999. * Block used to implement the sheen module of the PBR material
  65000. */
  65001. export class SheenBlock extends NodeMaterialBlock {
  65002. /**
  65003. * Create a new SheenBlock
  65004. * @param name defines the block name
  65005. */
  65006. constructor(name: string);
  65007. /**
  65008. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  65009. * It allows the strength of the sheen effect to not depend on the base color of the material,
  65010. * making it easier to setup and tweak the effect
  65011. */
  65012. albedoScaling: boolean;
  65013. /**
  65014. * Defines if the sheen is linked to the sheen color.
  65015. */
  65016. linkSheenWithAlbedo: boolean;
  65017. /**
  65018. * Initialize the block and prepare the context for build
  65019. * @param state defines the state that will be used for the build
  65020. */
  65021. initialize(state: NodeMaterialBuildState): void;
  65022. /**
  65023. * Gets the current class name
  65024. * @returns the class name
  65025. */
  65026. getClassName(): string;
  65027. /**
  65028. * Gets the intensity input component
  65029. */
  65030. get intensity(): NodeMaterialConnectionPoint;
  65031. /**
  65032. * Gets the color input component
  65033. */
  65034. get color(): NodeMaterialConnectionPoint;
  65035. /**
  65036. * Gets the roughness input component
  65037. */
  65038. get roughness(): NodeMaterialConnectionPoint;
  65039. /**
  65040. * Gets the sheen object output component
  65041. */
  65042. get sheen(): NodeMaterialConnectionPoint;
  65043. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65044. /**
  65045. * Gets the main code of the block (fragment side)
  65046. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  65047. * @returns the shader code
  65048. */
  65049. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  65050. protected _buildBlock(state: NodeMaterialBuildState): this;
  65051. protected _dumpPropertiesCode(): string;
  65052. serialize(): any;
  65053. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65054. }
  65055. }
  65056. declare module BABYLON {
  65057. /**
  65058. * Block used to implement the reflectivity module of the PBR material
  65059. */
  65060. export class ReflectivityBlock extends NodeMaterialBlock {
  65061. private _metallicReflectanceColor;
  65062. private _metallicF0Factor;
  65063. /** @hidden */
  65064. _vMetallicReflectanceFactorsName: string;
  65065. /**
  65066. * The property below is set by the main PBR block prior to calling methods of this class.
  65067. */
  65068. /** @hidden */
  65069. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  65070. /**
  65071. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  65072. */
  65073. useAmbientOcclusionFromMetallicTextureRed: boolean;
  65074. /**
  65075. * Specifies if the metallic texture contains the metallness information in its blue channel.
  65076. */
  65077. useMetallnessFromMetallicTextureBlue: boolean;
  65078. /**
  65079. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  65080. */
  65081. useRoughnessFromMetallicTextureAlpha: boolean;
  65082. /**
  65083. * Specifies if the metallic texture contains the roughness information in its green channel.
  65084. */
  65085. useRoughnessFromMetallicTextureGreen: boolean;
  65086. /**
  65087. * Create a new ReflectivityBlock
  65088. * @param name defines the block name
  65089. */
  65090. constructor(name: string);
  65091. /**
  65092. * Initialize the block and prepare the context for build
  65093. * @param state defines the state that will be used for the build
  65094. */
  65095. initialize(state: NodeMaterialBuildState): void;
  65096. /**
  65097. * Gets the current class name
  65098. * @returns the class name
  65099. */
  65100. getClassName(): string;
  65101. /**
  65102. * Gets the metallic input component
  65103. */
  65104. get metallic(): NodeMaterialConnectionPoint;
  65105. /**
  65106. * Gets the roughness input component
  65107. */
  65108. get roughness(): NodeMaterialConnectionPoint;
  65109. /**
  65110. * Gets the texture input component
  65111. */
  65112. get texture(): NodeMaterialConnectionPoint;
  65113. /**
  65114. * Gets the reflectivity object output component
  65115. */
  65116. get reflectivity(): NodeMaterialConnectionPoint;
  65117. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  65118. /**
  65119. * Gets the main code of the block (fragment side)
  65120. * @param state current state of the node material building
  65121. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  65122. * @returns the shader code
  65123. */
  65124. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  65125. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65126. protected _buildBlock(state: NodeMaterialBuildState): this;
  65127. protected _dumpPropertiesCode(): string;
  65128. serialize(): any;
  65129. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65130. }
  65131. }
  65132. declare module BABYLON {
  65133. /**
  65134. * Block used to implement the anisotropy module of the PBR material
  65135. */
  65136. export class AnisotropyBlock extends NodeMaterialBlock {
  65137. /**
  65138. * The two properties below are set by the main PBR block prior to calling methods of this class.
  65139. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  65140. * It's less burden on the user side in the editor part.
  65141. */
  65142. /** @hidden */
  65143. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  65144. /** @hidden */
  65145. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  65146. /**
  65147. * Create a new AnisotropyBlock
  65148. * @param name defines the block name
  65149. */
  65150. constructor(name: string);
  65151. /**
  65152. * Initialize the block and prepare the context for build
  65153. * @param state defines the state that will be used for the build
  65154. */
  65155. initialize(state: NodeMaterialBuildState): void;
  65156. /**
  65157. * Gets the current class name
  65158. * @returns the class name
  65159. */
  65160. getClassName(): string;
  65161. /**
  65162. * Gets the intensity input component
  65163. */
  65164. get intensity(): NodeMaterialConnectionPoint;
  65165. /**
  65166. * Gets the direction input component
  65167. */
  65168. get direction(): NodeMaterialConnectionPoint;
  65169. /**
  65170. * Gets the texture input component
  65171. */
  65172. get texture(): NodeMaterialConnectionPoint;
  65173. /**
  65174. * Gets the uv input component
  65175. */
  65176. get uv(): NodeMaterialConnectionPoint;
  65177. /**
  65178. * Gets the worldTangent input component
  65179. */
  65180. get worldTangent(): NodeMaterialConnectionPoint;
  65181. /**
  65182. * Gets the anisotropy object output component
  65183. */
  65184. get anisotropy(): NodeMaterialConnectionPoint;
  65185. private _generateTBNSpace;
  65186. /**
  65187. * Gets the main code of the block (fragment side)
  65188. * @param state current state of the node material building
  65189. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  65190. * @returns the shader code
  65191. */
  65192. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  65193. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65194. protected _buildBlock(state: NodeMaterialBuildState): this;
  65195. }
  65196. }
  65197. declare module BABYLON {
  65198. /**
  65199. * Block used to implement the clear coat module of the PBR material
  65200. */
  65201. export class ClearCoatBlock extends NodeMaterialBlock {
  65202. private _scene;
  65203. /**
  65204. * Create a new ClearCoatBlock
  65205. * @param name defines the block name
  65206. */
  65207. constructor(name: string);
  65208. /**
  65209. * Initialize the block and prepare the context for build
  65210. * @param state defines the state that will be used for the build
  65211. */
  65212. initialize(state: NodeMaterialBuildState): void;
  65213. /**
  65214. * Gets the current class name
  65215. * @returns the class name
  65216. */
  65217. getClassName(): string;
  65218. /**
  65219. * Gets the intensity input component
  65220. */
  65221. get intensity(): NodeMaterialConnectionPoint;
  65222. /**
  65223. * Gets the roughness input component
  65224. */
  65225. get roughness(): NodeMaterialConnectionPoint;
  65226. /**
  65227. * Gets the ior input component
  65228. */
  65229. get ior(): NodeMaterialConnectionPoint;
  65230. /**
  65231. * Gets the texture input component
  65232. */
  65233. get texture(): NodeMaterialConnectionPoint;
  65234. /**
  65235. * Gets the bump texture input component
  65236. */
  65237. get bumpTexture(): NodeMaterialConnectionPoint;
  65238. /**
  65239. * Gets the uv input component
  65240. */
  65241. get uv(): NodeMaterialConnectionPoint;
  65242. /**
  65243. * Gets the tint color input component
  65244. */
  65245. get tintColor(): NodeMaterialConnectionPoint;
  65246. /**
  65247. * Gets the tint "at distance" input component
  65248. */
  65249. get tintAtDistance(): NodeMaterialConnectionPoint;
  65250. /**
  65251. * Gets the tint thickness input component
  65252. */
  65253. get tintThickness(): NodeMaterialConnectionPoint;
  65254. /**
  65255. * Gets the world tangent input component
  65256. */
  65257. get worldTangent(): NodeMaterialConnectionPoint;
  65258. /**
  65259. * Gets the clear coat object output component
  65260. */
  65261. get clearcoat(): NodeMaterialConnectionPoint;
  65262. autoConfigure(material: NodeMaterial): void;
  65263. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65264. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  65265. private _generateTBNSpace;
  65266. /**
  65267. * Gets the main code of the block (fragment side)
  65268. * @param state current state of the node material building
  65269. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  65270. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  65271. * @param worldPosVarName name of the variable holding the world position
  65272. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  65273. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  65274. * @param worldNormalVarName name of the variable holding the world normal
  65275. * @returns the shader code
  65276. */
  65277. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  65278. protected _buildBlock(state: NodeMaterialBuildState): this;
  65279. }
  65280. }
  65281. declare module BABYLON {
  65282. /**
  65283. * Block used to implement the sub surface module of the PBR material
  65284. */
  65285. export class SubSurfaceBlock extends NodeMaterialBlock {
  65286. /**
  65287. * Create a new SubSurfaceBlock
  65288. * @param name defines the block name
  65289. */
  65290. constructor(name: string);
  65291. /**
  65292. * Stores the intensity of the different subsurface effects in the thickness texture.
  65293. * * the green channel is the translucency intensity.
  65294. * * the blue channel is the scattering intensity.
  65295. * * the alpha channel is the refraction intensity.
  65296. */
  65297. useMaskFromThicknessTexture: boolean;
  65298. /**
  65299. * Initialize the block and prepare the context for build
  65300. * @param state defines the state that will be used for the build
  65301. */
  65302. initialize(state: NodeMaterialBuildState): void;
  65303. /**
  65304. * Gets the current class name
  65305. * @returns the class name
  65306. */
  65307. getClassName(): string;
  65308. /**
  65309. * Gets the min thickness input component
  65310. */
  65311. get minThickness(): NodeMaterialConnectionPoint;
  65312. /**
  65313. * Gets the max thickness input component
  65314. */
  65315. get maxThickness(): NodeMaterialConnectionPoint;
  65316. /**
  65317. * Gets the thickness texture component
  65318. */
  65319. get thicknessTexture(): NodeMaterialConnectionPoint;
  65320. /**
  65321. * Gets the tint color input component
  65322. */
  65323. get tintColor(): NodeMaterialConnectionPoint;
  65324. /**
  65325. * Gets the translucency intensity input component
  65326. */
  65327. get translucencyIntensity(): NodeMaterialConnectionPoint;
  65328. /**
  65329. * Gets the translucency diffusion distance input component
  65330. */
  65331. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  65332. /**
  65333. * Gets the refraction object parameters
  65334. */
  65335. get refraction(): NodeMaterialConnectionPoint;
  65336. /**
  65337. * Gets the sub surface object output component
  65338. */
  65339. get subsurface(): NodeMaterialConnectionPoint;
  65340. autoConfigure(material: NodeMaterial): void;
  65341. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65342. /**
  65343. * Gets the main code of the block (fragment side)
  65344. * @param state current state of the node material building
  65345. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  65346. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  65347. * @param worldPosVarName name of the variable holding the world position
  65348. * @returns the shader code
  65349. */
  65350. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  65351. protected _buildBlock(state: NodeMaterialBuildState): this;
  65352. }
  65353. }
  65354. declare module BABYLON {
  65355. /**
  65356. * Block used to implement the PBR metallic/roughness model
  65357. */
  65358. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  65359. /**
  65360. * Gets or sets the light associated with this block
  65361. */
  65362. light: Nullable<Light>;
  65363. private _lightId;
  65364. private _scene;
  65365. private _environmentBRDFTexture;
  65366. private _environmentBrdfSamplerName;
  65367. private _vNormalWName;
  65368. private _invertNormalName;
  65369. /**
  65370. * Create a new ReflectionBlock
  65371. * @param name defines the block name
  65372. */
  65373. constructor(name: string);
  65374. /**
  65375. * Intensity of the direct lights e.g. the four lights available in your scene.
  65376. * This impacts both the direct diffuse and specular highlights.
  65377. */
  65378. directIntensity: number;
  65379. /**
  65380. * Intensity of the environment e.g. how much the environment will light the object
  65381. * either through harmonics for rough material or through the refelction for shiny ones.
  65382. */
  65383. environmentIntensity: number;
  65384. /**
  65385. * This is a special control allowing the reduction of the specular highlights coming from the
  65386. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  65387. */
  65388. specularIntensity: number;
  65389. /**
  65390. * Defines the falloff type used in this material.
  65391. * It by default is Physical.
  65392. */
  65393. lightFalloff: number;
  65394. /**
  65395. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  65396. */
  65397. useAlphaFromAlbedoTexture: boolean;
  65398. /**
  65399. * Specifies that alpha test should be used
  65400. */
  65401. useAlphaTest: boolean;
  65402. /**
  65403. * Defines the alpha limits in alpha test mode.
  65404. */
  65405. alphaTestCutoff: number;
  65406. /**
  65407. * Specifies that alpha blending should be used
  65408. */
  65409. useAlphaBlending: boolean;
  65410. /**
  65411. * Defines if the alpha value should be determined via the rgb values.
  65412. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  65413. */
  65414. opacityRGB: boolean;
  65415. /**
  65416. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  65417. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  65418. */
  65419. useRadianceOverAlpha: boolean;
  65420. /**
  65421. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  65422. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  65423. */
  65424. useSpecularOverAlpha: boolean;
  65425. /**
  65426. * Enables specular anti aliasing in the PBR shader.
  65427. * It will both interacts on the Geometry for analytical and IBL lighting.
  65428. * It also prefilter the roughness map based on the bump values.
  65429. */
  65430. enableSpecularAntiAliasing: boolean;
  65431. /**
  65432. * Enables realtime filtering on the texture.
  65433. */
  65434. realTimeFiltering: boolean;
  65435. /**
  65436. * Quality switch for realtime filtering
  65437. */
  65438. realTimeFilteringQuality: number;
  65439. /**
  65440. * Defines if the material uses energy conservation.
  65441. */
  65442. useEnergyConservation: boolean;
  65443. /**
  65444. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  65445. * too much the area relying on ambient texture to define their ambient occlusion.
  65446. */
  65447. useRadianceOcclusion: boolean;
  65448. /**
  65449. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  65450. * makes the reflect vector face the model (under horizon).
  65451. */
  65452. useHorizonOcclusion: boolean;
  65453. /**
  65454. * If set to true, no lighting calculations will be applied.
  65455. */
  65456. unlit: boolean;
  65457. /**
  65458. * Force normal to face away from face.
  65459. */
  65460. forceNormalForward: boolean;
  65461. /**
  65462. * Defines the material debug mode.
  65463. * It helps seeing only some components of the material while troubleshooting.
  65464. */
  65465. debugMode: number;
  65466. /**
  65467. * Specify from where on screen the debug mode should start.
  65468. * The value goes from -1 (full screen) to 1 (not visible)
  65469. * It helps with side by side comparison against the final render
  65470. * This defaults to 0
  65471. */
  65472. debugLimit: number;
  65473. /**
  65474. * As the default viewing range might not be enough (if the ambient is really small for instance)
  65475. * You can use the factor to better multiply the final value.
  65476. */
  65477. debugFactor: number;
  65478. /**
  65479. * Initialize the block and prepare the context for build
  65480. * @param state defines the state that will be used for the build
  65481. */
  65482. initialize(state: NodeMaterialBuildState): void;
  65483. /**
  65484. * Gets the current class name
  65485. * @returns the class name
  65486. */
  65487. getClassName(): string;
  65488. /**
  65489. * Gets the world position input component
  65490. */
  65491. get worldPosition(): NodeMaterialConnectionPoint;
  65492. /**
  65493. * Gets the world normal input component
  65494. */
  65495. get worldNormal(): NodeMaterialConnectionPoint;
  65496. /**
  65497. * Gets the perturbed normal input component
  65498. */
  65499. get perturbedNormal(): NodeMaterialConnectionPoint;
  65500. /**
  65501. * Gets the camera position input component
  65502. */
  65503. get cameraPosition(): NodeMaterialConnectionPoint;
  65504. /**
  65505. * Gets the base color input component
  65506. */
  65507. get baseColor(): NodeMaterialConnectionPoint;
  65508. /**
  65509. * Gets the opacity texture input component
  65510. */
  65511. get opacityTexture(): NodeMaterialConnectionPoint;
  65512. /**
  65513. * Gets the ambient color input component
  65514. */
  65515. get ambientColor(): NodeMaterialConnectionPoint;
  65516. /**
  65517. * Gets the reflectivity object parameters
  65518. */
  65519. get reflectivity(): NodeMaterialConnectionPoint;
  65520. /**
  65521. * Gets the ambient occlusion object parameters
  65522. */
  65523. get ambientOcc(): NodeMaterialConnectionPoint;
  65524. /**
  65525. * Gets the reflection object parameters
  65526. */
  65527. get reflection(): NodeMaterialConnectionPoint;
  65528. /**
  65529. * Gets the sheen object parameters
  65530. */
  65531. get sheen(): NodeMaterialConnectionPoint;
  65532. /**
  65533. * Gets the clear coat object parameters
  65534. */
  65535. get clearcoat(): NodeMaterialConnectionPoint;
  65536. /**
  65537. * Gets the sub surface object parameters
  65538. */
  65539. get subsurface(): NodeMaterialConnectionPoint;
  65540. /**
  65541. * Gets the anisotropy object parameters
  65542. */
  65543. get anisotropy(): NodeMaterialConnectionPoint;
  65544. /**
  65545. * Gets the ambient output component
  65546. */
  65547. get ambient(): NodeMaterialConnectionPoint;
  65548. /**
  65549. * Gets the diffuse output component
  65550. */
  65551. get diffuse(): NodeMaterialConnectionPoint;
  65552. /**
  65553. * Gets the specular output component
  65554. */
  65555. get specular(): NodeMaterialConnectionPoint;
  65556. /**
  65557. * Gets the sheen output component
  65558. */
  65559. get sheenDir(): NodeMaterialConnectionPoint;
  65560. /**
  65561. * Gets the clear coat output component
  65562. */
  65563. get clearcoatDir(): NodeMaterialConnectionPoint;
  65564. /**
  65565. * Gets the indirect diffuse output component
  65566. */
  65567. get diffuseIndirect(): NodeMaterialConnectionPoint;
  65568. /**
  65569. * Gets the indirect specular output component
  65570. */
  65571. get specularIndirect(): NodeMaterialConnectionPoint;
  65572. /**
  65573. * Gets the indirect sheen output component
  65574. */
  65575. get sheenIndirect(): NodeMaterialConnectionPoint;
  65576. /**
  65577. * Gets the indirect clear coat output component
  65578. */
  65579. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  65580. /**
  65581. * Gets the refraction output component
  65582. */
  65583. get refraction(): NodeMaterialConnectionPoint;
  65584. /**
  65585. * Gets the global lighting output component
  65586. */
  65587. get lighting(): NodeMaterialConnectionPoint;
  65588. /**
  65589. * Gets the shadow output component
  65590. */
  65591. get shadow(): NodeMaterialConnectionPoint;
  65592. /**
  65593. * Gets the alpha output component
  65594. */
  65595. get alpha(): NodeMaterialConnectionPoint;
  65596. autoConfigure(material: NodeMaterial): void;
  65597. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65598. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  65599. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65600. private _injectVertexCode;
  65601. /**
  65602. * Gets the code corresponding to the albedo/opacity module
  65603. * @returns the shader code
  65604. */
  65605. getAlbedoOpacityCode(): string;
  65606. protected _buildBlock(state: NodeMaterialBuildState): this;
  65607. protected _dumpPropertiesCode(): string;
  65608. serialize(): any;
  65609. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65610. }
  65611. }
  65612. declare module BABYLON {
  65613. /**
  65614. * Block used to compute value of one parameter modulo another
  65615. */
  65616. export class ModBlock extends NodeMaterialBlock {
  65617. /**
  65618. * Creates a new ModBlock
  65619. * @param name defines the block name
  65620. */
  65621. constructor(name: string);
  65622. /**
  65623. * Gets the current class name
  65624. * @returns the class name
  65625. */
  65626. getClassName(): string;
  65627. /**
  65628. * Gets the left operand input component
  65629. */
  65630. get left(): NodeMaterialConnectionPoint;
  65631. /**
  65632. * Gets the right operand input component
  65633. */
  65634. get right(): NodeMaterialConnectionPoint;
  65635. /**
  65636. * Gets the output component
  65637. */
  65638. get output(): NodeMaterialConnectionPoint;
  65639. protected _buildBlock(state: NodeMaterialBuildState): this;
  65640. }
  65641. }
  65642. declare module BABYLON {
  65643. /**
  65644. * Configuration for Draco compression
  65645. */
  65646. export interface IDracoCompressionConfiguration {
  65647. /**
  65648. * Configuration for the decoder.
  65649. */
  65650. decoder: {
  65651. /**
  65652. * The url to the WebAssembly module.
  65653. */
  65654. wasmUrl?: string;
  65655. /**
  65656. * The url to the WebAssembly binary.
  65657. */
  65658. wasmBinaryUrl?: string;
  65659. /**
  65660. * The url to the fallback JavaScript module.
  65661. */
  65662. fallbackUrl?: string;
  65663. };
  65664. }
  65665. /**
  65666. * Draco compression (https://google.github.io/draco/)
  65667. *
  65668. * This class wraps the Draco module.
  65669. *
  65670. * **Encoder**
  65671. *
  65672. * The encoder is not currently implemented.
  65673. *
  65674. * **Decoder**
  65675. *
  65676. * 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.
  65677. *
  65678. * To update the configuration, use the following code:
  65679. * ```javascript
  65680. * DracoCompression.Configuration = {
  65681. * decoder: {
  65682. * wasmUrl: "<url to the WebAssembly library>",
  65683. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  65684. * fallbackUrl: "<url to the fallback JavaScript library>",
  65685. * }
  65686. * };
  65687. * ```
  65688. *
  65689. * 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.
  65690. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  65691. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  65692. *
  65693. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  65694. * ```javascript
  65695. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  65696. * ```
  65697. *
  65698. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  65699. */
  65700. export class DracoCompression implements IDisposable {
  65701. private _workerPoolPromise?;
  65702. private _decoderModulePromise?;
  65703. /**
  65704. * The configuration. Defaults to the following urls:
  65705. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  65706. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  65707. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  65708. */
  65709. static Configuration: IDracoCompressionConfiguration;
  65710. /**
  65711. * Returns true if the decoder configuration is available.
  65712. */
  65713. static get DecoderAvailable(): boolean;
  65714. /**
  65715. * Default number of workers to create when creating the draco compression object.
  65716. */
  65717. static DefaultNumWorkers: number;
  65718. private static GetDefaultNumWorkers;
  65719. private static _Default;
  65720. /**
  65721. * Default instance for the draco compression object.
  65722. */
  65723. static get Default(): DracoCompression;
  65724. /**
  65725. * Constructor
  65726. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  65727. */
  65728. constructor(numWorkers?: number);
  65729. /**
  65730. * Stop all async operations and release resources.
  65731. */
  65732. dispose(): void;
  65733. /**
  65734. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  65735. * @returns a promise that resolves when ready
  65736. */
  65737. whenReadyAsync(): Promise<void>;
  65738. /**
  65739. * Decode Draco compressed mesh data to vertex data.
  65740. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  65741. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  65742. * @returns A promise that resolves with the decoded vertex data
  65743. */
  65744. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  65745. [kind: string]: number;
  65746. }): Promise<VertexData>;
  65747. }
  65748. }
  65749. declare module BABYLON {
  65750. /**
  65751. * Class for building Constructive Solid Geometry
  65752. */
  65753. export class CSG {
  65754. private polygons;
  65755. /**
  65756. * The world matrix
  65757. */
  65758. matrix: Matrix;
  65759. /**
  65760. * Stores the position
  65761. */
  65762. position: Vector3;
  65763. /**
  65764. * Stores the rotation
  65765. */
  65766. rotation: Vector3;
  65767. /**
  65768. * Stores the rotation quaternion
  65769. */
  65770. rotationQuaternion: Nullable<Quaternion>;
  65771. /**
  65772. * Stores the scaling vector
  65773. */
  65774. scaling: Vector3;
  65775. /**
  65776. * Convert the Mesh to CSG
  65777. * @param mesh The Mesh to convert to CSG
  65778. * @returns A new CSG from the Mesh
  65779. */
  65780. static FromMesh(mesh: Mesh): CSG;
  65781. /**
  65782. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  65783. * @param polygons Polygons used to construct a CSG solid
  65784. */
  65785. private static FromPolygons;
  65786. /**
  65787. * Clones, or makes a deep copy, of the CSG
  65788. * @returns A new CSG
  65789. */
  65790. clone(): CSG;
  65791. /**
  65792. * Unions this CSG with another CSG
  65793. * @param csg The CSG to union against this CSG
  65794. * @returns The unioned CSG
  65795. */
  65796. union(csg: CSG): CSG;
  65797. /**
  65798. * Unions this CSG with another CSG in place
  65799. * @param csg The CSG to union against this CSG
  65800. */
  65801. unionInPlace(csg: CSG): void;
  65802. /**
  65803. * Subtracts this CSG with another CSG
  65804. * @param csg The CSG to subtract against this CSG
  65805. * @returns A new CSG
  65806. */
  65807. subtract(csg: CSG): CSG;
  65808. /**
  65809. * Subtracts this CSG with another CSG in place
  65810. * @param csg The CSG to subtact against this CSG
  65811. */
  65812. subtractInPlace(csg: CSG): void;
  65813. /**
  65814. * Intersect this CSG with another CSG
  65815. * @param csg The CSG to intersect against this CSG
  65816. * @returns A new CSG
  65817. */
  65818. intersect(csg: CSG): CSG;
  65819. /**
  65820. * Intersects this CSG with another CSG in place
  65821. * @param csg The CSG to intersect against this CSG
  65822. */
  65823. intersectInPlace(csg: CSG): void;
  65824. /**
  65825. * Return a new CSG solid with solid and empty space switched. This solid is
  65826. * not modified.
  65827. * @returns A new CSG solid with solid and empty space switched
  65828. */
  65829. inverse(): CSG;
  65830. /**
  65831. * Inverses the CSG in place
  65832. */
  65833. inverseInPlace(): void;
  65834. /**
  65835. * This is used to keep meshes transformations so they can be restored
  65836. * when we build back a Babylon Mesh
  65837. * NB : All CSG operations are performed in world coordinates
  65838. * @param csg The CSG to copy the transform attributes from
  65839. * @returns This CSG
  65840. */
  65841. copyTransformAttributes(csg: CSG): CSG;
  65842. /**
  65843. * Build Raw mesh from CSG
  65844. * Coordinates here are in world space
  65845. * @param name The name of the mesh geometry
  65846. * @param scene The Scene
  65847. * @param keepSubMeshes Specifies if the submeshes should be kept
  65848. * @returns A new Mesh
  65849. */
  65850. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  65851. /**
  65852. * Build Mesh from CSG taking material and transforms into account
  65853. * @param name The name of the Mesh
  65854. * @param material The material of the Mesh
  65855. * @param scene The Scene
  65856. * @param keepSubMeshes Specifies if submeshes should be kept
  65857. * @returns The new Mesh
  65858. */
  65859. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  65860. }
  65861. }
  65862. declare module BABYLON {
  65863. /**
  65864. * Class used to create a trail following a mesh
  65865. */
  65866. export class TrailMesh extends Mesh {
  65867. private _generator;
  65868. private _autoStart;
  65869. private _running;
  65870. private _diameter;
  65871. private _length;
  65872. private _sectionPolygonPointsCount;
  65873. private _sectionVectors;
  65874. private _sectionNormalVectors;
  65875. private _beforeRenderObserver;
  65876. /**
  65877. * @constructor
  65878. * @param name The value used by scene.getMeshByName() to do a lookup.
  65879. * @param generator The mesh or transform node to generate a trail.
  65880. * @param scene The scene to add this mesh to.
  65881. * @param diameter Diameter of trailing mesh. Default is 1.
  65882. * @param length Length of trailing mesh. Default is 60.
  65883. * @param autoStart Automatically start trailing mesh. Default true.
  65884. */
  65885. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  65886. /**
  65887. * "TrailMesh"
  65888. * @returns "TrailMesh"
  65889. */
  65890. getClassName(): string;
  65891. private _createMesh;
  65892. /**
  65893. * Start trailing mesh.
  65894. */
  65895. start(): void;
  65896. /**
  65897. * Stop trailing mesh.
  65898. */
  65899. stop(): void;
  65900. /**
  65901. * Update trailing mesh geometry.
  65902. */
  65903. update(): void;
  65904. /**
  65905. * Returns a new TrailMesh object.
  65906. * @param name is a string, the name given to the new mesh
  65907. * @param newGenerator use new generator object for cloned trail mesh
  65908. * @returns a new mesh
  65909. */
  65910. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  65911. /**
  65912. * Serializes this trail mesh
  65913. * @param serializationObject object to write serialization to
  65914. */
  65915. serialize(serializationObject: any): void;
  65916. /**
  65917. * Parses a serialized trail mesh
  65918. * @param parsedMesh the serialized mesh
  65919. * @param scene the scene to create the trail mesh in
  65920. * @returns the created trail mesh
  65921. */
  65922. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  65923. }
  65924. }
  65925. declare module BABYLON {
  65926. /**
  65927. * Class containing static functions to help procedurally build meshes
  65928. */
  65929. export class TiledBoxBuilder {
  65930. /**
  65931. * Creates a box mesh
  65932. * 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)
  65933. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  65934. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65935. * * 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
  65936. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65937. * @param name defines the name of the mesh
  65938. * @param options defines the options used to create the mesh
  65939. * @param scene defines the hosting scene
  65940. * @returns the box mesh
  65941. */
  65942. static CreateTiledBox(name: string, options: {
  65943. pattern?: number;
  65944. width?: number;
  65945. height?: number;
  65946. depth?: number;
  65947. tileSize?: number;
  65948. tileWidth?: number;
  65949. tileHeight?: number;
  65950. alignHorizontal?: number;
  65951. alignVertical?: number;
  65952. faceUV?: Vector4[];
  65953. faceColors?: Color4[];
  65954. sideOrientation?: number;
  65955. updatable?: boolean;
  65956. }, scene?: Nullable<Scene>): Mesh;
  65957. }
  65958. }
  65959. declare module BABYLON {
  65960. /**
  65961. * Class containing static functions to help procedurally build meshes
  65962. */
  65963. export class TorusKnotBuilder {
  65964. /**
  65965. * Creates a torus knot mesh
  65966. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  65967. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  65968. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  65969. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  65970. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65971. * * 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
  65972. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65973. * @param name defines the name of the mesh
  65974. * @param options defines the options used to create the mesh
  65975. * @param scene defines the hosting scene
  65976. * @returns the torus knot mesh
  65977. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  65978. */
  65979. static CreateTorusKnot(name: string, options: {
  65980. radius?: number;
  65981. tube?: number;
  65982. radialSegments?: number;
  65983. tubularSegments?: number;
  65984. p?: number;
  65985. q?: number;
  65986. updatable?: boolean;
  65987. sideOrientation?: number;
  65988. frontUVs?: Vector4;
  65989. backUVs?: Vector4;
  65990. }, scene: any): Mesh;
  65991. }
  65992. }
  65993. declare module BABYLON {
  65994. /**
  65995. * Polygon
  65996. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  65997. */
  65998. export class Polygon {
  65999. /**
  66000. * Creates a rectangle
  66001. * @param xmin bottom X coord
  66002. * @param ymin bottom Y coord
  66003. * @param xmax top X coord
  66004. * @param ymax top Y coord
  66005. * @returns points that make the resulting rectation
  66006. */
  66007. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  66008. /**
  66009. * Creates a circle
  66010. * @param radius radius of circle
  66011. * @param cx scale in x
  66012. * @param cy scale in y
  66013. * @param numberOfSides number of sides that make up the circle
  66014. * @returns points that make the resulting circle
  66015. */
  66016. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  66017. /**
  66018. * Creates a polygon from input string
  66019. * @param input Input polygon data
  66020. * @returns the parsed points
  66021. */
  66022. static Parse(input: string): Vector2[];
  66023. /**
  66024. * Starts building a polygon from x and y coordinates
  66025. * @param x x coordinate
  66026. * @param y y coordinate
  66027. * @returns the started path2
  66028. */
  66029. static StartingAt(x: number, y: number): Path2;
  66030. }
  66031. /**
  66032. * Builds a polygon
  66033. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  66034. */
  66035. export class PolygonMeshBuilder {
  66036. private _points;
  66037. private _outlinepoints;
  66038. private _holes;
  66039. private _name;
  66040. private _scene;
  66041. private _epoints;
  66042. private _eholes;
  66043. private _addToepoint;
  66044. /**
  66045. * Babylon reference to the earcut plugin.
  66046. */
  66047. bjsEarcut: any;
  66048. /**
  66049. * Creates a PolygonMeshBuilder
  66050. * @param name name of the builder
  66051. * @param contours Path of the polygon
  66052. * @param scene scene to add to when creating the mesh
  66053. * @param earcutInjection can be used to inject your own earcut reference
  66054. */
  66055. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  66056. /**
  66057. * Adds a whole within the polygon
  66058. * @param hole Array of points defining the hole
  66059. * @returns this
  66060. */
  66061. addHole(hole: Vector2[]): PolygonMeshBuilder;
  66062. /**
  66063. * Creates the polygon
  66064. * @param updatable If the mesh should be updatable
  66065. * @param depth The depth of the mesh created
  66066. * @returns the created mesh
  66067. */
  66068. build(updatable?: boolean, depth?: number): Mesh;
  66069. /**
  66070. * Creates the polygon
  66071. * @param depth The depth of the mesh created
  66072. * @returns the created VertexData
  66073. */
  66074. buildVertexData(depth?: number): VertexData;
  66075. /**
  66076. * Adds a side to the polygon
  66077. * @param positions points that make the polygon
  66078. * @param normals normals of the polygon
  66079. * @param uvs uvs of the polygon
  66080. * @param indices indices of the polygon
  66081. * @param bounds bounds of the polygon
  66082. * @param points points of the polygon
  66083. * @param depth depth of the polygon
  66084. * @param flip flip of the polygon
  66085. */
  66086. private addSide;
  66087. }
  66088. }
  66089. declare module BABYLON {
  66090. /**
  66091. * Class containing static functions to help procedurally build meshes
  66092. */
  66093. export class PolygonBuilder {
  66094. /**
  66095. * Creates a polygon mesh
  66096. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  66097. * * 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
  66098. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  66099. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66100. * * 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)
  66101. * * Remember you can only change the shape positions, not their number when updating a polygon
  66102. * @param name defines the name of the mesh
  66103. * @param options defines the options used to create the mesh
  66104. * @param scene defines the hosting scene
  66105. * @param earcutInjection can be used to inject your own earcut reference
  66106. * @returns the polygon mesh
  66107. */
  66108. static CreatePolygon(name: string, options: {
  66109. shape: Vector3[];
  66110. holes?: Vector3[][];
  66111. depth?: number;
  66112. faceUV?: Vector4[];
  66113. faceColors?: Color4[];
  66114. updatable?: boolean;
  66115. sideOrientation?: number;
  66116. frontUVs?: Vector4;
  66117. backUVs?: Vector4;
  66118. wrap?: boolean;
  66119. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66120. /**
  66121. * Creates an extruded polygon mesh, with depth in the Y direction.
  66122. * * 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)
  66123. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  66124. * @param name defines the name of the mesh
  66125. * @param options defines the options used to create the mesh
  66126. * @param scene defines the hosting scene
  66127. * @param earcutInjection can be used to inject your own earcut reference
  66128. * @returns the polygon mesh
  66129. */
  66130. static ExtrudePolygon(name: string, options: {
  66131. shape: Vector3[];
  66132. holes?: Vector3[][];
  66133. depth?: number;
  66134. faceUV?: Vector4[];
  66135. faceColors?: Color4[];
  66136. updatable?: boolean;
  66137. sideOrientation?: number;
  66138. frontUVs?: Vector4;
  66139. backUVs?: Vector4;
  66140. wrap?: boolean;
  66141. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66142. }
  66143. }
  66144. declare module BABYLON {
  66145. /**
  66146. * Class containing static functions to help procedurally build meshes
  66147. */
  66148. export class LatheBuilder {
  66149. /**
  66150. * Creates lathe mesh.
  66151. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  66152. * * 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
  66153. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  66154. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  66155. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  66156. * * 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
  66157. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  66158. * * 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
  66159. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66160. * * 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
  66161. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66162. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66163. * @param name defines the name of the mesh
  66164. * @param options defines the options used to create the mesh
  66165. * @param scene defines the hosting scene
  66166. * @returns the lathe mesh
  66167. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  66168. */
  66169. static CreateLathe(name: string, options: {
  66170. shape: Vector3[];
  66171. radius?: number;
  66172. tessellation?: number;
  66173. clip?: number;
  66174. arc?: number;
  66175. closed?: boolean;
  66176. updatable?: boolean;
  66177. sideOrientation?: number;
  66178. frontUVs?: Vector4;
  66179. backUVs?: Vector4;
  66180. cap?: number;
  66181. invertUV?: boolean;
  66182. }, scene?: Nullable<Scene>): Mesh;
  66183. }
  66184. }
  66185. declare module BABYLON {
  66186. /**
  66187. * Class containing static functions to help procedurally build meshes
  66188. */
  66189. export class TiledPlaneBuilder {
  66190. /**
  66191. * Creates a tiled plane mesh
  66192. * * The parameter `pattern` will, depending on value, do nothing or
  66193. * * * flip (reflect about central vertical) alternate tiles across and up
  66194. * * * flip every tile on alternate rows
  66195. * * * rotate (180 degs) alternate tiles across and up
  66196. * * * rotate every tile on alternate rows
  66197. * * * flip and rotate alternate tiles across and up
  66198. * * * flip and rotate every tile on alternate rows
  66199. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  66200. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  66201. * * 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
  66202. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  66203. * * 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)
  66204. * * 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)
  66205. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  66206. * @param name defines the name of the mesh
  66207. * @param options defines the options used to create the mesh
  66208. * @param scene defines the hosting scene
  66209. * @returns the box mesh
  66210. */
  66211. static CreateTiledPlane(name: string, options: {
  66212. pattern?: number;
  66213. tileSize?: number;
  66214. tileWidth?: number;
  66215. tileHeight?: number;
  66216. size?: number;
  66217. width?: number;
  66218. height?: number;
  66219. alignHorizontal?: number;
  66220. alignVertical?: number;
  66221. sideOrientation?: number;
  66222. frontUVs?: Vector4;
  66223. backUVs?: Vector4;
  66224. updatable?: boolean;
  66225. }, scene?: Nullable<Scene>): Mesh;
  66226. }
  66227. }
  66228. declare module BABYLON {
  66229. /**
  66230. * Class containing static functions to help procedurally build meshes
  66231. */
  66232. export class TubeBuilder {
  66233. /**
  66234. * Creates a tube mesh.
  66235. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  66236. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  66237. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  66238. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  66239. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  66240. * * 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)
  66241. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  66242. * * 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
  66243. * * 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
  66244. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66245. * * 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
  66246. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66247. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66248. * @param name defines the name of the mesh
  66249. * @param options defines the options used to create the mesh
  66250. * @param scene defines the hosting scene
  66251. * @returns the tube mesh
  66252. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66253. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  66254. */
  66255. static CreateTube(name: string, options: {
  66256. path: Vector3[];
  66257. radius?: number;
  66258. tessellation?: number;
  66259. radiusFunction?: {
  66260. (i: number, distance: number): number;
  66261. };
  66262. cap?: number;
  66263. arc?: number;
  66264. updatable?: boolean;
  66265. sideOrientation?: number;
  66266. frontUVs?: Vector4;
  66267. backUVs?: Vector4;
  66268. instance?: Mesh;
  66269. invertUV?: boolean;
  66270. }, scene?: Nullable<Scene>): Mesh;
  66271. }
  66272. }
  66273. declare module BABYLON {
  66274. /**
  66275. * Class containing static functions to help procedurally build meshes
  66276. */
  66277. export class IcoSphereBuilder {
  66278. /**
  66279. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  66280. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  66281. * * 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`)
  66282. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  66283. * * 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
  66284. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66285. * * 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
  66286. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66287. * @param name defines the name of the mesh
  66288. * @param options defines the options used to create the mesh
  66289. * @param scene defines the hosting scene
  66290. * @returns the icosahedron mesh
  66291. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  66292. */
  66293. static CreateIcoSphere(name: string, options: {
  66294. radius?: number;
  66295. radiusX?: number;
  66296. radiusY?: number;
  66297. radiusZ?: number;
  66298. flat?: boolean;
  66299. subdivisions?: number;
  66300. sideOrientation?: number;
  66301. frontUVs?: Vector4;
  66302. backUVs?: Vector4;
  66303. updatable?: boolean;
  66304. }, scene?: Nullable<Scene>): Mesh;
  66305. }
  66306. }
  66307. declare module BABYLON {
  66308. /**
  66309. * Class containing static functions to help procedurally build meshes
  66310. */
  66311. export class DecalBuilder {
  66312. /**
  66313. * Creates a decal mesh.
  66314. * 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
  66315. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  66316. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  66317. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  66318. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  66319. * @param name defines the name of the mesh
  66320. * @param sourceMesh defines the mesh where the decal must be applied
  66321. * @param options defines the options used to create the mesh
  66322. * @param scene defines the hosting scene
  66323. * @returns the decal mesh
  66324. * @see https://doc.babylonjs.com/how_to/decals
  66325. */
  66326. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  66327. position?: Vector3;
  66328. normal?: Vector3;
  66329. size?: Vector3;
  66330. angle?: number;
  66331. }): Mesh;
  66332. }
  66333. }
  66334. declare module BABYLON {
  66335. /**
  66336. * Class containing static functions to help procedurally build meshes
  66337. */
  66338. export class MeshBuilder {
  66339. /**
  66340. * Creates a box mesh
  66341. * * The parameter `size` sets the size (float) of each box side (default 1)
  66342. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  66343. * * 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)
  66344. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  66345. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66346. * * 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
  66347. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66348. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  66349. * @param name defines the name of the mesh
  66350. * @param options defines the options used to create the mesh
  66351. * @param scene defines the hosting scene
  66352. * @returns the box mesh
  66353. */
  66354. static CreateBox(name: string, options: {
  66355. size?: number;
  66356. width?: number;
  66357. height?: number;
  66358. depth?: number;
  66359. faceUV?: Vector4[];
  66360. faceColors?: Color4[];
  66361. sideOrientation?: number;
  66362. frontUVs?: Vector4;
  66363. backUVs?: Vector4;
  66364. wrap?: boolean;
  66365. topBaseAt?: number;
  66366. bottomBaseAt?: number;
  66367. updatable?: boolean;
  66368. }, scene?: Nullable<Scene>): Mesh;
  66369. /**
  66370. * Creates a tiled box mesh
  66371. * * faceTiles sets the pattern, tile size and number of tiles for a face
  66372. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66373. * @param name defines the name of the mesh
  66374. * @param options defines the options used to create the mesh
  66375. * @param scene defines the hosting scene
  66376. * @returns the tiled box mesh
  66377. */
  66378. static CreateTiledBox(name: string, options: {
  66379. pattern?: number;
  66380. size?: number;
  66381. width?: number;
  66382. height?: number;
  66383. depth: number;
  66384. tileSize?: number;
  66385. tileWidth?: number;
  66386. tileHeight?: number;
  66387. faceUV?: Vector4[];
  66388. faceColors?: Color4[];
  66389. alignHorizontal?: number;
  66390. alignVertical?: number;
  66391. sideOrientation?: number;
  66392. updatable?: boolean;
  66393. }, scene?: Nullable<Scene>): Mesh;
  66394. /**
  66395. * Creates a sphere mesh
  66396. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  66397. * * 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`)
  66398. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  66399. * * 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
  66400. * * 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)
  66401. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66402. * * 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
  66403. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66404. * @param name defines the name of the mesh
  66405. * @param options defines the options used to create the mesh
  66406. * @param scene defines the hosting scene
  66407. * @returns the sphere mesh
  66408. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  66409. */
  66410. static CreateSphere(name: string, options: {
  66411. segments?: number;
  66412. diameter?: number;
  66413. diameterX?: number;
  66414. diameterY?: number;
  66415. diameterZ?: number;
  66416. arc?: number;
  66417. slice?: number;
  66418. sideOrientation?: number;
  66419. frontUVs?: Vector4;
  66420. backUVs?: Vector4;
  66421. updatable?: boolean;
  66422. }, scene?: Nullable<Scene>): Mesh;
  66423. /**
  66424. * Creates a plane polygonal mesh. By default, this is a disc
  66425. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  66426. * * 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
  66427. * * 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
  66428. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66429. * * 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
  66430. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66431. * @param name defines the name of the mesh
  66432. * @param options defines the options used to create the mesh
  66433. * @param scene defines the hosting scene
  66434. * @returns the plane polygonal mesh
  66435. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  66436. */
  66437. static CreateDisc(name: string, options: {
  66438. radius?: number;
  66439. tessellation?: number;
  66440. arc?: number;
  66441. updatable?: boolean;
  66442. sideOrientation?: number;
  66443. frontUVs?: Vector4;
  66444. backUVs?: Vector4;
  66445. }, scene?: Nullable<Scene>): Mesh;
  66446. /**
  66447. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  66448. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  66449. * * 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`)
  66450. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  66451. * * 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
  66452. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66453. * * 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
  66454. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66455. * @param name defines the name of the mesh
  66456. * @param options defines the options used to create the mesh
  66457. * @param scene defines the hosting scene
  66458. * @returns the icosahedron mesh
  66459. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  66460. */
  66461. static CreateIcoSphere(name: string, options: {
  66462. radius?: number;
  66463. radiusX?: number;
  66464. radiusY?: number;
  66465. radiusZ?: number;
  66466. flat?: boolean;
  66467. subdivisions?: number;
  66468. sideOrientation?: number;
  66469. frontUVs?: Vector4;
  66470. backUVs?: Vector4;
  66471. updatable?: boolean;
  66472. }, scene?: Nullable<Scene>): Mesh;
  66473. /**
  66474. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  66475. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  66476. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  66477. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  66478. * * 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
  66479. * * 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
  66480. * * 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
  66481. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66482. * * 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
  66483. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66484. * * 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
  66485. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  66486. * * 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
  66487. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  66488. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66489. * @param name defines the name of the mesh
  66490. * @param options defines the options used to create the mesh
  66491. * @param scene defines the hosting scene
  66492. * @returns the ribbon mesh
  66493. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  66494. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66495. */
  66496. static CreateRibbon(name: string, options: {
  66497. pathArray: Vector3[][];
  66498. closeArray?: boolean;
  66499. closePath?: boolean;
  66500. offset?: number;
  66501. updatable?: boolean;
  66502. sideOrientation?: number;
  66503. frontUVs?: Vector4;
  66504. backUVs?: Vector4;
  66505. instance?: Mesh;
  66506. invertUV?: boolean;
  66507. uvs?: Vector2[];
  66508. colors?: Color4[];
  66509. }, scene?: Nullable<Scene>): Mesh;
  66510. /**
  66511. * Creates a cylinder or a cone mesh
  66512. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  66513. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  66514. * * 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.
  66515. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  66516. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  66517. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  66518. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  66519. * * 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).
  66520. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  66521. * * 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).
  66522. * * 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
  66523. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  66524. * * 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
  66525. * * 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.
  66526. * * If `enclose` is false, a ring surface is one element.
  66527. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  66528. * * 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
  66529. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66530. * * 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
  66531. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66532. * @param name defines the name of the mesh
  66533. * @param options defines the options used to create the mesh
  66534. * @param scene defines the hosting scene
  66535. * @returns the cylinder mesh
  66536. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  66537. */
  66538. static CreateCylinder(name: string, options: {
  66539. height?: number;
  66540. diameterTop?: number;
  66541. diameterBottom?: number;
  66542. diameter?: number;
  66543. tessellation?: number;
  66544. subdivisions?: number;
  66545. arc?: number;
  66546. faceColors?: Color4[];
  66547. faceUV?: Vector4[];
  66548. updatable?: boolean;
  66549. hasRings?: boolean;
  66550. enclose?: boolean;
  66551. cap?: number;
  66552. sideOrientation?: number;
  66553. frontUVs?: Vector4;
  66554. backUVs?: Vector4;
  66555. }, scene?: Nullable<Scene>): Mesh;
  66556. /**
  66557. * Creates a torus mesh
  66558. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  66559. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  66560. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  66561. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66562. * * 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
  66563. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66564. * @param name defines the name of the mesh
  66565. * @param options defines the options used to create the mesh
  66566. * @param scene defines the hosting scene
  66567. * @returns the torus mesh
  66568. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  66569. */
  66570. static CreateTorus(name: string, options: {
  66571. diameter?: number;
  66572. thickness?: number;
  66573. tessellation?: number;
  66574. updatable?: boolean;
  66575. sideOrientation?: number;
  66576. frontUVs?: Vector4;
  66577. backUVs?: Vector4;
  66578. }, scene?: Nullable<Scene>): Mesh;
  66579. /**
  66580. * Creates a torus knot mesh
  66581. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  66582. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  66583. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  66584. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  66585. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66586. * * 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
  66587. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66588. * @param name defines the name of the mesh
  66589. * @param options defines the options used to create the mesh
  66590. * @param scene defines the hosting scene
  66591. * @returns the torus knot mesh
  66592. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  66593. */
  66594. static CreateTorusKnot(name: string, options: {
  66595. radius?: number;
  66596. tube?: number;
  66597. radialSegments?: number;
  66598. tubularSegments?: number;
  66599. p?: number;
  66600. q?: number;
  66601. updatable?: boolean;
  66602. sideOrientation?: number;
  66603. frontUVs?: Vector4;
  66604. backUVs?: Vector4;
  66605. }, scene?: Nullable<Scene>): Mesh;
  66606. /**
  66607. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  66608. * * 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
  66609. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  66610. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  66611. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  66612. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  66613. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  66614. * * 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
  66615. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  66616. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66617. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  66618. * @param name defines the name of the new line system
  66619. * @param options defines the options used to create the line system
  66620. * @param scene defines the hosting scene
  66621. * @returns a new line system mesh
  66622. */
  66623. static CreateLineSystem(name: string, options: {
  66624. lines: Vector3[][];
  66625. updatable?: boolean;
  66626. instance?: Nullable<LinesMesh>;
  66627. colors?: Nullable<Color4[][]>;
  66628. useVertexAlpha?: boolean;
  66629. }, scene: Nullable<Scene>): LinesMesh;
  66630. /**
  66631. * Creates a line mesh
  66632. * 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
  66633. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  66634. * * The parameter `points` is an array successive Vector3
  66635. * * 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
  66636. * * The optional parameter `colors` is an array of successive Color4, one per line point
  66637. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  66638. * * When updating an instance, remember that only point positions can change, not the number of points
  66639. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66640. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  66641. * @param name defines the name of the new line system
  66642. * @param options defines the options used to create the line system
  66643. * @param scene defines the hosting scene
  66644. * @returns a new line mesh
  66645. */
  66646. static CreateLines(name: string, options: {
  66647. points: Vector3[];
  66648. updatable?: boolean;
  66649. instance?: Nullable<LinesMesh>;
  66650. colors?: Color4[];
  66651. useVertexAlpha?: boolean;
  66652. }, scene?: Nullable<Scene>): LinesMesh;
  66653. /**
  66654. * Creates a dashed line mesh
  66655. * * 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
  66656. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  66657. * * The parameter `points` is an array successive Vector3
  66658. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  66659. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  66660. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  66661. * * 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
  66662. * * When updating an instance, remember that only point positions can change, not the number of points
  66663. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66664. * @param name defines the name of the mesh
  66665. * @param options defines the options used to create the mesh
  66666. * @param scene defines the hosting scene
  66667. * @returns the dashed line mesh
  66668. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  66669. */
  66670. static CreateDashedLines(name: string, options: {
  66671. points: Vector3[];
  66672. dashSize?: number;
  66673. gapSize?: number;
  66674. dashNb?: number;
  66675. updatable?: boolean;
  66676. instance?: LinesMesh;
  66677. }, scene?: Nullable<Scene>): LinesMesh;
  66678. /**
  66679. * 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.
  66680. * * 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.
  66681. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  66682. * * 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.
  66683. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  66684. * * 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
  66685. * * 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
  66686. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  66687. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66688. * * 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
  66689. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  66690. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66691. * @param name defines the name of the mesh
  66692. * @param options defines the options used to create the mesh
  66693. * @param scene defines the hosting scene
  66694. * @returns the extruded shape mesh
  66695. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66696. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  66697. */
  66698. static ExtrudeShape(name: string, options: {
  66699. shape: Vector3[];
  66700. path: Vector3[];
  66701. scale?: number;
  66702. rotation?: number;
  66703. cap?: number;
  66704. updatable?: boolean;
  66705. sideOrientation?: number;
  66706. frontUVs?: Vector4;
  66707. backUVs?: Vector4;
  66708. instance?: Mesh;
  66709. invertUV?: boolean;
  66710. }, scene?: Nullable<Scene>): Mesh;
  66711. /**
  66712. * Creates an custom extruded shape mesh.
  66713. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  66714. * * 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.
  66715. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  66716. * * 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
  66717. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  66718. * * 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
  66719. * * It must returns a float value that will be the scale value applied to the shape on each path point
  66720. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  66721. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  66722. * * 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
  66723. * * 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
  66724. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  66725. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66726. * * 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
  66727. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66728. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66729. * @param name defines the name of the mesh
  66730. * @param options defines the options used to create the mesh
  66731. * @param scene defines the hosting scene
  66732. * @returns the custom extruded shape mesh
  66733. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  66734. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66735. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  66736. */
  66737. static ExtrudeShapeCustom(name: string, options: {
  66738. shape: Vector3[];
  66739. path: Vector3[];
  66740. scaleFunction?: any;
  66741. rotationFunction?: any;
  66742. ribbonCloseArray?: boolean;
  66743. ribbonClosePath?: boolean;
  66744. cap?: number;
  66745. updatable?: boolean;
  66746. sideOrientation?: number;
  66747. frontUVs?: Vector4;
  66748. backUVs?: Vector4;
  66749. instance?: Mesh;
  66750. invertUV?: boolean;
  66751. }, scene?: Nullable<Scene>): Mesh;
  66752. /**
  66753. * Creates lathe mesh.
  66754. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  66755. * * 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
  66756. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  66757. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  66758. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  66759. * * 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
  66760. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  66761. * * 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
  66762. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66763. * * 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
  66764. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66765. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66766. * @param name defines the name of the mesh
  66767. * @param options defines the options used to create the mesh
  66768. * @param scene defines the hosting scene
  66769. * @returns the lathe mesh
  66770. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  66771. */
  66772. static CreateLathe(name: string, options: {
  66773. shape: Vector3[];
  66774. radius?: number;
  66775. tessellation?: number;
  66776. clip?: number;
  66777. arc?: number;
  66778. closed?: boolean;
  66779. updatable?: boolean;
  66780. sideOrientation?: number;
  66781. frontUVs?: Vector4;
  66782. backUVs?: Vector4;
  66783. cap?: number;
  66784. invertUV?: boolean;
  66785. }, scene?: Nullable<Scene>): Mesh;
  66786. /**
  66787. * Creates a tiled plane mesh
  66788. * * You can set a limited pattern arrangement with the tiles
  66789. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66790. * * 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
  66791. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66792. * @param name defines the name of the mesh
  66793. * @param options defines the options used to create the mesh
  66794. * @param scene defines the hosting scene
  66795. * @returns the plane mesh
  66796. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  66797. */
  66798. static CreateTiledPlane(name: string, options: {
  66799. pattern?: number;
  66800. tileSize?: number;
  66801. tileWidth?: number;
  66802. tileHeight?: number;
  66803. size?: number;
  66804. width?: number;
  66805. height?: number;
  66806. alignHorizontal?: number;
  66807. alignVertical?: number;
  66808. sideOrientation?: number;
  66809. frontUVs?: Vector4;
  66810. backUVs?: Vector4;
  66811. updatable?: boolean;
  66812. }, scene?: Nullable<Scene>): Mesh;
  66813. /**
  66814. * Creates a plane mesh
  66815. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  66816. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  66817. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  66818. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66819. * * 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
  66820. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66821. * @param name defines the name of the mesh
  66822. * @param options defines the options used to create the mesh
  66823. * @param scene defines the hosting scene
  66824. * @returns the plane mesh
  66825. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  66826. */
  66827. static CreatePlane(name: string, options: {
  66828. size?: number;
  66829. width?: number;
  66830. height?: number;
  66831. sideOrientation?: number;
  66832. frontUVs?: Vector4;
  66833. backUVs?: Vector4;
  66834. updatable?: boolean;
  66835. sourcePlane?: Plane;
  66836. }, scene?: Nullable<Scene>): Mesh;
  66837. /**
  66838. * Creates a ground mesh
  66839. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  66840. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  66841. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66842. * @param name defines the name of the mesh
  66843. * @param options defines the options used to create the mesh
  66844. * @param scene defines the hosting scene
  66845. * @returns the ground mesh
  66846. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  66847. */
  66848. static CreateGround(name: string, options: {
  66849. width?: number;
  66850. height?: number;
  66851. subdivisions?: number;
  66852. subdivisionsX?: number;
  66853. subdivisionsY?: number;
  66854. updatable?: boolean;
  66855. }, scene?: Nullable<Scene>): Mesh;
  66856. /**
  66857. * Creates a tiled ground mesh
  66858. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  66859. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  66860. * * 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
  66861. * * 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
  66862. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66863. * @param name defines the name of the mesh
  66864. * @param options defines the options used to create the mesh
  66865. * @param scene defines the hosting scene
  66866. * @returns the tiled ground mesh
  66867. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  66868. */
  66869. static CreateTiledGround(name: string, options: {
  66870. xmin: number;
  66871. zmin: number;
  66872. xmax: number;
  66873. zmax: number;
  66874. subdivisions?: {
  66875. w: number;
  66876. h: number;
  66877. };
  66878. precision?: {
  66879. w: number;
  66880. h: number;
  66881. };
  66882. updatable?: boolean;
  66883. }, scene?: Nullable<Scene>): Mesh;
  66884. /**
  66885. * Creates a ground mesh from a height map
  66886. * * The parameter `url` sets the URL of the height map image resource.
  66887. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  66888. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  66889. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  66890. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  66891. * * 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.
  66892. * * 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).
  66893. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  66894. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  66895. * @param name defines the name of the mesh
  66896. * @param url defines the url to the height map
  66897. * @param options defines the options used to create the mesh
  66898. * @param scene defines the hosting scene
  66899. * @returns the ground mesh
  66900. * @see https://doc.babylonjs.com/babylon101/height_map
  66901. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  66902. */
  66903. static CreateGroundFromHeightMap(name: string, url: string, options: {
  66904. width?: number;
  66905. height?: number;
  66906. subdivisions?: number;
  66907. minHeight?: number;
  66908. maxHeight?: number;
  66909. colorFilter?: Color3;
  66910. alphaFilter?: number;
  66911. updatable?: boolean;
  66912. onReady?: (mesh: GroundMesh) => void;
  66913. }, scene?: Nullable<Scene>): GroundMesh;
  66914. /**
  66915. * Creates a polygon mesh
  66916. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  66917. * * 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
  66918. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  66919. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66920. * * 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)
  66921. * * Remember you can only change the shape positions, not their number when updating a polygon
  66922. * @param name defines the name of the mesh
  66923. * @param options defines the options used to create the mesh
  66924. * @param scene defines the hosting scene
  66925. * @param earcutInjection can be used to inject your own earcut reference
  66926. * @returns the polygon mesh
  66927. */
  66928. static CreatePolygon(name: string, options: {
  66929. shape: Vector3[];
  66930. holes?: Vector3[][];
  66931. depth?: number;
  66932. faceUV?: Vector4[];
  66933. faceColors?: Color4[];
  66934. updatable?: boolean;
  66935. sideOrientation?: number;
  66936. frontUVs?: Vector4;
  66937. backUVs?: Vector4;
  66938. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66939. /**
  66940. * Creates an extruded polygon mesh, with depth in the Y direction.
  66941. * * 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)
  66942. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  66943. * @param name defines the name of the mesh
  66944. * @param options defines the options used to create the mesh
  66945. * @param scene defines the hosting scene
  66946. * @param earcutInjection can be used to inject your own earcut reference
  66947. * @returns the polygon mesh
  66948. */
  66949. static ExtrudePolygon(name: string, options: {
  66950. shape: Vector3[];
  66951. holes?: Vector3[][];
  66952. depth?: number;
  66953. faceUV?: Vector4[];
  66954. faceColors?: Color4[];
  66955. updatable?: boolean;
  66956. sideOrientation?: number;
  66957. frontUVs?: Vector4;
  66958. backUVs?: Vector4;
  66959. wrap?: boolean;
  66960. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  66961. /**
  66962. * Creates a tube mesh.
  66963. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  66964. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  66965. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  66966. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  66967. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  66968. * * 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)
  66969. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  66970. * * 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
  66971. * * 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
  66972. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  66973. * * 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
  66974. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  66975. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  66976. * @param name defines the name of the mesh
  66977. * @param options defines the options used to create the mesh
  66978. * @param scene defines the hosting scene
  66979. * @returns the tube mesh
  66980. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  66981. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  66982. */
  66983. static CreateTube(name: string, options: {
  66984. path: Vector3[];
  66985. radius?: number;
  66986. tessellation?: number;
  66987. radiusFunction?: {
  66988. (i: number, distance: number): number;
  66989. };
  66990. cap?: number;
  66991. arc?: number;
  66992. updatable?: boolean;
  66993. sideOrientation?: number;
  66994. frontUVs?: Vector4;
  66995. backUVs?: Vector4;
  66996. instance?: Mesh;
  66997. invertUV?: boolean;
  66998. }, scene?: Nullable<Scene>): Mesh;
  66999. /**
  67000. * Creates a polyhedron mesh
  67001. * * 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
  67002. * * The parameter `size` (positive float, default 1) sets the polygon size
  67003. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  67004. * * 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`
  67005. * * 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
  67006. * * 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)`)
  67007. * * 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
  67008. * * 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
  67009. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  67010. * * 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
  67011. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  67012. * @param name defines the name of the mesh
  67013. * @param options defines the options used to create the mesh
  67014. * @param scene defines the hosting scene
  67015. * @returns the polyhedron mesh
  67016. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  67017. */
  67018. static CreatePolyhedron(name: string, options: {
  67019. type?: number;
  67020. size?: number;
  67021. sizeX?: number;
  67022. sizeY?: number;
  67023. sizeZ?: number;
  67024. custom?: any;
  67025. faceUV?: Vector4[];
  67026. faceColors?: Color4[];
  67027. flat?: boolean;
  67028. updatable?: boolean;
  67029. sideOrientation?: number;
  67030. frontUVs?: Vector4;
  67031. backUVs?: Vector4;
  67032. }, scene?: Nullable<Scene>): Mesh;
  67033. /**
  67034. * Creates a decal mesh.
  67035. * 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
  67036. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  67037. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  67038. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  67039. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  67040. * @param name defines the name of the mesh
  67041. * @param sourceMesh defines the mesh where the decal must be applied
  67042. * @param options defines the options used to create the mesh
  67043. * @param scene defines the hosting scene
  67044. * @returns the decal mesh
  67045. * @see https://doc.babylonjs.com/how_to/decals
  67046. */
  67047. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  67048. position?: Vector3;
  67049. normal?: Vector3;
  67050. size?: Vector3;
  67051. angle?: number;
  67052. }): Mesh;
  67053. /**
  67054. * Creates a Capsule Mesh
  67055. * @param name defines the name of the mesh.
  67056. * @param options the constructors options used to shape the mesh.
  67057. * @param scene defines the scene the mesh is scoped to.
  67058. * @returns the capsule mesh
  67059. * @see https://doc.babylonjs.com/how_to/capsule_shape
  67060. */
  67061. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  67062. }
  67063. }
  67064. declare module BABYLON {
  67065. /**
  67066. * A simplifier interface for future simplification implementations
  67067. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67068. */
  67069. export interface ISimplifier {
  67070. /**
  67071. * Simplification of a given mesh according to the given settings.
  67072. * Since this requires computation, it is assumed that the function runs async.
  67073. * @param settings The settings of the simplification, including quality and distance
  67074. * @param successCallback A callback that will be called after the mesh was simplified.
  67075. * @param errorCallback in case of an error, this callback will be called. optional.
  67076. */
  67077. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  67078. }
  67079. /**
  67080. * Expected simplification settings.
  67081. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  67082. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67083. */
  67084. export interface ISimplificationSettings {
  67085. /**
  67086. * Gets or sets the expected quality
  67087. */
  67088. quality: number;
  67089. /**
  67090. * Gets or sets the distance when this optimized version should be used
  67091. */
  67092. distance: number;
  67093. /**
  67094. * Gets an already optimized mesh
  67095. */
  67096. optimizeMesh?: boolean;
  67097. }
  67098. /**
  67099. * Class used to specify simplification options
  67100. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67101. */
  67102. export class SimplificationSettings implements ISimplificationSettings {
  67103. /** expected quality */
  67104. quality: number;
  67105. /** distance when this optimized version should be used */
  67106. distance: number;
  67107. /** already optimized mesh */
  67108. optimizeMesh?: boolean | undefined;
  67109. /**
  67110. * Creates a SimplificationSettings
  67111. * @param quality expected quality
  67112. * @param distance distance when this optimized version should be used
  67113. * @param optimizeMesh already optimized mesh
  67114. */
  67115. constructor(
  67116. /** expected quality */
  67117. quality: number,
  67118. /** distance when this optimized version should be used */
  67119. distance: number,
  67120. /** already optimized mesh */
  67121. optimizeMesh?: boolean | undefined);
  67122. }
  67123. /**
  67124. * Interface used to define a simplification task
  67125. */
  67126. export interface ISimplificationTask {
  67127. /**
  67128. * Array of settings
  67129. */
  67130. settings: Array<ISimplificationSettings>;
  67131. /**
  67132. * Simplification type
  67133. */
  67134. simplificationType: SimplificationType;
  67135. /**
  67136. * Mesh to simplify
  67137. */
  67138. mesh: Mesh;
  67139. /**
  67140. * Callback called on success
  67141. */
  67142. successCallback?: () => void;
  67143. /**
  67144. * Defines if parallel processing can be used
  67145. */
  67146. parallelProcessing: boolean;
  67147. }
  67148. /**
  67149. * Queue used to order the simplification tasks
  67150. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67151. */
  67152. export class SimplificationQueue {
  67153. private _simplificationArray;
  67154. /**
  67155. * Gets a boolean indicating that the process is still running
  67156. */
  67157. running: boolean;
  67158. /**
  67159. * Creates a new queue
  67160. */
  67161. constructor();
  67162. /**
  67163. * Adds a new simplification task
  67164. * @param task defines a task to add
  67165. */
  67166. addTask(task: ISimplificationTask): void;
  67167. /**
  67168. * Execute next task
  67169. */
  67170. executeNext(): void;
  67171. /**
  67172. * Execute a simplification task
  67173. * @param task defines the task to run
  67174. */
  67175. runSimplification(task: ISimplificationTask): void;
  67176. private getSimplifier;
  67177. }
  67178. /**
  67179. * The implemented types of simplification
  67180. * At the moment only Quadratic Error Decimation is implemented
  67181. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67182. */
  67183. export enum SimplificationType {
  67184. /** Quadratic error decimation */
  67185. QUADRATIC = 0
  67186. }
  67187. /**
  67188. * An implementation of the Quadratic Error simplification algorithm.
  67189. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  67190. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  67191. * @author RaananW
  67192. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67193. */
  67194. export class QuadraticErrorSimplification implements ISimplifier {
  67195. private _mesh;
  67196. private triangles;
  67197. private vertices;
  67198. private references;
  67199. private _reconstructedMesh;
  67200. /** Gets or sets the number pf sync interations */
  67201. syncIterations: number;
  67202. /** Gets or sets the aggressiveness of the simplifier */
  67203. aggressiveness: number;
  67204. /** Gets or sets the number of allowed iterations for decimation */
  67205. decimationIterations: number;
  67206. /** Gets or sets the espilon to use for bounding box computation */
  67207. boundingBoxEpsilon: number;
  67208. /**
  67209. * Creates a new QuadraticErrorSimplification
  67210. * @param _mesh defines the target mesh
  67211. */
  67212. constructor(_mesh: Mesh);
  67213. /**
  67214. * Simplification of a given mesh according to the given settings.
  67215. * Since this requires computation, it is assumed that the function runs async.
  67216. * @param settings The settings of the simplification, including quality and distance
  67217. * @param successCallback A callback that will be called after the mesh was simplified.
  67218. */
  67219. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  67220. private runDecimation;
  67221. private initWithMesh;
  67222. private init;
  67223. private reconstructMesh;
  67224. private initDecimatedMesh;
  67225. private isFlipped;
  67226. private updateTriangles;
  67227. private identifyBorder;
  67228. private updateMesh;
  67229. private vertexError;
  67230. private calculateError;
  67231. }
  67232. }
  67233. declare module BABYLON {
  67234. interface Scene {
  67235. /** @hidden (Backing field) */
  67236. _simplificationQueue: SimplificationQueue;
  67237. /**
  67238. * Gets or sets the simplification queue attached to the scene
  67239. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  67240. */
  67241. simplificationQueue: SimplificationQueue;
  67242. }
  67243. interface Mesh {
  67244. /**
  67245. * Simplify the mesh according to the given array of settings.
  67246. * Function will return immediately and will simplify async
  67247. * @param settings a collection of simplification settings
  67248. * @param parallelProcessing should all levels calculate parallel or one after the other
  67249. * @param simplificationType the type of simplification to run
  67250. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  67251. * @returns the current mesh
  67252. */
  67253. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  67254. }
  67255. /**
  67256. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  67257. * created in a scene
  67258. */
  67259. export class SimplicationQueueSceneComponent implements ISceneComponent {
  67260. /**
  67261. * The component name helpfull to identify the component in the list of scene components.
  67262. */
  67263. readonly name: string;
  67264. /**
  67265. * The scene the component belongs to.
  67266. */
  67267. scene: Scene;
  67268. /**
  67269. * Creates a new instance of the component for the given scene
  67270. * @param scene Defines the scene to register the component in
  67271. */
  67272. constructor(scene: Scene);
  67273. /**
  67274. * Registers the component in a given scene
  67275. */
  67276. register(): void;
  67277. /**
  67278. * Rebuilds the elements related to this component in case of
  67279. * context lost for instance.
  67280. */
  67281. rebuild(): void;
  67282. /**
  67283. * Disposes the component and the associated ressources
  67284. */
  67285. dispose(): void;
  67286. private _beforeCameraUpdate;
  67287. }
  67288. }
  67289. declare module BABYLON {
  67290. interface Mesh {
  67291. /**
  67292. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  67293. */
  67294. thinInstanceEnablePicking: boolean;
  67295. /**
  67296. * Creates a new thin instance
  67297. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  67298. * @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
  67299. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  67300. */
  67301. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  67302. /**
  67303. * Adds the transformation (matrix) of the current mesh as a thin instance
  67304. * @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
  67305. * @returns the thin instance index number
  67306. */
  67307. thinInstanceAddSelf(refresh: boolean): number;
  67308. /**
  67309. * Registers a custom attribute to be used with thin instances
  67310. * @param kind name of the attribute
  67311. * @param stride size in floats of the attribute
  67312. */
  67313. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  67314. /**
  67315. * Sets the matrix of a thin instance
  67316. * @param index index of the thin instance
  67317. * @param matrix matrix to set
  67318. * @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
  67319. */
  67320. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  67321. /**
  67322. * Sets the value of a custom attribute for a thin instance
  67323. * @param kind name of the attribute
  67324. * @param index index of the thin instance
  67325. * @param value value to set
  67326. * @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
  67327. */
  67328. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  67329. /**
  67330. * 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.
  67331. */
  67332. thinInstanceCount: number;
  67333. /**
  67334. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  67335. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  67336. * @param buffer buffer to set
  67337. * @param stride size in floats of each value of the buffer
  67338. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  67339. */
  67340. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  67341. /**
  67342. * Gets the list of world matrices
  67343. * @return an array containing all the world matrices from the thin instances
  67344. */
  67345. thinInstanceGetWorldMatrices(): Matrix[];
  67346. /**
  67347. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  67348. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  67349. */
  67350. thinInstanceBufferUpdated(kind: string): void;
  67351. /**
  67352. * Applies a partial update to a buffer directly on the GPU
  67353. * Note that the buffer located on the CPU is NOT updated! It's up to you to update it (or not) with the same data you pass to this method
  67354. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  67355. * @param data the data to set in the GPU buffer
  67356. * @param offset the offset in the GPU buffer where to update the data
  67357. */
  67358. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  67359. /**
  67360. * Refreshes the bounding info, taking into account all the thin instances defined
  67361. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  67362. */
  67363. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  67364. /** @hidden */
  67365. _thinInstanceInitializeUserStorage(): void;
  67366. /** @hidden */
  67367. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  67368. /** @hidden */
  67369. _userThinInstanceBuffersStorage: {
  67370. data: {
  67371. [key: string]: Float32Array;
  67372. };
  67373. sizes: {
  67374. [key: string]: number;
  67375. };
  67376. vertexBuffers: {
  67377. [key: string]: Nullable<VertexBuffer>;
  67378. };
  67379. strides: {
  67380. [key: string]: number;
  67381. };
  67382. };
  67383. }
  67384. }
  67385. declare module BABYLON {
  67386. /**
  67387. * Navigation plugin interface to add navigation constrained by a navigation mesh
  67388. */
  67389. export interface INavigationEnginePlugin {
  67390. /**
  67391. * plugin name
  67392. */
  67393. name: string;
  67394. /**
  67395. * Creates a navigation mesh
  67396. * @param meshes array of all the geometry used to compute the navigatio mesh
  67397. * @param parameters bunch of parameters used to filter geometry
  67398. */
  67399. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  67400. /**
  67401. * Create a navigation mesh debug mesh
  67402. * @param scene is where the mesh will be added
  67403. * @returns debug display mesh
  67404. */
  67405. createDebugNavMesh(scene: Scene): Mesh;
  67406. /**
  67407. * Get a navigation mesh constrained position, closest to the parameter position
  67408. * @param position world position
  67409. * @returns the closest point to position constrained by the navigation mesh
  67410. */
  67411. getClosestPoint(position: Vector3): Vector3;
  67412. /**
  67413. * Get a navigation mesh constrained position, closest to the parameter position
  67414. * @param position world position
  67415. * @param result output the closest point to position constrained by the navigation mesh
  67416. */
  67417. getClosestPointToRef(position: Vector3, result: Vector3): void;
  67418. /**
  67419. * Get a navigation mesh constrained position, within a particular radius
  67420. * @param position world position
  67421. * @param maxRadius the maximum distance to the constrained world position
  67422. * @returns the closest point to position constrained by the navigation mesh
  67423. */
  67424. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  67425. /**
  67426. * Get a navigation mesh constrained position, within a particular radius
  67427. * @param position world position
  67428. * @param maxRadius the maximum distance to the constrained world position
  67429. * @param result output the closest point to position constrained by the navigation mesh
  67430. */
  67431. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  67432. /**
  67433. * Compute the final position from a segment made of destination-position
  67434. * @param position world position
  67435. * @param destination world position
  67436. * @returns the resulting point along the navmesh
  67437. */
  67438. moveAlong(position: Vector3, destination: Vector3): Vector3;
  67439. /**
  67440. * Compute the final position from a segment made of destination-position
  67441. * @param position world position
  67442. * @param destination world position
  67443. * @param result output the resulting point along the navmesh
  67444. */
  67445. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  67446. /**
  67447. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  67448. * @param start world position
  67449. * @param end world position
  67450. * @returns array containing world position composing the path
  67451. */
  67452. computePath(start: Vector3, end: Vector3): Vector3[];
  67453. /**
  67454. * If this plugin is supported
  67455. * @returns true if plugin is supported
  67456. */
  67457. isSupported(): boolean;
  67458. /**
  67459. * Create a new Crowd so you can add agents
  67460. * @param maxAgents the maximum agent count in the crowd
  67461. * @param maxAgentRadius the maximum radius an agent can have
  67462. * @param scene to attach the crowd to
  67463. * @returns the crowd you can add agents to
  67464. */
  67465. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  67466. /**
  67467. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  67468. * The queries will try to find a solution within those bounds
  67469. * default is (1,1,1)
  67470. * @param extent x,y,z value that define the extent around the queries point of reference
  67471. */
  67472. setDefaultQueryExtent(extent: Vector3): void;
  67473. /**
  67474. * Get the Bounding box extent specified by setDefaultQueryExtent
  67475. * @returns the box extent values
  67476. */
  67477. getDefaultQueryExtent(): Vector3;
  67478. /**
  67479. * build the navmesh from a previously saved state using getNavmeshData
  67480. * @param data the Uint8Array returned by getNavmeshData
  67481. */
  67482. buildFromNavmeshData(data: Uint8Array): void;
  67483. /**
  67484. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  67485. * @returns data the Uint8Array that can be saved and reused
  67486. */
  67487. getNavmeshData(): Uint8Array;
  67488. /**
  67489. * Get the Bounding box extent result specified by setDefaultQueryExtent
  67490. * @param result output the box extent values
  67491. */
  67492. getDefaultQueryExtentToRef(result: Vector3): void;
  67493. /**
  67494. * Release all resources
  67495. */
  67496. dispose(): void;
  67497. }
  67498. /**
  67499. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  67500. */
  67501. export interface ICrowd {
  67502. /**
  67503. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  67504. * You can attach anything to that node. The node position is updated in the scene update tick.
  67505. * @param pos world position that will be constrained by the navigation mesh
  67506. * @param parameters agent parameters
  67507. * @param transform hooked to the agent that will be update by the scene
  67508. * @returns agent index
  67509. */
  67510. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  67511. /**
  67512. * Returns the agent position in world space
  67513. * @param index agent index returned by addAgent
  67514. * @returns world space position
  67515. */
  67516. getAgentPosition(index: number): Vector3;
  67517. /**
  67518. * Gets the agent position result in world space
  67519. * @param index agent index returned by addAgent
  67520. * @param result output world space position
  67521. */
  67522. getAgentPositionToRef(index: number, result: Vector3): void;
  67523. /**
  67524. * Gets the agent velocity in world space
  67525. * @param index agent index returned by addAgent
  67526. * @returns world space velocity
  67527. */
  67528. getAgentVelocity(index: number): Vector3;
  67529. /**
  67530. * Gets the agent velocity result in world space
  67531. * @param index agent index returned by addAgent
  67532. * @param result output world space velocity
  67533. */
  67534. getAgentVelocityToRef(index: number, result: Vector3): void;
  67535. /**
  67536. * remove a particular agent previously created
  67537. * @param index agent index returned by addAgent
  67538. */
  67539. removeAgent(index: number): void;
  67540. /**
  67541. * get the list of all agents attached to this crowd
  67542. * @returns list of agent indices
  67543. */
  67544. getAgents(): number[];
  67545. /**
  67546. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  67547. * @param deltaTime in seconds
  67548. */
  67549. update(deltaTime: number): void;
  67550. /**
  67551. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  67552. * @param index agent index returned by addAgent
  67553. * @param destination targeted world position
  67554. */
  67555. agentGoto(index: number, destination: Vector3): void;
  67556. /**
  67557. * Teleport the agent to a new position
  67558. * @param index agent index returned by addAgent
  67559. * @param destination targeted world position
  67560. */
  67561. agentTeleport(index: number, destination: Vector3): void;
  67562. /**
  67563. * Update agent parameters
  67564. * @param index agent index returned by addAgent
  67565. * @param parameters agent parameters
  67566. */
  67567. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  67568. /**
  67569. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  67570. * The queries will try to find a solution within those bounds
  67571. * default is (1,1,1)
  67572. * @param extent x,y,z value that define the extent around the queries point of reference
  67573. */
  67574. setDefaultQueryExtent(extent: Vector3): void;
  67575. /**
  67576. * Get the Bounding box extent specified by setDefaultQueryExtent
  67577. * @returns the box extent values
  67578. */
  67579. getDefaultQueryExtent(): Vector3;
  67580. /**
  67581. * Get the Bounding box extent result specified by setDefaultQueryExtent
  67582. * @param result output the box extent values
  67583. */
  67584. getDefaultQueryExtentToRef(result: Vector3): void;
  67585. /**
  67586. * Release all resources
  67587. */
  67588. dispose(): void;
  67589. }
  67590. /**
  67591. * Configures an agent
  67592. */
  67593. export interface IAgentParameters {
  67594. /**
  67595. * Agent radius. [Limit: >= 0]
  67596. */
  67597. radius: number;
  67598. /**
  67599. * Agent height. [Limit: > 0]
  67600. */
  67601. height: number;
  67602. /**
  67603. * Maximum allowed acceleration. [Limit: >= 0]
  67604. */
  67605. maxAcceleration: number;
  67606. /**
  67607. * Maximum allowed speed. [Limit: >= 0]
  67608. */
  67609. maxSpeed: number;
  67610. /**
  67611. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  67612. */
  67613. collisionQueryRange: number;
  67614. /**
  67615. * The path visibility optimization range. [Limit: > 0]
  67616. */
  67617. pathOptimizationRange: number;
  67618. /**
  67619. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  67620. */
  67621. separationWeight: number;
  67622. }
  67623. /**
  67624. * Configures the navigation mesh creation
  67625. */
  67626. export interface INavMeshParameters {
  67627. /**
  67628. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  67629. */
  67630. cs: number;
  67631. /**
  67632. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  67633. */
  67634. ch: number;
  67635. /**
  67636. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  67637. */
  67638. walkableSlopeAngle: number;
  67639. /**
  67640. * Minimum floor to 'ceiling' height that will still allow the floor area to
  67641. * be considered walkable. [Limit: >= 3] [Units: vx]
  67642. */
  67643. walkableHeight: number;
  67644. /**
  67645. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  67646. */
  67647. walkableClimb: number;
  67648. /**
  67649. * The distance to erode/shrink the walkable area of the heightfield away from
  67650. * obstructions. [Limit: >=0] [Units: vx]
  67651. */
  67652. walkableRadius: number;
  67653. /**
  67654. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  67655. */
  67656. maxEdgeLen: number;
  67657. /**
  67658. * The maximum distance a simplfied contour's border edges should deviate
  67659. * the original raw contour. [Limit: >=0] [Units: vx]
  67660. */
  67661. maxSimplificationError: number;
  67662. /**
  67663. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  67664. */
  67665. minRegionArea: number;
  67666. /**
  67667. * Any regions with a span count smaller than this value will, if possible,
  67668. * be merged with larger regions. [Limit: >=0] [Units: vx]
  67669. */
  67670. mergeRegionArea: number;
  67671. /**
  67672. * The maximum number of vertices allowed for polygons generated during the
  67673. * contour to polygon conversion process. [Limit: >= 3]
  67674. */
  67675. maxVertsPerPoly: number;
  67676. /**
  67677. * Sets the sampling distance to use when generating the detail mesh.
  67678. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  67679. */
  67680. detailSampleDist: number;
  67681. /**
  67682. * The maximum distance the detail mesh surface should deviate from heightfield
  67683. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  67684. */
  67685. detailSampleMaxError: number;
  67686. }
  67687. }
  67688. declare module BABYLON {
  67689. /**
  67690. * RecastJS navigation plugin
  67691. */
  67692. export class RecastJSPlugin implements INavigationEnginePlugin {
  67693. /**
  67694. * Reference to the Recast library
  67695. */
  67696. bjsRECAST: any;
  67697. /**
  67698. * plugin name
  67699. */
  67700. name: string;
  67701. /**
  67702. * the first navmesh created. We might extend this to support multiple navmeshes
  67703. */
  67704. navMesh: any;
  67705. /**
  67706. * Initializes the recastJS plugin
  67707. * @param recastInjection can be used to inject your own recast reference
  67708. */
  67709. constructor(recastInjection?: any);
  67710. /**
  67711. * Creates a navigation mesh
  67712. * @param meshes array of all the geometry used to compute the navigatio mesh
  67713. * @param parameters bunch of parameters used to filter geometry
  67714. */
  67715. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  67716. /**
  67717. * Create a navigation mesh debug mesh
  67718. * @param scene is where the mesh will be added
  67719. * @returns debug display mesh
  67720. */
  67721. createDebugNavMesh(scene: Scene): Mesh;
  67722. /**
  67723. * Get a navigation mesh constrained position, closest to the parameter position
  67724. * @param position world position
  67725. * @returns the closest point to position constrained by the navigation mesh
  67726. */
  67727. getClosestPoint(position: Vector3): Vector3;
  67728. /**
  67729. * Get a navigation mesh constrained position, closest to the parameter position
  67730. * @param position world position
  67731. * @param result output the closest point to position constrained by the navigation mesh
  67732. */
  67733. getClosestPointToRef(position: Vector3, result: Vector3): void;
  67734. /**
  67735. * Get a navigation mesh constrained position, within a particular radius
  67736. * @param position world position
  67737. * @param maxRadius the maximum distance to the constrained world position
  67738. * @returns the closest point to position constrained by the navigation mesh
  67739. */
  67740. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  67741. /**
  67742. * Get a navigation mesh constrained position, within a particular radius
  67743. * @param position world position
  67744. * @param maxRadius the maximum distance to the constrained world position
  67745. * @param result output the closest point to position constrained by the navigation mesh
  67746. */
  67747. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  67748. /**
  67749. * Compute the final position from a segment made of destination-position
  67750. * @param position world position
  67751. * @param destination world position
  67752. * @returns the resulting point along the navmesh
  67753. */
  67754. moveAlong(position: Vector3, destination: Vector3): Vector3;
  67755. /**
  67756. * Compute the final position from a segment made of destination-position
  67757. * @param position world position
  67758. * @param destination world position
  67759. * @param result output the resulting point along the navmesh
  67760. */
  67761. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  67762. /**
  67763. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  67764. * @param start world position
  67765. * @param end world position
  67766. * @returns array containing world position composing the path
  67767. */
  67768. computePath(start: Vector3, end: Vector3): Vector3[];
  67769. /**
  67770. * Create a new Crowd so you can add agents
  67771. * @param maxAgents the maximum agent count in the crowd
  67772. * @param maxAgentRadius the maximum radius an agent can have
  67773. * @param scene to attach the crowd to
  67774. * @returns the crowd you can add agents to
  67775. */
  67776. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  67777. /**
  67778. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  67779. * The queries will try to find a solution within those bounds
  67780. * default is (1,1,1)
  67781. * @param extent x,y,z value that define the extent around the queries point of reference
  67782. */
  67783. setDefaultQueryExtent(extent: Vector3): void;
  67784. /**
  67785. * Get the Bounding box extent specified by setDefaultQueryExtent
  67786. * @returns the box extent values
  67787. */
  67788. getDefaultQueryExtent(): Vector3;
  67789. /**
  67790. * build the navmesh from a previously saved state using getNavmeshData
  67791. * @param data the Uint8Array returned by getNavmeshData
  67792. */
  67793. buildFromNavmeshData(data: Uint8Array): void;
  67794. /**
  67795. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  67796. * @returns data the Uint8Array that can be saved and reused
  67797. */
  67798. getNavmeshData(): Uint8Array;
  67799. /**
  67800. * Get the Bounding box extent result specified by setDefaultQueryExtent
  67801. * @param result output the box extent values
  67802. */
  67803. getDefaultQueryExtentToRef(result: Vector3): void;
  67804. /**
  67805. * Disposes
  67806. */
  67807. dispose(): void;
  67808. /**
  67809. * If this plugin is supported
  67810. * @returns true if plugin is supported
  67811. */
  67812. isSupported(): boolean;
  67813. }
  67814. /**
  67815. * Recast detour crowd implementation
  67816. */
  67817. export class RecastJSCrowd implements ICrowd {
  67818. /**
  67819. * Recast/detour plugin
  67820. */
  67821. bjsRECASTPlugin: RecastJSPlugin;
  67822. /**
  67823. * Link to the detour crowd
  67824. */
  67825. recastCrowd: any;
  67826. /**
  67827. * One transform per agent
  67828. */
  67829. transforms: TransformNode[];
  67830. /**
  67831. * All agents created
  67832. */
  67833. agents: number[];
  67834. /**
  67835. * Link to the scene is kept to unregister the crowd from the scene
  67836. */
  67837. private _scene;
  67838. /**
  67839. * Observer for crowd updates
  67840. */
  67841. private _onBeforeAnimationsObserver;
  67842. /**
  67843. * Constructor
  67844. * @param plugin recastJS plugin
  67845. * @param maxAgents the maximum agent count in the crowd
  67846. * @param maxAgentRadius the maximum radius an agent can have
  67847. * @param scene to attach the crowd to
  67848. * @returns the crowd you can add agents to
  67849. */
  67850. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  67851. /**
  67852. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  67853. * You can attach anything to that node. The node position is updated in the scene update tick.
  67854. * @param pos world position that will be constrained by the navigation mesh
  67855. * @param parameters agent parameters
  67856. * @param transform hooked to the agent that will be update by the scene
  67857. * @returns agent index
  67858. */
  67859. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  67860. /**
  67861. * Returns the agent position in world space
  67862. * @param index agent index returned by addAgent
  67863. * @returns world space position
  67864. */
  67865. getAgentPosition(index: number): Vector3;
  67866. /**
  67867. * Returns the agent position result in world space
  67868. * @param index agent index returned by addAgent
  67869. * @param result output world space position
  67870. */
  67871. getAgentPositionToRef(index: number, result: Vector3): void;
  67872. /**
  67873. * Returns the agent velocity in world space
  67874. * @param index agent index returned by addAgent
  67875. * @returns world space velocity
  67876. */
  67877. getAgentVelocity(index: number): Vector3;
  67878. /**
  67879. * Returns the agent velocity result in world space
  67880. * @param index agent index returned by addAgent
  67881. * @param result output world space velocity
  67882. */
  67883. getAgentVelocityToRef(index: number, result: Vector3): void;
  67884. /**
  67885. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  67886. * @param index agent index returned by addAgent
  67887. * @param destination targeted world position
  67888. */
  67889. agentGoto(index: number, destination: Vector3): void;
  67890. /**
  67891. * Teleport the agent to a new position
  67892. * @param index agent index returned by addAgent
  67893. * @param destination targeted world position
  67894. */
  67895. agentTeleport(index: number, destination: Vector3): void;
  67896. /**
  67897. * Update agent parameters
  67898. * @param index agent index returned by addAgent
  67899. * @param parameters agent parameters
  67900. */
  67901. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  67902. /**
  67903. * remove a particular agent previously created
  67904. * @param index agent index returned by addAgent
  67905. */
  67906. removeAgent(index: number): void;
  67907. /**
  67908. * get the list of all agents attached to this crowd
  67909. * @returns list of agent indices
  67910. */
  67911. getAgents(): number[];
  67912. /**
  67913. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  67914. * @param deltaTime in seconds
  67915. */
  67916. update(deltaTime: number): void;
  67917. /**
  67918. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  67919. * The queries will try to find a solution within those bounds
  67920. * default is (1,1,1)
  67921. * @param extent x,y,z value that define the extent around the queries point of reference
  67922. */
  67923. setDefaultQueryExtent(extent: Vector3): void;
  67924. /**
  67925. * Get the Bounding box extent specified by setDefaultQueryExtent
  67926. * @returns the box extent values
  67927. */
  67928. getDefaultQueryExtent(): Vector3;
  67929. /**
  67930. * Get the Bounding box extent result specified by setDefaultQueryExtent
  67931. * @param result output the box extent values
  67932. */
  67933. getDefaultQueryExtentToRef(result: Vector3): void;
  67934. /**
  67935. * Release all resources
  67936. */
  67937. dispose(): void;
  67938. }
  67939. }
  67940. declare module BABYLON {
  67941. /**
  67942. * Class used to enable access to IndexedDB
  67943. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  67944. */
  67945. export class Database implements IOfflineProvider {
  67946. private _callbackManifestChecked;
  67947. private _currentSceneUrl;
  67948. private _db;
  67949. private _enableSceneOffline;
  67950. private _enableTexturesOffline;
  67951. private _manifestVersionFound;
  67952. private _mustUpdateRessources;
  67953. private _hasReachedQuota;
  67954. private _isSupported;
  67955. private _idbFactory;
  67956. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  67957. private static IsUASupportingBlobStorage;
  67958. /**
  67959. * Gets a boolean indicating if Database storate is enabled (off by default)
  67960. */
  67961. static IDBStorageEnabled: boolean;
  67962. /**
  67963. * Gets a boolean indicating if scene must be saved in the database
  67964. */
  67965. get enableSceneOffline(): boolean;
  67966. /**
  67967. * Gets a boolean indicating if textures must be saved in the database
  67968. */
  67969. get enableTexturesOffline(): boolean;
  67970. /**
  67971. * Creates a new Database
  67972. * @param urlToScene defines the url to load the scene
  67973. * @param callbackManifestChecked defines the callback to use when manifest is checked
  67974. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  67975. */
  67976. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  67977. private static _ParseURL;
  67978. private static _ReturnFullUrlLocation;
  67979. private _checkManifestFile;
  67980. /**
  67981. * Open the database and make it available
  67982. * @param successCallback defines the callback to call on success
  67983. * @param errorCallback defines the callback to call on error
  67984. */
  67985. open(successCallback: () => void, errorCallback: () => void): void;
  67986. /**
  67987. * Loads an image from the database
  67988. * @param url defines the url to load from
  67989. * @param image defines the target DOM image
  67990. */
  67991. loadImage(url: string, image: HTMLImageElement): void;
  67992. private _loadImageFromDBAsync;
  67993. private _saveImageIntoDBAsync;
  67994. private _checkVersionFromDB;
  67995. private _loadVersionFromDBAsync;
  67996. private _saveVersionIntoDBAsync;
  67997. /**
  67998. * Loads a file from database
  67999. * @param url defines the URL to load from
  68000. * @param sceneLoaded defines a callback to call on success
  68001. * @param progressCallBack defines a callback to call when progress changed
  68002. * @param errorCallback defines a callback to call on error
  68003. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  68004. */
  68005. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  68006. private _loadFileAsync;
  68007. private _saveFileAsync;
  68008. /**
  68009. * Validates if xhr data is correct
  68010. * @param xhr defines the request to validate
  68011. * @param dataType defines the expected data type
  68012. * @returns true if data is correct
  68013. */
  68014. private static _ValidateXHRData;
  68015. }
  68016. }
  68017. declare module BABYLON {
  68018. /** @hidden */
  68019. export var gpuUpdateParticlesPixelShader: {
  68020. name: string;
  68021. shader: string;
  68022. };
  68023. }
  68024. declare module BABYLON {
  68025. /** @hidden */
  68026. export var gpuUpdateParticlesVertexShader: {
  68027. name: string;
  68028. shader: string;
  68029. };
  68030. }
  68031. declare module BABYLON {
  68032. /** @hidden */
  68033. export var clipPlaneFragmentDeclaration2: {
  68034. name: string;
  68035. shader: string;
  68036. };
  68037. }
  68038. declare module BABYLON {
  68039. /** @hidden */
  68040. export var gpuRenderParticlesPixelShader: {
  68041. name: string;
  68042. shader: string;
  68043. };
  68044. }
  68045. declare module BABYLON {
  68046. /** @hidden */
  68047. export var clipPlaneVertexDeclaration2: {
  68048. name: string;
  68049. shader: string;
  68050. };
  68051. }
  68052. declare module BABYLON {
  68053. /** @hidden */
  68054. export var gpuRenderParticlesVertexShader: {
  68055. name: string;
  68056. shader: string;
  68057. };
  68058. }
  68059. declare module BABYLON {
  68060. /**
  68061. * This represents a GPU particle system in Babylon
  68062. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  68063. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  68064. */
  68065. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  68066. /**
  68067. * The layer mask we are rendering the particles through.
  68068. */
  68069. layerMask: number;
  68070. private _capacity;
  68071. private _activeCount;
  68072. private _currentActiveCount;
  68073. private _accumulatedCount;
  68074. private _renderEffect;
  68075. private _updateEffect;
  68076. private _buffer0;
  68077. private _buffer1;
  68078. private _spriteBuffer;
  68079. private _updateVAO;
  68080. private _renderVAO;
  68081. private _targetIndex;
  68082. private _sourceBuffer;
  68083. private _targetBuffer;
  68084. private _currentRenderId;
  68085. private _started;
  68086. private _stopped;
  68087. private _timeDelta;
  68088. private _randomTexture;
  68089. private _randomTexture2;
  68090. private _attributesStrideSize;
  68091. private _updateEffectOptions;
  68092. private _randomTextureSize;
  68093. private _actualFrame;
  68094. private _customEffect;
  68095. private readonly _rawTextureWidth;
  68096. /**
  68097. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  68098. */
  68099. static get IsSupported(): boolean;
  68100. /**
  68101. * An event triggered when the system is disposed.
  68102. */
  68103. onDisposeObservable: Observable<IParticleSystem>;
  68104. /**
  68105. * An event triggered when the system is stopped
  68106. */
  68107. onStoppedObservable: Observable<IParticleSystem>;
  68108. /**
  68109. * Gets the maximum number of particles active at the same time.
  68110. * @returns The max number of active particles.
  68111. */
  68112. getCapacity(): number;
  68113. /**
  68114. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  68115. * to override the particles.
  68116. */
  68117. forceDepthWrite: boolean;
  68118. /**
  68119. * Gets or set the number of active particles
  68120. */
  68121. get activeParticleCount(): number;
  68122. set activeParticleCount(value: number);
  68123. private _preWarmDone;
  68124. /**
  68125. * Specifies if the particles are updated in emitter local space or world space.
  68126. */
  68127. isLocal: boolean;
  68128. /** Gets or sets a matrix to use to compute projection */
  68129. defaultProjectionMatrix: Matrix;
  68130. /**
  68131. * Is this system ready to be used/rendered
  68132. * @return true if the system is ready
  68133. */
  68134. isReady(): boolean;
  68135. /**
  68136. * Gets if the system has been started. (Note: this will still be true after stop is called)
  68137. * @returns True if it has been started, otherwise false.
  68138. */
  68139. isStarted(): boolean;
  68140. /**
  68141. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  68142. * @returns True if it has been stopped, otherwise false.
  68143. */
  68144. isStopped(): boolean;
  68145. /**
  68146. * Gets a boolean indicating that the system is stopping
  68147. * @returns true if the system is currently stopping
  68148. */
  68149. isStopping(): boolean;
  68150. /**
  68151. * Gets the number of particles active at the same time.
  68152. * @returns The number of active particles.
  68153. */
  68154. getActiveCount(): number;
  68155. /**
  68156. * Starts the particle system and begins to emit
  68157. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  68158. */
  68159. start(delay?: number): void;
  68160. /**
  68161. * Stops the particle system.
  68162. */
  68163. stop(): void;
  68164. /**
  68165. * Remove all active particles
  68166. */
  68167. reset(): void;
  68168. /**
  68169. * Returns the string "GPUParticleSystem"
  68170. * @returns a string containing the class name
  68171. */
  68172. getClassName(): string;
  68173. /**
  68174. * Gets the custom effect used to render the particles
  68175. * @param blendMode Blend mode for which the effect should be retrieved
  68176. * @returns The effect
  68177. */
  68178. getCustomEffect(blendMode?: number): Nullable<Effect>;
  68179. /**
  68180. * Sets the custom effect used to render the particles
  68181. * @param effect The effect to set
  68182. * @param blendMode Blend mode for which the effect should be set
  68183. */
  68184. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  68185. /** @hidden */
  68186. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  68187. /**
  68188. * Observable that will be called just before the particles are drawn
  68189. */
  68190. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  68191. /**
  68192. * Gets the name of the particle vertex shader
  68193. */
  68194. get vertexShaderName(): string;
  68195. private _colorGradientsTexture;
  68196. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  68197. /**
  68198. * Adds a new color gradient
  68199. * @param gradient defines the gradient to use (between 0 and 1)
  68200. * @param color1 defines the color to affect to the specified gradient
  68201. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  68202. * @returns the current particle system
  68203. */
  68204. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  68205. private _refreshColorGradient;
  68206. /** Force the system to rebuild all gradients that need to be resync */
  68207. forceRefreshGradients(): void;
  68208. /**
  68209. * Remove a specific color gradient
  68210. * @param gradient defines the gradient to remove
  68211. * @returns the current particle system
  68212. */
  68213. removeColorGradient(gradient: number): GPUParticleSystem;
  68214. private _angularSpeedGradientsTexture;
  68215. private _sizeGradientsTexture;
  68216. private _velocityGradientsTexture;
  68217. private _limitVelocityGradientsTexture;
  68218. private _dragGradientsTexture;
  68219. private _addFactorGradient;
  68220. /**
  68221. * Adds a new size gradient
  68222. * @param gradient defines the gradient to use (between 0 and 1)
  68223. * @param factor defines the size factor to affect to the specified gradient
  68224. * @returns the current particle system
  68225. */
  68226. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  68227. /**
  68228. * Remove a specific size gradient
  68229. * @param gradient defines the gradient to remove
  68230. * @returns the current particle system
  68231. */
  68232. removeSizeGradient(gradient: number): GPUParticleSystem;
  68233. private _refreshFactorGradient;
  68234. /**
  68235. * Adds a new angular speed gradient
  68236. * @param gradient defines the gradient to use (between 0 and 1)
  68237. * @param factor defines the angular speed to affect to the specified gradient
  68238. * @returns the current particle system
  68239. */
  68240. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  68241. /**
  68242. * Remove a specific angular speed gradient
  68243. * @param gradient defines the gradient to remove
  68244. * @returns the current particle system
  68245. */
  68246. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  68247. /**
  68248. * Adds a new velocity gradient
  68249. * @param gradient defines the gradient to use (between 0 and 1)
  68250. * @param factor defines the velocity to affect to the specified gradient
  68251. * @returns the current particle system
  68252. */
  68253. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  68254. /**
  68255. * Remove a specific velocity gradient
  68256. * @param gradient defines the gradient to remove
  68257. * @returns the current particle system
  68258. */
  68259. removeVelocityGradient(gradient: number): GPUParticleSystem;
  68260. /**
  68261. * Adds a new limit velocity gradient
  68262. * @param gradient defines the gradient to use (between 0 and 1)
  68263. * @param factor defines the limit velocity value to affect to the specified gradient
  68264. * @returns the current particle system
  68265. */
  68266. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  68267. /**
  68268. * Remove a specific limit velocity gradient
  68269. * @param gradient defines the gradient to remove
  68270. * @returns the current particle system
  68271. */
  68272. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  68273. /**
  68274. * Adds a new drag gradient
  68275. * @param gradient defines the gradient to use (between 0 and 1)
  68276. * @param factor defines the drag value to affect to the specified gradient
  68277. * @returns the current particle system
  68278. */
  68279. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  68280. /**
  68281. * Remove a specific drag gradient
  68282. * @param gradient defines the gradient to remove
  68283. * @returns the current particle system
  68284. */
  68285. removeDragGradient(gradient: number): GPUParticleSystem;
  68286. /**
  68287. * Not supported by GPUParticleSystem
  68288. * @param gradient defines the gradient to use (between 0 and 1)
  68289. * @param factor defines the emit rate value to affect to the specified gradient
  68290. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  68291. * @returns the current particle system
  68292. */
  68293. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  68294. /**
  68295. * Not supported by GPUParticleSystem
  68296. * @param gradient defines the gradient to remove
  68297. * @returns the current particle system
  68298. */
  68299. removeEmitRateGradient(gradient: number): IParticleSystem;
  68300. /**
  68301. * Not supported by GPUParticleSystem
  68302. * @param gradient defines the gradient to use (between 0 and 1)
  68303. * @param factor defines the start size value to affect to the specified gradient
  68304. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  68305. * @returns the current particle system
  68306. */
  68307. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  68308. /**
  68309. * Not supported by GPUParticleSystem
  68310. * @param gradient defines the gradient to remove
  68311. * @returns the current particle system
  68312. */
  68313. removeStartSizeGradient(gradient: number): IParticleSystem;
  68314. /**
  68315. * Not supported by GPUParticleSystem
  68316. * @param gradient defines the gradient to use (between 0 and 1)
  68317. * @param min defines the color remap minimal range
  68318. * @param max defines the color remap maximal range
  68319. * @returns the current particle system
  68320. */
  68321. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  68322. /**
  68323. * Not supported by GPUParticleSystem
  68324. * @param gradient defines the gradient to remove
  68325. * @returns the current particle system
  68326. */
  68327. removeColorRemapGradient(): IParticleSystem;
  68328. /**
  68329. * Not supported by GPUParticleSystem
  68330. * @param gradient defines the gradient to use (between 0 and 1)
  68331. * @param min defines the alpha remap minimal range
  68332. * @param max defines the alpha remap maximal range
  68333. * @returns the current particle system
  68334. */
  68335. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  68336. /**
  68337. * Not supported by GPUParticleSystem
  68338. * @param gradient defines the gradient to remove
  68339. * @returns the current particle system
  68340. */
  68341. removeAlphaRemapGradient(): IParticleSystem;
  68342. /**
  68343. * Not supported by GPUParticleSystem
  68344. * @param gradient defines the gradient to use (between 0 and 1)
  68345. * @param color defines the color to affect to the specified gradient
  68346. * @returns the current particle system
  68347. */
  68348. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  68349. /**
  68350. * Not supported by GPUParticleSystem
  68351. * @param gradient defines the gradient to remove
  68352. * @returns the current particle system
  68353. */
  68354. removeRampGradient(): IParticleSystem;
  68355. /**
  68356. * Not supported by GPUParticleSystem
  68357. * @returns the list of ramp gradients
  68358. */
  68359. getRampGradients(): Nullable<Array<Color3Gradient>>;
  68360. /**
  68361. * Not supported by GPUParticleSystem
  68362. * Gets or sets a boolean indicating that ramp gradients must be used
  68363. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  68364. */
  68365. get useRampGradients(): boolean;
  68366. set useRampGradients(value: boolean);
  68367. /**
  68368. * Not supported by GPUParticleSystem
  68369. * @param gradient defines the gradient to use (between 0 and 1)
  68370. * @param factor defines the life time factor to affect to the specified gradient
  68371. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  68372. * @returns the current particle system
  68373. */
  68374. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  68375. /**
  68376. * Not supported by GPUParticleSystem
  68377. * @param gradient defines the gradient to remove
  68378. * @returns the current particle system
  68379. */
  68380. removeLifeTimeGradient(gradient: number): IParticleSystem;
  68381. /**
  68382. * Instantiates a GPU particle system.
  68383. * 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.
  68384. * @param name The name of the particle system
  68385. * @param options The options used to create the system
  68386. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  68387. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  68388. * @param customEffect a custom effect used to change the way particles are rendered by default
  68389. */
  68390. constructor(name: string, options: Partial<{
  68391. capacity: number;
  68392. randomTextureSize: number;
  68393. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  68394. protected _reset(): void;
  68395. private _createUpdateVAO;
  68396. private _createRenderVAO;
  68397. private _initialize;
  68398. /** @hidden */
  68399. _recreateUpdateEffect(): void;
  68400. private _getEffect;
  68401. /**
  68402. * Fill the defines array according to the current settings of the particle system
  68403. * @param defines Array to be updated
  68404. * @param blendMode blend mode to take into account when updating the array
  68405. */
  68406. fillDefines(defines: Array<string>, blendMode?: number): void;
  68407. /**
  68408. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  68409. * @param uniforms Uniforms array to fill
  68410. * @param attributes Attributes array to fill
  68411. * @param samplers Samplers array to fill
  68412. */
  68413. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  68414. /** @hidden */
  68415. _recreateRenderEffect(): Effect;
  68416. /**
  68417. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  68418. * @param preWarm defines if we are in the pre-warmimg phase
  68419. */
  68420. animate(preWarm?: boolean): void;
  68421. private _createFactorGradientTexture;
  68422. private _createSizeGradientTexture;
  68423. private _createAngularSpeedGradientTexture;
  68424. private _createVelocityGradientTexture;
  68425. private _createLimitVelocityGradientTexture;
  68426. private _createDragGradientTexture;
  68427. private _createColorGradientTexture;
  68428. /**
  68429. * Renders the particle system in its current state
  68430. * @param preWarm defines if the system should only update the particles but not render them
  68431. * @returns the current number of particles
  68432. */
  68433. render(preWarm?: boolean): number;
  68434. /**
  68435. * Rebuilds the particle system
  68436. */
  68437. rebuild(): void;
  68438. private _releaseBuffers;
  68439. private _releaseVAOs;
  68440. /**
  68441. * Disposes the particle system and free the associated resources
  68442. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  68443. */
  68444. dispose(disposeTexture?: boolean): void;
  68445. /**
  68446. * Clones the particle system.
  68447. * @param name The name of the cloned object
  68448. * @param newEmitter The new emitter to use
  68449. * @returns the cloned particle system
  68450. */
  68451. clone(name: string, newEmitter: any): GPUParticleSystem;
  68452. /**
  68453. * Serializes the particle system to a JSON object
  68454. * @param serializeTexture defines if the texture must be serialized as well
  68455. * @returns the JSON object
  68456. */
  68457. serialize(serializeTexture?: boolean): any;
  68458. /**
  68459. * Parses a JSON object to create a GPU particle system.
  68460. * @param parsedParticleSystem The JSON object to parse
  68461. * @param sceneOrEngine The scene or the engine to create the particle system in
  68462. * @param rootUrl The root url to use to load external dependencies like texture
  68463. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  68464. * @returns the parsed GPU particle system
  68465. */
  68466. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  68467. }
  68468. }
  68469. declare module BABYLON {
  68470. /**
  68471. * Represents a set of particle systems working together to create a specific effect
  68472. */
  68473. export class ParticleSystemSet implements IDisposable {
  68474. /**
  68475. * Gets or sets base Assets URL
  68476. */
  68477. static BaseAssetsUrl: string;
  68478. private _emitterCreationOptions;
  68479. private _emitterNode;
  68480. /**
  68481. * Gets the particle system list
  68482. */
  68483. systems: IParticleSystem[];
  68484. /**
  68485. * Gets the emitter node used with this set
  68486. */
  68487. get emitterNode(): Nullable<TransformNode>;
  68488. /**
  68489. * Creates a new emitter mesh as a sphere
  68490. * @param options defines the options used to create the sphere
  68491. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  68492. * @param scene defines the hosting scene
  68493. */
  68494. setEmitterAsSphere(options: {
  68495. diameter: number;
  68496. segments: number;
  68497. color: Color3;
  68498. }, renderingGroupId: number, scene: Scene): void;
  68499. /**
  68500. * Starts all particle systems of the set
  68501. * @param emitter defines an optional mesh to use as emitter for the particle systems
  68502. */
  68503. start(emitter?: AbstractMesh): void;
  68504. /**
  68505. * Release all associated resources
  68506. */
  68507. dispose(): void;
  68508. /**
  68509. * Serialize the set into a JSON compatible object
  68510. * @param serializeTexture defines if the texture must be serialized as well
  68511. * @returns a JSON compatible representation of the set
  68512. */
  68513. serialize(serializeTexture?: boolean): any;
  68514. /**
  68515. * Parse a new ParticleSystemSet from a serialized source
  68516. * @param data defines a JSON compatible representation of the set
  68517. * @param scene defines the hosting scene
  68518. * @param gpu defines if we want GPU particles or CPU particles
  68519. * @returns a new ParticleSystemSet
  68520. */
  68521. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  68522. }
  68523. }
  68524. declare module BABYLON {
  68525. /**
  68526. * This class is made for on one-liner static method to help creating particle system set.
  68527. */
  68528. export class ParticleHelper {
  68529. /**
  68530. * Gets or sets base Assets URL
  68531. */
  68532. static BaseAssetsUrl: string;
  68533. /** Define the Url to load snippets */
  68534. static SnippetUrl: string;
  68535. /**
  68536. * Create a default particle system that you can tweak
  68537. * @param emitter defines the emitter to use
  68538. * @param capacity defines the system capacity (default is 500 particles)
  68539. * @param scene defines the hosting scene
  68540. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  68541. * @returns the new Particle system
  68542. */
  68543. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  68544. /**
  68545. * This is the main static method (one-liner) of this helper to create different particle systems
  68546. * @param type This string represents the type to the particle system to create
  68547. * @param scene The scene where the particle system should live
  68548. * @param gpu If the system will use gpu
  68549. * @returns the ParticleSystemSet created
  68550. */
  68551. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  68552. /**
  68553. * Static function used to export a particle system to a ParticleSystemSet variable.
  68554. * Please note that the emitter shape is not exported
  68555. * @param systems defines the particle systems to export
  68556. * @returns the created particle system set
  68557. */
  68558. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  68559. /**
  68560. * Creates a particle system from a snippet saved in a remote file
  68561. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  68562. * @param url defines the url to load from
  68563. * @param scene defines the hosting scene
  68564. * @param gpu If the system will use gpu
  68565. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  68566. * @returns a promise that will resolve to the new particle system
  68567. */
  68568. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  68569. /**
  68570. * Creates a particle system from a snippet saved by the particle system editor
  68571. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  68572. * @param scene defines the hosting scene
  68573. * @param gpu If the system will use gpu
  68574. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  68575. * @returns a promise that will resolve to the new particle system
  68576. */
  68577. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  68578. }
  68579. }
  68580. declare module BABYLON {
  68581. interface Engine {
  68582. /**
  68583. * Create an effect to use with particle systems.
  68584. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  68585. * the particle system for which you want to create a custom effect in the last parameter
  68586. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  68587. * @param uniformsNames defines a list of attribute names
  68588. * @param samplers defines an array of string used to represent textures
  68589. * @param defines defines the string containing the defines to use to compile the shaders
  68590. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  68591. * @param onCompiled defines a function to call when the effect creation is successful
  68592. * @param onError defines a function to call when the effect creation has failed
  68593. * @param particleSystem the particle system you want to create the effect for
  68594. * @returns the new Effect
  68595. */
  68596. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  68597. }
  68598. interface Mesh {
  68599. /**
  68600. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  68601. * @returns an array of IParticleSystem
  68602. */
  68603. getEmittedParticleSystems(): IParticleSystem[];
  68604. /**
  68605. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  68606. * @returns an array of IParticleSystem
  68607. */
  68608. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  68609. }
  68610. }
  68611. declare module BABYLON {
  68612. /** Defines the 4 color options */
  68613. export enum PointColor {
  68614. /** color value */
  68615. Color = 2,
  68616. /** uv value */
  68617. UV = 1,
  68618. /** random value */
  68619. Random = 0,
  68620. /** stated value */
  68621. Stated = 3
  68622. }
  68623. /**
  68624. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  68625. * 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.
  68626. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  68627. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  68628. *
  68629. * Full documentation here : TO BE ENTERED
  68630. */
  68631. export class PointsCloudSystem implements IDisposable {
  68632. /**
  68633. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  68634. * Example : var p = SPS.particles[i];
  68635. */
  68636. particles: CloudPoint[];
  68637. /**
  68638. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  68639. */
  68640. nbParticles: number;
  68641. /**
  68642. * This a counter for your own usage. It's not set by any SPS functions.
  68643. */
  68644. counter: number;
  68645. /**
  68646. * The PCS name. This name is also given to the underlying mesh.
  68647. */
  68648. name: string;
  68649. /**
  68650. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  68651. */
  68652. mesh: Mesh;
  68653. /**
  68654. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  68655. * Please read :
  68656. */
  68657. vars: any;
  68658. /**
  68659. * @hidden
  68660. */
  68661. _size: number;
  68662. private _scene;
  68663. private _promises;
  68664. private _positions;
  68665. private _indices;
  68666. private _normals;
  68667. private _colors;
  68668. private _uvs;
  68669. private _indices32;
  68670. private _positions32;
  68671. private _colors32;
  68672. private _uvs32;
  68673. private _updatable;
  68674. private _isVisibilityBoxLocked;
  68675. private _alwaysVisible;
  68676. private _groups;
  68677. private _groupCounter;
  68678. private _computeParticleColor;
  68679. private _computeParticleTexture;
  68680. private _computeParticleRotation;
  68681. private _computeBoundingBox;
  68682. private _isReady;
  68683. /**
  68684. * Creates a PCS (Points Cloud System) object
  68685. * @param name (String) is the PCS name, this will be the underlying mesh name
  68686. * @param pointSize (number) is the size for each point
  68687. * @param scene (Scene) is the scene in which the PCS is added
  68688. * @param options defines the options of the PCS e.g.
  68689. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  68690. */
  68691. constructor(name: string, pointSize: number, scene: Scene, options?: {
  68692. updatable?: boolean;
  68693. });
  68694. /**
  68695. * Builds the PCS underlying mesh. Returns a standard Mesh.
  68696. * If no points were added to the PCS, the returned mesh is just a single point.
  68697. * @returns a promise for the created mesh
  68698. */
  68699. buildMeshAsync(): Promise<Mesh>;
  68700. /**
  68701. * @hidden
  68702. */
  68703. private _buildMesh;
  68704. private _addParticle;
  68705. private _randomUnitVector;
  68706. private _getColorIndicesForCoord;
  68707. private _setPointsColorOrUV;
  68708. private _colorFromTexture;
  68709. private _calculateDensity;
  68710. /**
  68711. * Adds points to the PCS in random positions within a unit sphere
  68712. * @param nb (positive integer) the number of particles to be created from this model
  68713. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  68714. * @returns the number of groups in the system
  68715. */
  68716. addPoints(nb: number, pointFunction?: any): number;
  68717. /**
  68718. * Adds points to the PCS from the surface of the model shape
  68719. * @param mesh is any Mesh object that will be used as a surface model for the points
  68720. * @param nb (positive integer) the number of particles to be created from this model
  68721. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  68722. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  68723. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  68724. * @returns the number of groups in the system
  68725. */
  68726. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  68727. /**
  68728. * Adds points to the PCS inside the model shape
  68729. * @param mesh is any Mesh object that will be used as a surface model for the points
  68730. * @param nb (positive integer) the number of particles to be created from this model
  68731. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  68732. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  68733. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  68734. * @returns the number of groups in the system
  68735. */
  68736. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  68737. /**
  68738. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  68739. * This method calls `updateParticle()` for each particle of the SPS.
  68740. * For an animated SPS, it is usually called within the render loop.
  68741. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  68742. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  68743. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  68744. * @returns the PCS.
  68745. */
  68746. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  68747. /**
  68748. * Disposes the PCS.
  68749. */
  68750. dispose(): void;
  68751. /**
  68752. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  68753. * doc :
  68754. * @returns the PCS.
  68755. */
  68756. refreshVisibleSize(): PointsCloudSystem;
  68757. /**
  68758. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  68759. * @param size the size (float) of the visibility box
  68760. * note : this doesn't lock the PCS mesh bounding box.
  68761. * doc :
  68762. */
  68763. setVisibilityBox(size: number): void;
  68764. /**
  68765. * Gets whether the PCS is always visible or not
  68766. * doc :
  68767. */
  68768. get isAlwaysVisible(): boolean;
  68769. /**
  68770. * Sets the PCS as always visible or not
  68771. * doc :
  68772. */
  68773. set isAlwaysVisible(val: boolean);
  68774. /**
  68775. * Tells to `setParticles()` to compute the particle rotations or not
  68776. * Default value : false. The PCS is faster when it's set to false
  68777. * Note : particle rotations are only applied to parent particles
  68778. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  68779. */
  68780. set computeParticleRotation(val: boolean);
  68781. /**
  68782. * Tells to `setParticles()` to compute the particle colors or not.
  68783. * Default value : true. The PCS is faster when it's set to false.
  68784. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  68785. */
  68786. set computeParticleColor(val: boolean);
  68787. set computeParticleTexture(val: boolean);
  68788. /**
  68789. * Gets if `setParticles()` computes the particle colors or not.
  68790. * Default value : false. The PCS is faster when it's set to false.
  68791. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  68792. */
  68793. get computeParticleColor(): boolean;
  68794. /**
  68795. * Gets if `setParticles()` computes the particle textures or not.
  68796. * Default value : false. The PCS is faster when it's set to false.
  68797. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  68798. */
  68799. get computeParticleTexture(): boolean;
  68800. /**
  68801. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  68802. */
  68803. set computeBoundingBox(val: boolean);
  68804. /**
  68805. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  68806. */
  68807. get computeBoundingBox(): boolean;
  68808. /**
  68809. * This function does nothing. It may be overwritten to set all the particle first values.
  68810. * The PCS doesn't call this function, you may have to call it by your own.
  68811. * doc :
  68812. */
  68813. initParticles(): void;
  68814. /**
  68815. * This function does nothing. It may be overwritten to recycle a particle
  68816. * The PCS doesn't call this function, you can to call it
  68817. * doc :
  68818. * @param particle The particle to recycle
  68819. * @returns the recycled particle
  68820. */
  68821. recycleParticle(particle: CloudPoint): CloudPoint;
  68822. /**
  68823. * Updates a particle : this function should be overwritten by the user.
  68824. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  68825. * doc :
  68826. * @example : just set a particle position or velocity and recycle conditions
  68827. * @param particle The particle to update
  68828. * @returns the updated particle
  68829. */
  68830. updateParticle(particle: CloudPoint): CloudPoint;
  68831. /**
  68832. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  68833. * This does nothing and may be overwritten by the user.
  68834. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  68835. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  68836. * @param update the boolean update value actually passed to setParticles()
  68837. */
  68838. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  68839. /**
  68840. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  68841. * This will be passed three parameters.
  68842. * This does nothing and may be overwritten by the user.
  68843. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  68844. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  68845. * @param update the boolean update value actually passed to setParticles()
  68846. */
  68847. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  68848. }
  68849. }
  68850. declare module BABYLON {
  68851. /**
  68852. * Represents one particle of a points cloud system.
  68853. */
  68854. export class CloudPoint {
  68855. /**
  68856. * particle global index
  68857. */
  68858. idx: number;
  68859. /**
  68860. * The color of the particle
  68861. */
  68862. color: Nullable<Color4>;
  68863. /**
  68864. * The world space position of the particle.
  68865. */
  68866. position: Vector3;
  68867. /**
  68868. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  68869. */
  68870. rotation: Vector3;
  68871. /**
  68872. * The world space rotation quaternion of the particle.
  68873. */
  68874. rotationQuaternion: Nullable<Quaternion>;
  68875. /**
  68876. * The uv of the particle.
  68877. */
  68878. uv: Nullable<Vector2>;
  68879. /**
  68880. * The current speed of the particle.
  68881. */
  68882. velocity: Vector3;
  68883. /**
  68884. * The pivot point in the particle local space.
  68885. */
  68886. pivot: Vector3;
  68887. /**
  68888. * Must the particle be translated from its pivot point in its local space ?
  68889. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  68890. * Default : false
  68891. */
  68892. translateFromPivot: boolean;
  68893. /**
  68894. * Index of this particle in the global "positions" array (Internal use)
  68895. * @hidden
  68896. */
  68897. _pos: number;
  68898. /**
  68899. * @hidden Index of this particle in the global "indices" array (Internal use)
  68900. */
  68901. _ind: number;
  68902. /**
  68903. * Group this particle belongs to
  68904. */
  68905. _group: PointsGroup;
  68906. /**
  68907. * Group id of this particle
  68908. */
  68909. groupId: number;
  68910. /**
  68911. * Index of the particle in its group id (Internal use)
  68912. */
  68913. idxInGroup: number;
  68914. /**
  68915. * @hidden Particle BoundingInfo object (Internal use)
  68916. */
  68917. _boundingInfo: BoundingInfo;
  68918. /**
  68919. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  68920. */
  68921. _pcs: PointsCloudSystem;
  68922. /**
  68923. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  68924. */
  68925. _stillInvisible: boolean;
  68926. /**
  68927. * @hidden Last computed particle rotation matrix
  68928. */
  68929. _rotationMatrix: number[];
  68930. /**
  68931. * Parent particle Id, if any.
  68932. * Default null.
  68933. */
  68934. parentId: Nullable<number>;
  68935. /**
  68936. * @hidden Internal global position in the PCS.
  68937. */
  68938. _globalPosition: Vector3;
  68939. /**
  68940. * Creates a Point Cloud object.
  68941. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  68942. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  68943. * @param group (PointsGroup) is the group the particle belongs to
  68944. * @param groupId (integer) is the group identifier in the PCS.
  68945. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  68946. * @param pcs defines the PCS it is associated to
  68947. */
  68948. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  68949. /**
  68950. * get point size
  68951. */
  68952. get size(): Vector3;
  68953. /**
  68954. * Set point size
  68955. */
  68956. set size(scale: Vector3);
  68957. /**
  68958. * Legacy support, changed quaternion to rotationQuaternion
  68959. */
  68960. get quaternion(): Nullable<Quaternion>;
  68961. /**
  68962. * Legacy support, changed quaternion to rotationQuaternion
  68963. */
  68964. set quaternion(q: Nullable<Quaternion>);
  68965. /**
  68966. * Returns a boolean. True if the particle intersects a mesh, else false
  68967. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  68968. * @param target is the object (point or mesh) what the intersection is computed against
  68969. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  68970. * @returns true if it intersects
  68971. */
  68972. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  68973. /**
  68974. * get the rotation matrix of the particle
  68975. * @hidden
  68976. */
  68977. getRotationMatrix(m: Matrix): void;
  68978. }
  68979. /**
  68980. * Represents a group of points in a points cloud system
  68981. * * PCS internal tool, don't use it manually.
  68982. */
  68983. export class PointsGroup {
  68984. /**
  68985. * The group id
  68986. * @hidden
  68987. */
  68988. groupID: number;
  68989. /**
  68990. * image data for group (internal use)
  68991. * @hidden
  68992. */
  68993. _groupImageData: Nullable<ArrayBufferView>;
  68994. /**
  68995. * Image Width (internal use)
  68996. * @hidden
  68997. */
  68998. _groupImgWidth: number;
  68999. /**
  69000. * Image Height (internal use)
  69001. * @hidden
  69002. */
  69003. _groupImgHeight: number;
  69004. /**
  69005. * Custom position function (internal use)
  69006. * @hidden
  69007. */
  69008. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  69009. /**
  69010. * density per facet for surface points
  69011. * @hidden
  69012. */
  69013. _groupDensity: number[];
  69014. /**
  69015. * Only when points are colored by texture carries pointer to texture list array
  69016. * @hidden
  69017. */
  69018. _textureNb: number;
  69019. /**
  69020. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  69021. * PCS internal tool, don't use it manually.
  69022. * @hidden
  69023. */
  69024. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  69025. }
  69026. }
  69027. declare module BABYLON {
  69028. interface Scene {
  69029. /** @hidden (Backing field) */
  69030. _physicsEngine: Nullable<IPhysicsEngine>;
  69031. /** @hidden */
  69032. _physicsTimeAccumulator: number;
  69033. /**
  69034. * Gets the current physics engine
  69035. * @returns a IPhysicsEngine or null if none attached
  69036. */
  69037. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  69038. /**
  69039. * Enables physics to the current scene
  69040. * @param gravity defines the scene's gravity for the physics engine
  69041. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  69042. * @return a boolean indicating if the physics engine was initialized
  69043. */
  69044. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  69045. /**
  69046. * Disables and disposes the physics engine associated with the scene
  69047. */
  69048. disablePhysicsEngine(): void;
  69049. /**
  69050. * Gets a boolean indicating if there is an active physics engine
  69051. * @returns a boolean indicating if there is an active physics engine
  69052. */
  69053. isPhysicsEnabled(): boolean;
  69054. /**
  69055. * Deletes a physics compound impostor
  69056. * @param compound defines the compound to delete
  69057. */
  69058. deleteCompoundImpostor(compound: any): void;
  69059. /**
  69060. * An event triggered when physic simulation is about to be run
  69061. */
  69062. onBeforePhysicsObservable: Observable<Scene>;
  69063. /**
  69064. * An event triggered when physic simulation has been done
  69065. */
  69066. onAfterPhysicsObservable: Observable<Scene>;
  69067. }
  69068. interface AbstractMesh {
  69069. /** @hidden */
  69070. _physicsImpostor: Nullable<PhysicsImpostor>;
  69071. /**
  69072. * Gets or sets impostor used for physic simulation
  69073. * @see https://doc.babylonjs.com/features/physics_engine
  69074. */
  69075. physicsImpostor: Nullable<PhysicsImpostor>;
  69076. /**
  69077. * Gets the current physics impostor
  69078. * @see https://doc.babylonjs.com/features/physics_engine
  69079. * @returns a physics impostor or null
  69080. */
  69081. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  69082. /** Apply a physic impulse to the mesh
  69083. * @param force defines the force to apply
  69084. * @param contactPoint defines where to apply the force
  69085. * @returns the current mesh
  69086. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  69087. */
  69088. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  69089. /**
  69090. * Creates a physic joint between two meshes
  69091. * @param otherMesh defines the other mesh to use
  69092. * @param pivot1 defines the pivot to use on this mesh
  69093. * @param pivot2 defines the pivot to use on the other mesh
  69094. * @param options defines additional options (can be plugin dependent)
  69095. * @returns the current mesh
  69096. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  69097. */
  69098. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  69099. /** @hidden */
  69100. _disposePhysicsObserver: Nullable<Observer<Node>>;
  69101. }
  69102. /**
  69103. * Defines the physics engine scene component responsible to manage a physics engine
  69104. */
  69105. export class PhysicsEngineSceneComponent implements ISceneComponent {
  69106. /**
  69107. * The component name helpful to identify the component in the list of scene components.
  69108. */
  69109. readonly name: string;
  69110. /**
  69111. * The scene the component belongs to.
  69112. */
  69113. scene: Scene;
  69114. /**
  69115. * Creates a new instance of the component for the given scene
  69116. * @param scene Defines the scene to register the component in
  69117. */
  69118. constructor(scene: Scene);
  69119. /**
  69120. * Registers the component in a given scene
  69121. */
  69122. register(): void;
  69123. /**
  69124. * Rebuilds the elements related to this component in case of
  69125. * context lost for instance.
  69126. */
  69127. rebuild(): void;
  69128. /**
  69129. * Disposes the component and the associated ressources
  69130. */
  69131. dispose(): void;
  69132. }
  69133. }
  69134. declare module BABYLON {
  69135. /**
  69136. * A helper for physics simulations
  69137. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69138. */
  69139. export class PhysicsHelper {
  69140. private _scene;
  69141. private _physicsEngine;
  69142. /**
  69143. * Initializes the Physics helper
  69144. * @param scene Babylon.js scene
  69145. */
  69146. constructor(scene: Scene);
  69147. /**
  69148. * Applies a radial explosion impulse
  69149. * @param origin the origin of the explosion
  69150. * @param radiusOrEventOptions the radius or the options of radial explosion
  69151. * @param strength the explosion strength
  69152. * @param falloff possible options: Constant & Linear. Defaults to Constant
  69153. * @returns A physics radial explosion event, or null
  69154. */
  69155. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  69156. /**
  69157. * Applies a radial explosion force
  69158. * @param origin the origin of the explosion
  69159. * @param radiusOrEventOptions the radius or the options of radial explosion
  69160. * @param strength the explosion strength
  69161. * @param falloff possible options: Constant & Linear. Defaults to Constant
  69162. * @returns A physics radial explosion event, or null
  69163. */
  69164. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  69165. /**
  69166. * Creates a gravitational field
  69167. * @param origin the origin of the explosion
  69168. * @param radiusOrEventOptions the radius or the options of radial explosion
  69169. * @param strength the explosion strength
  69170. * @param falloff possible options: Constant & Linear. Defaults to Constant
  69171. * @returns A physics gravitational field event, or null
  69172. */
  69173. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  69174. /**
  69175. * Creates a physics updraft event
  69176. * @param origin the origin of the updraft
  69177. * @param radiusOrEventOptions the radius or the options of the updraft
  69178. * @param strength the strength of the updraft
  69179. * @param height the height of the updraft
  69180. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  69181. * @returns A physics updraft event, or null
  69182. */
  69183. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  69184. /**
  69185. * Creates a physics vortex event
  69186. * @param origin the of the vortex
  69187. * @param radiusOrEventOptions the radius or the options of the vortex
  69188. * @param strength the strength of the vortex
  69189. * @param height the height of the vortex
  69190. * @returns a Physics vortex event, or null
  69191. * A physics vortex event or null
  69192. */
  69193. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  69194. }
  69195. /**
  69196. * Represents a physics radial explosion event
  69197. */
  69198. class PhysicsRadialExplosionEvent {
  69199. private _scene;
  69200. private _options;
  69201. private _sphere;
  69202. private _dataFetched;
  69203. /**
  69204. * Initializes a radial explosioin event
  69205. * @param _scene BabylonJS scene
  69206. * @param _options The options for the vortex event
  69207. */
  69208. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  69209. /**
  69210. * Returns the data related to the radial explosion event (sphere).
  69211. * @returns The radial explosion event data
  69212. */
  69213. getData(): PhysicsRadialExplosionEventData;
  69214. /**
  69215. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  69216. * @param impostor A physics imposter
  69217. * @param origin the origin of the explosion
  69218. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  69219. */
  69220. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  69221. /**
  69222. * Triggers affecterd impostors callbacks
  69223. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  69224. */
  69225. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  69226. /**
  69227. * Disposes the sphere.
  69228. * @param force Specifies if the sphere should be disposed by force
  69229. */
  69230. dispose(force?: boolean): void;
  69231. /*** Helpers ***/
  69232. private _prepareSphere;
  69233. private _intersectsWithSphere;
  69234. }
  69235. /**
  69236. * Represents a gravitational field event
  69237. */
  69238. class PhysicsGravitationalFieldEvent {
  69239. private _physicsHelper;
  69240. private _scene;
  69241. private _origin;
  69242. private _options;
  69243. private _tickCallback;
  69244. private _sphere;
  69245. private _dataFetched;
  69246. /**
  69247. * Initializes the physics gravitational field event
  69248. * @param _physicsHelper A physics helper
  69249. * @param _scene BabylonJS scene
  69250. * @param _origin The origin position of the gravitational field event
  69251. * @param _options The options for the vortex event
  69252. */
  69253. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  69254. /**
  69255. * Returns the data related to the gravitational field event (sphere).
  69256. * @returns A gravitational field event
  69257. */
  69258. getData(): PhysicsGravitationalFieldEventData;
  69259. /**
  69260. * Enables the gravitational field.
  69261. */
  69262. enable(): void;
  69263. /**
  69264. * Disables the gravitational field.
  69265. */
  69266. disable(): void;
  69267. /**
  69268. * Disposes the sphere.
  69269. * @param force The force to dispose from the gravitational field event
  69270. */
  69271. dispose(force?: boolean): void;
  69272. private _tick;
  69273. }
  69274. /**
  69275. * Represents a physics updraft event
  69276. */
  69277. class PhysicsUpdraftEvent {
  69278. private _scene;
  69279. private _origin;
  69280. private _options;
  69281. private _physicsEngine;
  69282. private _originTop;
  69283. private _originDirection;
  69284. private _tickCallback;
  69285. private _cylinder;
  69286. private _cylinderPosition;
  69287. private _dataFetched;
  69288. /**
  69289. * Initializes the physics updraft event
  69290. * @param _scene BabylonJS scene
  69291. * @param _origin The origin position of the updraft
  69292. * @param _options The options for the updraft event
  69293. */
  69294. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  69295. /**
  69296. * Returns the data related to the updraft event (cylinder).
  69297. * @returns A physics updraft event
  69298. */
  69299. getData(): PhysicsUpdraftEventData;
  69300. /**
  69301. * Enables the updraft.
  69302. */
  69303. enable(): void;
  69304. /**
  69305. * Disables the updraft.
  69306. */
  69307. disable(): void;
  69308. /**
  69309. * Disposes the cylinder.
  69310. * @param force Specifies if the updraft should be disposed by force
  69311. */
  69312. dispose(force?: boolean): void;
  69313. private getImpostorHitData;
  69314. private _tick;
  69315. /*** Helpers ***/
  69316. private _prepareCylinder;
  69317. private _intersectsWithCylinder;
  69318. }
  69319. /**
  69320. * Represents a physics vortex event
  69321. */
  69322. class PhysicsVortexEvent {
  69323. private _scene;
  69324. private _origin;
  69325. private _options;
  69326. private _physicsEngine;
  69327. private _originTop;
  69328. private _tickCallback;
  69329. private _cylinder;
  69330. private _cylinderPosition;
  69331. private _dataFetched;
  69332. /**
  69333. * Initializes the physics vortex event
  69334. * @param _scene The BabylonJS scene
  69335. * @param _origin The origin position of the vortex
  69336. * @param _options The options for the vortex event
  69337. */
  69338. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  69339. /**
  69340. * Returns the data related to the vortex event (cylinder).
  69341. * @returns The physics vortex event data
  69342. */
  69343. getData(): PhysicsVortexEventData;
  69344. /**
  69345. * Enables the vortex.
  69346. */
  69347. enable(): void;
  69348. /**
  69349. * Disables the cortex.
  69350. */
  69351. disable(): void;
  69352. /**
  69353. * Disposes the sphere.
  69354. * @param force
  69355. */
  69356. dispose(force?: boolean): void;
  69357. private getImpostorHitData;
  69358. private _tick;
  69359. /*** Helpers ***/
  69360. private _prepareCylinder;
  69361. private _intersectsWithCylinder;
  69362. }
  69363. /**
  69364. * Options fot the radial explosion event
  69365. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69366. */
  69367. export class PhysicsRadialExplosionEventOptions {
  69368. /**
  69369. * The radius of the sphere for the radial explosion.
  69370. */
  69371. radius: number;
  69372. /**
  69373. * The strenth of the explosion.
  69374. */
  69375. strength: number;
  69376. /**
  69377. * The strenght of the force in correspondence to the distance of the affected object
  69378. */
  69379. falloff: PhysicsRadialImpulseFalloff;
  69380. /**
  69381. * Sphere options for the radial explosion.
  69382. */
  69383. sphere: {
  69384. segments: number;
  69385. diameter: number;
  69386. };
  69387. /**
  69388. * Sphere options for the radial explosion.
  69389. */
  69390. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  69391. }
  69392. /**
  69393. * Options fot the updraft event
  69394. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69395. */
  69396. export class PhysicsUpdraftEventOptions {
  69397. /**
  69398. * The radius of the cylinder for the vortex
  69399. */
  69400. radius: number;
  69401. /**
  69402. * The strenth of the updraft.
  69403. */
  69404. strength: number;
  69405. /**
  69406. * The height of the cylinder for the updraft.
  69407. */
  69408. height: number;
  69409. /**
  69410. * The mode for the the updraft.
  69411. */
  69412. updraftMode: PhysicsUpdraftMode;
  69413. }
  69414. /**
  69415. * Options fot the vortex event
  69416. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69417. */
  69418. export class PhysicsVortexEventOptions {
  69419. /**
  69420. * The radius of the cylinder for the vortex
  69421. */
  69422. radius: number;
  69423. /**
  69424. * The strenth of the vortex.
  69425. */
  69426. strength: number;
  69427. /**
  69428. * The height of the cylinder for the vortex.
  69429. */
  69430. height: number;
  69431. /**
  69432. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  69433. */
  69434. centripetalForceThreshold: number;
  69435. /**
  69436. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  69437. */
  69438. centripetalForceMultiplier: number;
  69439. /**
  69440. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  69441. */
  69442. centrifugalForceMultiplier: number;
  69443. /**
  69444. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  69445. */
  69446. updraftForceMultiplier: number;
  69447. }
  69448. /**
  69449. * The strenght of the force in correspondence to the distance of the affected object
  69450. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69451. */
  69452. export enum PhysicsRadialImpulseFalloff {
  69453. /** Defines that impulse is constant in strength across it's whole radius */
  69454. Constant = 0,
  69455. /** Defines that impulse gets weaker if it's further from the origin */
  69456. Linear = 1
  69457. }
  69458. /**
  69459. * The strength of the force in correspondence to the distance of the affected object
  69460. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69461. */
  69462. export enum PhysicsUpdraftMode {
  69463. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  69464. Center = 0,
  69465. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  69466. Perpendicular = 1
  69467. }
  69468. /**
  69469. * Interface for a physics hit data
  69470. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69471. */
  69472. export interface PhysicsHitData {
  69473. /**
  69474. * The force applied at the contact point
  69475. */
  69476. force: Vector3;
  69477. /**
  69478. * The contact point
  69479. */
  69480. contactPoint: Vector3;
  69481. /**
  69482. * The distance from the origin to the contact point
  69483. */
  69484. distanceFromOrigin: number;
  69485. }
  69486. /**
  69487. * Interface for radial explosion event data
  69488. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69489. */
  69490. export interface PhysicsRadialExplosionEventData {
  69491. /**
  69492. * A sphere used for the radial explosion event
  69493. */
  69494. sphere: Mesh;
  69495. }
  69496. /**
  69497. * Interface for gravitational field event data
  69498. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69499. */
  69500. export interface PhysicsGravitationalFieldEventData {
  69501. /**
  69502. * A sphere mesh used for the gravitational field event
  69503. */
  69504. sphere: Mesh;
  69505. }
  69506. /**
  69507. * Interface for updraft event data
  69508. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69509. */
  69510. export interface PhysicsUpdraftEventData {
  69511. /**
  69512. * A cylinder used for the updraft event
  69513. */
  69514. cylinder: Mesh;
  69515. }
  69516. /**
  69517. * Interface for vortex event data
  69518. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69519. */
  69520. export interface PhysicsVortexEventData {
  69521. /**
  69522. * A cylinder used for the vortex event
  69523. */
  69524. cylinder: Mesh;
  69525. }
  69526. /**
  69527. * Interface for an affected physics impostor
  69528. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  69529. */
  69530. export interface PhysicsAffectedImpostorWithData {
  69531. /**
  69532. * The impostor affected by the effect
  69533. */
  69534. impostor: PhysicsImpostor;
  69535. /**
  69536. * The data about the hit/horce from the explosion
  69537. */
  69538. hitData: PhysicsHitData;
  69539. }
  69540. }
  69541. declare module BABYLON {
  69542. /** @hidden */
  69543. export var blackAndWhitePixelShader: {
  69544. name: string;
  69545. shader: string;
  69546. };
  69547. }
  69548. declare module BABYLON {
  69549. /**
  69550. * Post process used to render in black and white
  69551. */
  69552. export class BlackAndWhitePostProcess extends PostProcess {
  69553. /**
  69554. * Linear about to convert he result to black and white (default: 1)
  69555. */
  69556. degree: number;
  69557. /**
  69558. * Gets a string identifying the name of the class
  69559. * @returns "BlackAndWhitePostProcess" string
  69560. */
  69561. getClassName(): string;
  69562. /**
  69563. * Creates a black and white post process
  69564. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  69565. * @param name The name of the effect.
  69566. * @param options The required width/height ratio to downsize to before computing the render pass.
  69567. * @param camera The camera to apply the render pass to.
  69568. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69569. * @param engine The engine which the post process will be applied. (default: current engine)
  69570. * @param reusable If the post process can be reused on the same frame. (default: false)
  69571. */
  69572. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69573. /** @hidden */
  69574. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  69575. }
  69576. }
  69577. declare module BABYLON {
  69578. /**
  69579. * This represents a set of one or more post processes in Babylon.
  69580. * A post process can be used to apply a shader to a texture after it is rendered.
  69581. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  69582. */
  69583. export class PostProcessRenderEffect {
  69584. private _postProcesses;
  69585. private _getPostProcesses;
  69586. private _singleInstance;
  69587. private _cameras;
  69588. private _indicesForCamera;
  69589. /**
  69590. * Name of the effect
  69591. * @hidden
  69592. */
  69593. _name: string;
  69594. /**
  69595. * Instantiates a post process render effect.
  69596. * A post process can be used to apply a shader to a texture after it is rendered.
  69597. * @param engine The engine the effect is tied to
  69598. * @param name The name of the effect
  69599. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  69600. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  69601. */
  69602. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  69603. /**
  69604. * Checks if all the post processes in the effect are supported.
  69605. */
  69606. get isSupported(): boolean;
  69607. /**
  69608. * Updates the current state of the effect
  69609. * @hidden
  69610. */
  69611. _update(): void;
  69612. /**
  69613. * Attaches the effect on cameras
  69614. * @param cameras The camera to attach to.
  69615. * @hidden
  69616. */
  69617. _attachCameras(cameras: Camera): void;
  69618. /**
  69619. * Attaches the effect on cameras
  69620. * @param cameras The camera to attach to.
  69621. * @hidden
  69622. */
  69623. _attachCameras(cameras: Camera[]): void;
  69624. /**
  69625. * Detaches the effect on cameras
  69626. * @param cameras The camera to detatch from.
  69627. * @hidden
  69628. */
  69629. _detachCameras(cameras: Camera): void;
  69630. /**
  69631. * Detatches the effect on cameras
  69632. * @param cameras The camera to detatch from.
  69633. * @hidden
  69634. */
  69635. _detachCameras(cameras: Camera[]): void;
  69636. /**
  69637. * Enables the effect on given cameras
  69638. * @param cameras The camera to enable.
  69639. * @hidden
  69640. */
  69641. _enable(cameras: Camera): void;
  69642. /**
  69643. * Enables the effect on given cameras
  69644. * @param cameras The camera to enable.
  69645. * @hidden
  69646. */
  69647. _enable(cameras: Nullable<Camera[]>): void;
  69648. /**
  69649. * Disables the effect on the given cameras
  69650. * @param cameras The camera to disable.
  69651. * @hidden
  69652. */
  69653. _disable(cameras: Camera): void;
  69654. /**
  69655. * Disables the effect on the given cameras
  69656. * @param cameras The camera to disable.
  69657. * @hidden
  69658. */
  69659. _disable(cameras: Nullable<Camera[]>): void;
  69660. /**
  69661. * Gets a list of the post processes contained in the effect.
  69662. * @param camera The camera to get the post processes on.
  69663. * @returns The list of the post processes in the effect.
  69664. */
  69665. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  69666. }
  69667. }
  69668. declare module BABYLON {
  69669. /** @hidden */
  69670. export var extractHighlightsPixelShader: {
  69671. name: string;
  69672. shader: string;
  69673. };
  69674. }
  69675. declare module BABYLON {
  69676. /**
  69677. * 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.
  69678. */
  69679. export class ExtractHighlightsPostProcess extends PostProcess {
  69680. /**
  69681. * The luminance threshold, pixels below this value will be set to black.
  69682. */
  69683. threshold: number;
  69684. /** @hidden */
  69685. _exposure: number;
  69686. /**
  69687. * Post process which has the input texture to be used when performing highlight extraction
  69688. * @hidden
  69689. */
  69690. _inputPostProcess: Nullable<PostProcess>;
  69691. /**
  69692. * Gets a string identifying the name of the class
  69693. * @returns "ExtractHighlightsPostProcess" string
  69694. */
  69695. getClassName(): string;
  69696. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69697. }
  69698. }
  69699. declare module BABYLON {
  69700. /** @hidden */
  69701. export var bloomMergePixelShader: {
  69702. name: string;
  69703. shader: string;
  69704. };
  69705. }
  69706. declare module BABYLON {
  69707. /**
  69708. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  69709. */
  69710. export class BloomMergePostProcess extends PostProcess {
  69711. /** Weight of the bloom to be added to the original input. */
  69712. weight: number;
  69713. /**
  69714. * Gets a string identifying the name of the class
  69715. * @returns "BloomMergePostProcess" string
  69716. */
  69717. getClassName(): string;
  69718. /**
  69719. * Creates a new instance of @see BloomMergePostProcess
  69720. * @param name The name of the effect.
  69721. * @param originalFromInput Post process which's input will be used for the merge.
  69722. * @param blurred Blurred highlights post process which's output will be used.
  69723. * @param weight Weight of the bloom to be added to the original input.
  69724. * @param options The required width/height ratio to downsize to before computing the render pass.
  69725. * @param camera The camera to apply the render pass to.
  69726. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69727. * @param engine The engine which the post process will be applied. (default: current engine)
  69728. * @param reusable If the post process can be reused on the same frame. (default: false)
  69729. * @param textureType Type of textures used when performing the post process. (default: 0)
  69730. * @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)
  69731. */
  69732. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  69733. /** Weight of the bloom to be added to the original input. */
  69734. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69735. }
  69736. }
  69737. declare module BABYLON {
  69738. /**
  69739. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  69740. */
  69741. export class BloomEffect extends PostProcessRenderEffect {
  69742. private bloomScale;
  69743. /**
  69744. * @hidden Internal
  69745. */
  69746. _effects: Array<PostProcess>;
  69747. /**
  69748. * @hidden Internal
  69749. */
  69750. _downscale: ExtractHighlightsPostProcess;
  69751. private _blurX;
  69752. private _blurY;
  69753. private _merge;
  69754. /**
  69755. * The luminance threshold to find bright areas of the image to bloom.
  69756. */
  69757. get threshold(): number;
  69758. set threshold(value: number);
  69759. /**
  69760. * The strength of the bloom.
  69761. */
  69762. get weight(): number;
  69763. set weight(value: number);
  69764. /**
  69765. * Specifies the size of the bloom blur kernel, relative to the final output size
  69766. */
  69767. get kernel(): number;
  69768. set kernel(value: number);
  69769. /**
  69770. * Creates a new instance of @see BloomEffect
  69771. * @param scene The scene the effect belongs to.
  69772. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  69773. * @param bloomKernel The size of the kernel to be used when applying the blur.
  69774. * @param bloomWeight The the strength of bloom.
  69775. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  69776. * @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)
  69777. */
  69778. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  69779. /**
  69780. * Disposes each of the internal effects for a given camera.
  69781. * @param camera The camera to dispose the effect on.
  69782. */
  69783. disposeEffects(camera: Camera): void;
  69784. /**
  69785. * @hidden Internal
  69786. */
  69787. _updateEffects(): void;
  69788. /**
  69789. * Internal
  69790. * @returns if all the contained post processes are ready.
  69791. * @hidden
  69792. */
  69793. _isReady(): boolean;
  69794. }
  69795. }
  69796. declare module BABYLON {
  69797. /** @hidden */
  69798. export var chromaticAberrationPixelShader: {
  69799. name: string;
  69800. shader: string;
  69801. };
  69802. }
  69803. declare module BABYLON {
  69804. /**
  69805. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  69806. */
  69807. export class ChromaticAberrationPostProcess extends PostProcess {
  69808. /**
  69809. * The amount of seperation of rgb channels (default: 30)
  69810. */
  69811. aberrationAmount: number;
  69812. /**
  69813. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  69814. */
  69815. radialIntensity: number;
  69816. /**
  69817. * 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))
  69818. */
  69819. direction: Vector2;
  69820. /**
  69821. * 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))
  69822. */
  69823. centerPosition: Vector2;
  69824. /** The width of the screen to apply the effect on */
  69825. screenWidth: number;
  69826. /** The height of the screen to apply the effect on */
  69827. screenHeight: number;
  69828. /**
  69829. * Gets a string identifying the name of the class
  69830. * @returns "ChromaticAberrationPostProcess" string
  69831. */
  69832. getClassName(): string;
  69833. /**
  69834. * Creates a new instance ChromaticAberrationPostProcess
  69835. * @param name The name of the effect.
  69836. * @param screenWidth The width of the screen to apply the effect on.
  69837. * @param screenHeight The height of the screen to apply the effect on.
  69838. * @param options The required width/height ratio to downsize to before computing the render pass.
  69839. * @param camera The camera to apply the render pass to.
  69840. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69841. * @param engine The engine which the post process will be applied. (default: current engine)
  69842. * @param reusable If the post process can be reused on the same frame. (default: false)
  69843. * @param textureType Type of textures used when performing the post process. (default: 0)
  69844. * @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)
  69845. */
  69846. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69847. /** @hidden */
  69848. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  69849. }
  69850. }
  69851. declare module BABYLON {
  69852. /** @hidden */
  69853. export var circleOfConfusionPixelShader: {
  69854. name: string;
  69855. shader: string;
  69856. };
  69857. }
  69858. declare module BABYLON {
  69859. /**
  69860. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  69861. */
  69862. export class CircleOfConfusionPostProcess extends PostProcess {
  69863. /**
  69864. * 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.
  69865. */
  69866. lensSize: number;
  69867. /**
  69868. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  69869. */
  69870. fStop: number;
  69871. /**
  69872. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  69873. */
  69874. focusDistance: number;
  69875. /**
  69876. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  69877. */
  69878. focalLength: number;
  69879. /**
  69880. * Gets a string identifying the name of the class
  69881. * @returns "CircleOfConfusionPostProcess" string
  69882. */
  69883. getClassName(): string;
  69884. private _depthTexture;
  69885. /**
  69886. * Creates a new instance CircleOfConfusionPostProcess
  69887. * @param name The name of the effect.
  69888. * @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.
  69889. * @param options The required width/height ratio to downsize to before computing the render pass.
  69890. * @param camera The camera to apply the render pass to.
  69891. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69892. * @param engine The engine which the post process will be applied. (default: current engine)
  69893. * @param reusable If the post process can be reused on the same frame. (default: false)
  69894. * @param textureType Type of textures used when performing the post process. (default: 0)
  69895. * @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)
  69896. */
  69897. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69898. /**
  69899. * 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.
  69900. */
  69901. set depthTexture(value: RenderTargetTexture);
  69902. }
  69903. }
  69904. declare module BABYLON {
  69905. /** @hidden */
  69906. export var colorCorrectionPixelShader: {
  69907. name: string;
  69908. shader: string;
  69909. };
  69910. }
  69911. declare module BABYLON {
  69912. /**
  69913. *
  69914. * This post-process allows the modification of rendered colors by using
  69915. * a 'look-up table' (LUT). This effect is also called Color Grading.
  69916. *
  69917. * The object needs to be provided an url to a texture containing the color
  69918. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  69919. * Use an image editing software to tweak the LUT to match your needs.
  69920. *
  69921. * For an example of a color LUT, see here:
  69922. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  69923. * For explanations on color grading, see here:
  69924. * @see http://udn.epicgames.com/Three/ColorGrading.html
  69925. *
  69926. */
  69927. export class ColorCorrectionPostProcess extends PostProcess {
  69928. private _colorTableTexture;
  69929. /**
  69930. * Gets the color table url used to create the LUT texture
  69931. */
  69932. colorTableUrl: string;
  69933. /**
  69934. * Gets a string identifying the name of the class
  69935. * @returns "ColorCorrectionPostProcess" string
  69936. */
  69937. getClassName(): string;
  69938. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69939. /** @hidden */
  69940. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  69941. }
  69942. }
  69943. declare module BABYLON {
  69944. /** @hidden */
  69945. export var convolutionPixelShader: {
  69946. name: string;
  69947. shader: string;
  69948. };
  69949. }
  69950. declare module BABYLON {
  69951. /**
  69952. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  69953. * input texture to perform effects such as edge detection or sharpening
  69954. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  69955. */
  69956. export class ConvolutionPostProcess extends PostProcess {
  69957. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  69958. kernel: number[];
  69959. /**
  69960. * Gets a string identifying the name of the class
  69961. * @returns "ConvolutionPostProcess" string
  69962. */
  69963. getClassName(): string;
  69964. /**
  69965. * Creates a new instance ConvolutionPostProcess
  69966. * @param name The name of the effect.
  69967. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  69968. * @param options The required width/height ratio to downsize to before computing the render pass.
  69969. * @param camera The camera to apply the render pass to.
  69970. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69971. * @param engine The engine which the post process will be applied. (default: current engine)
  69972. * @param reusable If the post process can be reused on the same frame. (default: false)
  69973. * @param textureType Type of textures used when performing the post process. (default: 0)
  69974. */
  69975. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  69976. /** @hidden */
  69977. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  69978. /**
  69979. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69980. */
  69981. static EdgeDetect0Kernel: number[];
  69982. /**
  69983. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69984. */
  69985. static EdgeDetect1Kernel: number[];
  69986. /**
  69987. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69988. */
  69989. static EdgeDetect2Kernel: number[];
  69990. /**
  69991. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69992. */
  69993. static SharpenKernel: number[];
  69994. /**
  69995. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  69996. */
  69997. static EmbossKernel: number[];
  69998. /**
  69999. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  70000. */
  70001. static GaussianKernel: number[];
  70002. }
  70003. }
  70004. declare module BABYLON {
  70005. /**
  70006. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  70007. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  70008. * based on samples that have a large difference in distance than the center pixel.
  70009. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  70010. */
  70011. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  70012. /**
  70013. * The direction the blur should be applied
  70014. */
  70015. direction: Vector2;
  70016. /**
  70017. * Gets a string identifying the name of the class
  70018. * @returns "DepthOfFieldBlurPostProcess" string
  70019. */
  70020. getClassName(): string;
  70021. /**
  70022. * Creates a new instance CircleOfConfusionPostProcess
  70023. * @param name The name of the effect.
  70024. * @param scene The scene the effect belongs to.
  70025. * @param direction The direction the blur should be applied.
  70026. * @param kernel The size of the kernel used to blur.
  70027. * @param options The required width/height ratio to downsize to before computing the render pass.
  70028. * @param camera The camera to apply the render pass to.
  70029. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  70030. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  70031. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70032. * @param engine The engine which the post process will be applied. (default: current engine)
  70033. * @param reusable If the post process can be reused on the same frame. (default: false)
  70034. * @param textureType Type of textures used when performing the post process. (default: 0)
  70035. * @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)
  70036. */
  70037. 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);
  70038. }
  70039. }
  70040. declare module BABYLON {
  70041. /** @hidden */
  70042. export var depthOfFieldMergePixelShader: {
  70043. name: string;
  70044. shader: string;
  70045. };
  70046. }
  70047. declare module BABYLON {
  70048. /**
  70049. * Options to be set when merging outputs from the default pipeline.
  70050. */
  70051. export class DepthOfFieldMergePostProcessOptions {
  70052. /**
  70053. * The original image to merge on top of
  70054. */
  70055. originalFromInput: PostProcess;
  70056. /**
  70057. * Parameters to perform the merge of the depth of field effect
  70058. */
  70059. depthOfField?: {
  70060. circleOfConfusion: PostProcess;
  70061. blurSteps: Array<PostProcess>;
  70062. };
  70063. /**
  70064. * Parameters to perform the merge of bloom effect
  70065. */
  70066. bloom?: {
  70067. blurred: PostProcess;
  70068. weight: number;
  70069. };
  70070. }
  70071. /**
  70072. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  70073. */
  70074. export class DepthOfFieldMergePostProcess extends PostProcess {
  70075. private blurSteps;
  70076. /**
  70077. * Gets a string identifying the name of the class
  70078. * @returns "DepthOfFieldMergePostProcess" string
  70079. */
  70080. getClassName(): string;
  70081. /**
  70082. * Creates a new instance of DepthOfFieldMergePostProcess
  70083. * @param name The name of the effect.
  70084. * @param originalFromInput Post process which's input will be used for the merge.
  70085. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  70086. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  70087. * @param options The required width/height ratio to downsize to before computing the render pass.
  70088. * @param camera The camera to apply the render pass to.
  70089. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70090. * @param engine The engine which the post process will be applied. (default: current engine)
  70091. * @param reusable If the post process can be reused on the same frame. (default: false)
  70092. * @param textureType Type of textures used when performing the post process. (default: 0)
  70093. * @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)
  70094. */
  70095. 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);
  70096. /**
  70097. * Updates the effect with the current post process compile time values and recompiles the shader.
  70098. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  70099. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  70100. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  70101. * @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
  70102. * @param onCompiled Called when the shader has been compiled.
  70103. * @param onError Called if there is an error when compiling a shader.
  70104. */
  70105. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  70106. }
  70107. }
  70108. declare module BABYLON {
  70109. /**
  70110. * Specifies the level of max blur that should be applied when using the depth of field effect
  70111. */
  70112. export enum DepthOfFieldEffectBlurLevel {
  70113. /**
  70114. * Subtle blur
  70115. */
  70116. Low = 0,
  70117. /**
  70118. * Medium blur
  70119. */
  70120. Medium = 1,
  70121. /**
  70122. * Large blur
  70123. */
  70124. High = 2
  70125. }
  70126. /**
  70127. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  70128. */
  70129. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  70130. private _circleOfConfusion;
  70131. /**
  70132. * @hidden Internal, blurs from high to low
  70133. */
  70134. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  70135. private _depthOfFieldBlurY;
  70136. private _dofMerge;
  70137. /**
  70138. * @hidden Internal post processes in depth of field effect
  70139. */
  70140. _effects: Array<PostProcess>;
  70141. /**
  70142. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  70143. */
  70144. set focalLength(value: number);
  70145. get focalLength(): number;
  70146. /**
  70147. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  70148. */
  70149. set fStop(value: number);
  70150. get fStop(): number;
  70151. /**
  70152. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  70153. */
  70154. set focusDistance(value: number);
  70155. get focusDistance(): number;
  70156. /**
  70157. * 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.
  70158. */
  70159. set lensSize(value: number);
  70160. get lensSize(): number;
  70161. /**
  70162. * Creates a new instance DepthOfFieldEffect
  70163. * @param scene The scene the effect belongs to.
  70164. * @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.
  70165. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  70166. * @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)
  70167. */
  70168. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  70169. /**
  70170. * Get the current class name of the current effet
  70171. * @returns "DepthOfFieldEffect"
  70172. */
  70173. getClassName(): string;
  70174. /**
  70175. * 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.
  70176. */
  70177. set depthTexture(value: RenderTargetTexture);
  70178. /**
  70179. * Disposes each of the internal effects for a given camera.
  70180. * @param camera The camera to dispose the effect on.
  70181. */
  70182. disposeEffects(camera: Camera): void;
  70183. /**
  70184. * @hidden Internal
  70185. */
  70186. _updateEffects(): void;
  70187. /**
  70188. * Internal
  70189. * @returns if all the contained post processes are ready.
  70190. * @hidden
  70191. */
  70192. _isReady(): boolean;
  70193. }
  70194. }
  70195. declare module BABYLON {
  70196. /** @hidden */
  70197. export var displayPassPixelShader: {
  70198. name: string;
  70199. shader: string;
  70200. };
  70201. }
  70202. declare module BABYLON {
  70203. /**
  70204. * DisplayPassPostProcess which produces an output the same as it's input
  70205. */
  70206. export class DisplayPassPostProcess extends PostProcess {
  70207. /**
  70208. * Gets a string identifying the name of the class
  70209. * @returns "DisplayPassPostProcess" string
  70210. */
  70211. getClassName(): string;
  70212. /**
  70213. * Creates the DisplayPassPostProcess
  70214. * @param name The name of the effect.
  70215. * @param options The required width/height ratio to downsize to before computing the render pass.
  70216. * @param camera The camera to apply the render pass to.
  70217. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70218. * @param engine The engine which the post process will be applied. (default: current engine)
  70219. * @param reusable If the post process can be reused on the same frame. (default: false)
  70220. */
  70221. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70222. /** @hidden */
  70223. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  70224. }
  70225. }
  70226. declare module BABYLON {
  70227. /** @hidden */
  70228. export var filterPixelShader: {
  70229. name: string;
  70230. shader: string;
  70231. };
  70232. }
  70233. declare module BABYLON {
  70234. /**
  70235. * Applies a kernel filter to the image
  70236. */
  70237. export class FilterPostProcess extends PostProcess {
  70238. /** The matrix to be applied to the image */
  70239. kernelMatrix: Matrix;
  70240. /**
  70241. * Gets a string identifying the name of the class
  70242. * @returns "FilterPostProcess" string
  70243. */
  70244. getClassName(): string;
  70245. /**
  70246. *
  70247. * @param name The name of the effect.
  70248. * @param kernelMatrix The matrix to be applied to the image
  70249. * @param options The required width/height ratio to downsize to before computing the render pass.
  70250. * @param camera The camera to apply the render pass to.
  70251. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70252. * @param engine The engine which the post process will be applied. (default: current engine)
  70253. * @param reusable If the post process can be reused on the same frame. (default: false)
  70254. */
  70255. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70256. /** @hidden */
  70257. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  70258. }
  70259. }
  70260. declare module BABYLON {
  70261. /** @hidden */
  70262. export var fxaaPixelShader: {
  70263. name: string;
  70264. shader: string;
  70265. };
  70266. }
  70267. declare module BABYLON {
  70268. /** @hidden */
  70269. export var fxaaVertexShader: {
  70270. name: string;
  70271. shader: string;
  70272. };
  70273. }
  70274. declare module BABYLON {
  70275. /**
  70276. * Fxaa post process
  70277. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  70278. */
  70279. export class FxaaPostProcess extends PostProcess {
  70280. /**
  70281. * Gets a string identifying the name of the class
  70282. * @returns "FxaaPostProcess" string
  70283. */
  70284. getClassName(): string;
  70285. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  70286. private _getDefines;
  70287. /** @hidden */
  70288. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  70289. }
  70290. }
  70291. declare module BABYLON {
  70292. /** @hidden */
  70293. export var grainPixelShader: {
  70294. name: string;
  70295. shader: string;
  70296. };
  70297. }
  70298. declare module BABYLON {
  70299. /**
  70300. * The GrainPostProcess adds noise to the image at mid luminance levels
  70301. */
  70302. export class GrainPostProcess extends PostProcess {
  70303. /**
  70304. * The intensity of the grain added (default: 30)
  70305. */
  70306. intensity: number;
  70307. /**
  70308. * If the grain should be randomized on every frame
  70309. */
  70310. animated: boolean;
  70311. /**
  70312. * Gets a string identifying the name of the class
  70313. * @returns "GrainPostProcess" string
  70314. */
  70315. getClassName(): string;
  70316. /**
  70317. * Creates a new instance of @see GrainPostProcess
  70318. * @param name The name of the effect.
  70319. * @param options The required width/height ratio to downsize to before computing the render pass.
  70320. * @param camera The camera to apply the render pass to.
  70321. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70322. * @param engine The engine which the post process will be applied. (default: current engine)
  70323. * @param reusable If the post process can be reused on the same frame. (default: false)
  70324. * @param textureType Type of textures used when performing the post process. (default: 0)
  70325. * @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)
  70326. */
  70327. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70328. /** @hidden */
  70329. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  70330. }
  70331. }
  70332. declare module BABYLON {
  70333. /** @hidden */
  70334. export var highlightsPixelShader: {
  70335. name: string;
  70336. shader: string;
  70337. };
  70338. }
  70339. declare module BABYLON {
  70340. /**
  70341. * Extracts highlights from the image
  70342. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  70343. */
  70344. export class HighlightsPostProcess extends PostProcess {
  70345. /**
  70346. * Gets a string identifying the name of the class
  70347. * @returns "HighlightsPostProcess" string
  70348. */
  70349. getClassName(): string;
  70350. /**
  70351. * Extracts highlights from the image
  70352. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  70353. * @param name The name of the effect.
  70354. * @param options The required width/height ratio to downsize to before computing the render pass.
  70355. * @param camera The camera to apply the render pass to.
  70356. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70357. * @param engine The engine which the post process will be applied. (default: current engine)
  70358. * @param reusable If the post process can be reused on the same frame. (default: false)
  70359. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  70360. */
  70361. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  70362. }
  70363. }
  70364. declare module BABYLON {
  70365. /**
  70366. * Contains all parameters needed for the prepass to perform
  70367. * motion blur
  70368. */
  70369. export class MotionBlurConfiguration implements PrePassEffectConfiguration {
  70370. /**
  70371. * Is motion blur enabled
  70372. */
  70373. enabled: boolean;
  70374. /**
  70375. * Name of the configuration
  70376. */
  70377. name: string;
  70378. /**
  70379. * Textures that should be present in the MRT for this effect to work
  70380. */
  70381. readonly texturesRequired: number[];
  70382. }
  70383. }
  70384. declare module BABYLON {
  70385. interface Scene {
  70386. /** @hidden (Backing field) */
  70387. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  70388. /**
  70389. * Gets or Sets the current geometry buffer associated to the scene.
  70390. */
  70391. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  70392. /**
  70393. * Enables a GeometryBufferRender and associates it with the scene
  70394. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  70395. * @returns the GeometryBufferRenderer
  70396. */
  70397. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  70398. /**
  70399. * Disables the GeometryBufferRender associated with the scene
  70400. */
  70401. disableGeometryBufferRenderer(): void;
  70402. }
  70403. /**
  70404. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  70405. * in several rendering techniques.
  70406. */
  70407. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  70408. /**
  70409. * The component name helpful to identify the component in the list of scene components.
  70410. */
  70411. readonly name: string;
  70412. /**
  70413. * The scene the component belongs to.
  70414. */
  70415. scene: Scene;
  70416. /**
  70417. * Creates a new instance of the component for the given scene
  70418. * @param scene Defines the scene to register the component in
  70419. */
  70420. constructor(scene: Scene);
  70421. /**
  70422. * Registers the component in a given scene
  70423. */
  70424. register(): void;
  70425. /**
  70426. * Rebuilds the elements related to this component in case of
  70427. * context lost for instance.
  70428. */
  70429. rebuild(): void;
  70430. /**
  70431. * Disposes the component and the associated ressources
  70432. */
  70433. dispose(): void;
  70434. private _gatherRenderTargets;
  70435. }
  70436. }
  70437. declare module BABYLON {
  70438. /** @hidden */
  70439. export var motionBlurPixelShader: {
  70440. name: string;
  70441. shader: string;
  70442. };
  70443. }
  70444. declare module BABYLON {
  70445. /**
  70446. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  70447. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  70448. * As an example, all you have to do is to create the post-process:
  70449. * var mb = new BABYLON.MotionBlurPostProcess(
  70450. * 'mb', // The name of the effect.
  70451. * scene, // The scene containing the objects to blur according to their velocity.
  70452. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  70453. * camera // The camera to apply the render pass to.
  70454. * );
  70455. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  70456. */
  70457. export class MotionBlurPostProcess extends PostProcess {
  70458. /**
  70459. * Defines how much the image is blurred by the movement. Default value is equal to 1
  70460. */
  70461. motionStrength: number;
  70462. /**
  70463. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  70464. */
  70465. get motionBlurSamples(): number;
  70466. /**
  70467. * Sets the number of iterations to be used for motion blur quality
  70468. */
  70469. set motionBlurSamples(samples: number);
  70470. private _motionBlurSamples;
  70471. private _forceGeometryBuffer;
  70472. private _geometryBufferRenderer;
  70473. private _prePassRenderer;
  70474. /**
  70475. * Gets a string identifying the name of the class
  70476. * @returns "MotionBlurPostProcess" string
  70477. */
  70478. getClassName(): string;
  70479. /**
  70480. * Creates a new instance MotionBlurPostProcess
  70481. * @param name The name of the effect.
  70482. * @param scene The scene containing the objects to blur according to their velocity.
  70483. * @param options The required width/height ratio to downsize to before computing the render pass.
  70484. * @param camera The camera to apply the render pass to.
  70485. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70486. * @param engine The engine which the post process will be applied. (default: current engine)
  70487. * @param reusable If the post process can be reused on the same frame. (default: false)
  70488. * @param textureType Type of textures used when performing the post process. (default: 0)
  70489. * @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)
  70490. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  70491. */
  70492. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  70493. /**
  70494. * Excludes the given skinned mesh from computing bones velocities.
  70495. * 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.
  70496. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  70497. */
  70498. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  70499. /**
  70500. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  70501. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  70502. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  70503. */
  70504. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  70505. /**
  70506. * Disposes the post process.
  70507. * @param camera The camera to dispose the post process on.
  70508. */
  70509. dispose(camera?: Camera): void;
  70510. /** @hidden */
  70511. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  70512. }
  70513. }
  70514. declare module BABYLON {
  70515. /** @hidden */
  70516. export var refractionPixelShader: {
  70517. name: string;
  70518. shader: string;
  70519. };
  70520. }
  70521. declare module BABYLON {
  70522. /**
  70523. * Post process which applies a refractin texture
  70524. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  70525. */
  70526. export class RefractionPostProcess extends PostProcess {
  70527. private _refTexture;
  70528. private _ownRefractionTexture;
  70529. /** the base color of the refraction (used to taint the rendering) */
  70530. color: Color3;
  70531. /** simulated refraction depth */
  70532. depth: number;
  70533. /** the coefficient of the base color (0 to remove base color tainting) */
  70534. colorLevel: number;
  70535. /** Gets the url used to load the refraction texture */
  70536. refractionTextureUrl: string;
  70537. /**
  70538. * Gets or sets the refraction texture
  70539. * Please note that you are responsible for disposing the texture if you set it manually
  70540. */
  70541. get refractionTexture(): Texture;
  70542. set refractionTexture(value: Texture);
  70543. /**
  70544. * Gets a string identifying the name of the class
  70545. * @returns "RefractionPostProcess" string
  70546. */
  70547. getClassName(): string;
  70548. /**
  70549. * Initializes the RefractionPostProcess
  70550. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  70551. * @param name The name of the effect.
  70552. * @param refractionTextureUrl Url of the refraction texture to use
  70553. * @param color the base color of the refraction (used to taint the rendering)
  70554. * @param depth simulated refraction depth
  70555. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  70556. * @param camera The camera to apply the render pass to.
  70557. * @param options The required width/height ratio to downsize to before computing the render pass.
  70558. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70559. * @param engine The engine which the post process will be applied. (default: current engine)
  70560. * @param reusable If the post process can be reused on the same frame. (default: false)
  70561. */
  70562. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  70563. /**
  70564. * Disposes of the post process
  70565. * @param camera Camera to dispose post process on
  70566. */
  70567. dispose(camera: Camera): void;
  70568. /** @hidden */
  70569. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  70570. }
  70571. }
  70572. declare module BABYLON {
  70573. /** @hidden */
  70574. export var sharpenPixelShader: {
  70575. name: string;
  70576. shader: string;
  70577. };
  70578. }
  70579. declare module BABYLON {
  70580. /**
  70581. * The SharpenPostProcess applies a sharpen kernel to every pixel
  70582. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  70583. */
  70584. export class SharpenPostProcess extends PostProcess {
  70585. /**
  70586. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  70587. */
  70588. colorAmount: number;
  70589. /**
  70590. * How much sharpness should be applied (default: 0.3)
  70591. */
  70592. edgeAmount: number;
  70593. /**
  70594. * Gets a string identifying the name of the class
  70595. * @returns "SharpenPostProcess" string
  70596. */
  70597. getClassName(): string;
  70598. /**
  70599. * Creates a new instance ConvolutionPostProcess
  70600. * @param name The name of the effect.
  70601. * @param options The required width/height ratio to downsize to before computing the render pass.
  70602. * @param camera The camera to apply the render pass to.
  70603. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70604. * @param engine The engine which the post process will be applied. (default: current engine)
  70605. * @param reusable If the post process can be reused on the same frame. (default: false)
  70606. * @param textureType Type of textures used when performing the post process. (default: 0)
  70607. * @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)
  70608. */
  70609. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70610. /** @hidden */
  70611. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  70612. }
  70613. }
  70614. declare module BABYLON {
  70615. /**
  70616. * PostProcessRenderPipeline
  70617. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70618. */
  70619. export class PostProcessRenderPipeline {
  70620. private engine;
  70621. private _renderEffects;
  70622. private _renderEffectsForIsolatedPass;
  70623. /**
  70624. * List of inspectable custom properties (used by the Inspector)
  70625. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  70626. */
  70627. inspectableCustomProperties: IInspectable[];
  70628. /**
  70629. * @hidden
  70630. */
  70631. protected _cameras: Camera[];
  70632. /** @hidden */
  70633. _name: string;
  70634. /**
  70635. * Gets pipeline name
  70636. */
  70637. get name(): string;
  70638. /** Gets the list of attached cameras */
  70639. get cameras(): Camera[];
  70640. /**
  70641. * Initializes a PostProcessRenderPipeline
  70642. * @param engine engine to add the pipeline to
  70643. * @param name name of the pipeline
  70644. */
  70645. constructor(engine: Engine, name: string);
  70646. /**
  70647. * Gets the class name
  70648. * @returns "PostProcessRenderPipeline"
  70649. */
  70650. getClassName(): string;
  70651. /**
  70652. * If all the render effects in the pipeline are supported
  70653. */
  70654. get isSupported(): boolean;
  70655. /**
  70656. * Adds an effect to the pipeline
  70657. * @param renderEffect the effect to add
  70658. */
  70659. addEffect(renderEffect: PostProcessRenderEffect): void;
  70660. /** @hidden */
  70661. _rebuild(): void;
  70662. /** @hidden */
  70663. _enableEffect(renderEffectName: string, cameras: Camera): void;
  70664. /** @hidden */
  70665. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  70666. /** @hidden */
  70667. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  70668. /** @hidden */
  70669. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  70670. /** @hidden */
  70671. _attachCameras(cameras: Camera, unique: boolean): void;
  70672. /** @hidden */
  70673. _attachCameras(cameras: Camera[], unique: boolean): void;
  70674. /** @hidden */
  70675. _detachCameras(cameras: Camera): void;
  70676. /** @hidden */
  70677. _detachCameras(cameras: Nullable<Camera[]>): void;
  70678. /** @hidden */
  70679. _update(): void;
  70680. /** @hidden */
  70681. _reset(): void;
  70682. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  70683. /**
  70684. * Sets the required values to the prepass renderer.
  70685. * @param prePassRenderer defines the prepass renderer to setup.
  70686. * @returns true if the pre pass is needed.
  70687. */
  70688. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  70689. /**
  70690. * Disposes of the pipeline
  70691. */
  70692. dispose(): void;
  70693. }
  70694. }
  70695. declare module BABYLON {
  70696. /**
  70697. * PostProcessRenderPipelineManager class
  70698. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70699. */
  70700. export class PostProcessRenderPipelineManager {
  70701. private _renderPipelines;
  70702. /**
  70703. * Initializes a PostProcessRenderPipelineManager
  70704. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70705. */
  70706. constructor();
  70707. /**
  70708. * Gets the list of supported render pipelines
  70709. */
  70710. get supportedPipelines(): PostProcessRenderPipeline[];
  70711. /**
  70712. * Adds a pipeline to the manager
  70713. * @param renderPipeline The pipeline to add
  70714. */
  70715. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  70716. /**
  70717. * Attaches a camera to the pipeline
  70718. * @param renderPipelineName The name of the pipeline to attach to
  70719. * @param cameras the camera to attach
  70720. * @param unique if the camera can be attached multiple times to the pipeline
  70721. */
  70722. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  70723. /**
  70724. * Detaches a camera from the pipeline
  70725. * @param renderPipelineName The name of the pipeline to detach from
  70726. * @param cameras the camera to detach
  70727. */
  70728. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  70729. /**
  70730. * Enables an effect by name on a pipeline
  70731. * @param renderPipelineName the name of the pipeline to enable the effect in
  70732. * @param renderEffectName the name of the effect to enable
  70733. * @param cameras the cameras that the effect should be enabled on
  70734. */
  70735. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  70736. /**
  70737. * Disables an effect by name on a pipeline
  70738. * @param renderPipelineName the name of the pipeline to disable the effect in
  70739. * @param renderEffectName the name of the effect to disable
  70740. * @param cameras the cameras that the effect should be disabled on
  70741. */
  70742. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  70743. /**
  70744. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  70745. */
  70746. update(): void;
  70747. /** @hidden */
  70748. _rebuild(): void;
  70749. /**
  70750. * Disposes of the manager and pipelines
  70751. */
  70752. dispose(): void;
  70753. }
  70754. }
  70755. declare module BABYLON {
  70756. interface Scene {
  70757. /** @hidden (Backing field) */
  70758. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  70759. /**
  70760. * Gets the postprocess render pipeline manager
  70761. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  70762. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  70763. */
  70764. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  70765. }
  70766. /**
  70767. * Defines the Render Pipeline scene component responsible to rendering pipelines
  70768. */
  70769. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  70770. /**
  70771. * The component name helpfull to identify the component in the list of scene components.
  70772. */
  70773. readonly name: string;
  70774. /**
  70775. * The scene the component belongs to.
  70776. */
  70777. scene: Scene;
  70778. /**
  70779. * Creates a new instance of the component for the given scene
  70780. * @param scene Defines the scene to register the component in
  70781. */
  70782. constructor(scene: Scene);
  70783. /**
  70784. * Registers the component in a given scene
  70785. */
  70786. register(): void;
  70787. /**
  70788. * Rebuilds the elements related to this component in case of
  70789. * context lost for instance.
  70790. */
  70791. rebuild(): void;
  70792. /**
  70793. * Disposes the component and the associated ressources
  70794. */
  70795. dispose(): void;
  70796. private _gatherRenderTargets;
  70797. }
  70798. }
  70799. declare module BABYLON {
  70800. /**
  70801. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  70802. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  70803. */
  70804. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  70805. private _scene;
  70806. private _camerasToBeAttached;
  70807. /**
  70808. * ID of the sharpen post process,
  70809. */
  70810. private readonly SharpenPostProcessId;
  70811. /**
  70812. * @ignore
  70813. * ID of the image processing post process;
  70814. */
  70815. readonly ImageProcessingPostProcessId: string;
  70816. /**
  70817. * @ignore
  70818. * ID of the Fast Approximate Anti-Aliasing post process;
  70819. */
  70820. readonly FxaaPostProcessId: string;
  70821. /**
  70822. * ID of the chromatic aberration post process,
  70823. */
  70824. private readonly ChromaticAberrationPostProcessId;
  70825. /**
  70826. * ID of the grain post process
  70827. */
  70828. private readonly GrainPostProcessId;
  70829. /**
  70830. * Sharpen post process which will apply a sharpen convolution to enhance edges
  70831. */
  70832. sharpen: SharpenPostProcess;
  70833. private _sharpenEffect;
  70834. private bloom;
  70835. /**
  70836. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  70837. */
  70838. depthOfField: DepthOfFieldEffect;
  70839. /**
  70840. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  70841. */
  70842. fxaa: FxaaPostProcess;
  70843. /**
  70844. * Image post processing pass used to perform operations such as tone mapping or color grading.
  70845. */
  70846. imageProcessing: ImageProcessingPostProcess;
  70847. /**
  70848. * Chromatic aberration post process which will shift rgb colors in the image
  70849. */
  70850. chromaticAberration: ChromaticAberrationPostProcess;
  70851. private _chromaticAberrationEffect;
  70852. /**
  70853. * Grain post process which add noise to the image
  70854. */
  70855. grain: GrainPostProcess;
  70856. private _grainEffect;
  70857. /**
  70858. * Glow post process which adds a glow to emissive areas of the image
  70859. */
  70860. private _glowLayer;
  70861. /**
  70862. * Animations which can be used to tweak settings over a period of time
  70863. */
  70864. animations: Animation[];
  70865. private _imageProcessingConfigurationObserver;
  70866. private _sharpenEnabled;
  70867. private _bloomEnabled;
  70868. private _depthOfFieldEnabled;
  70869. private _depthOfFieldBlurLevel;
  70870. private _fxaaEnabled;
  70871. private _imageProcessingEnabled;
  70872. private _defaultPipelineTextureType;
  70873. private _bloomScale;
  70874. private _chromaticAberrationEnabled;
  70875. private _grainEnabled;
  70876. private _buildAllowed;
  70877. /**
  70878. * Gets active scene
  70879. */
  70880. get scene(): Scene;
  70881. /**
  70882. * Enable or disable the sharpen process from the pipeline
  70883. */
  70884. set sharpenEnabled(enabled: boolean);
  70885. get sharpenEnabled(): boolean;
  70886. private _resizeObserver;
  70887. private _hardwareScaleLevel;
  70888. private _bloomKernel;
  70889. /**
  70890. * Specifies the size of the bloom blur kernel, relative to the final output size
  70891. */
  70892. get bloomKernel(): number;
  70893. set bloomKernel(value: number);
  70894. /**
  70895. * Specifies the weight of the bloom in the final rendering
  70896. */
  70897. private _bloomWeight;
  70898. /**
  70899. * Specifies the luma threshold for the area that will be blurred by the bloom
  70900. */
  70901. private _bloomThreshold;
  70902. private _hdr;
  70903. /**
  70904. * The strength of the bloom.
  70905. */
  70906. set bloomWeight(value: number);
  70907. get bloomWeight(): number;
  70908. /**
  70909. * The strength of the bloom.
  70910. */
  70911. set bloomThreshold(value: number);
  70912. get bloomThreshold(): number;
  70913. /**
  70914. * The scale of the bloom, lower value will provide better performance.
  70915. */
  70916. set bloomScale(value: number);
  70917. get bloomScale(): number;
  70918. /**
  70919. * Enable or disable the bloom from the pipeline
  70920. */
  70921. set bloomEnabled(enabled: boolean);
  70922. get bloomEnabled(): boolean;
  70923. private _rebuildBloom;
  70924. /**
  70925. * If the depth of field is enabled.
  70926. */
  70927. get depthOfFieldEnabled(): boolean;
  70928. set depthOfFieldEnabled(enabled: boolean);
  70929. /**
  70930. * Blur level of the depth of field effect. (Higher blur will effect performance)
  70931. */
  70932. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  70933. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  70934. /**
  70935. * If the anti aliasing is enabled.
  70936. */
  70937. set fxaaEnabled(enabled: boolean);
  70938. get fxaaEnabled(): boolean;
  70939. private _samples;
  70940. /**
  70941. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  70942. */
  70943. set samples(sampleCount: number);
  70944. get samples(): number;
  70945. /**
  70946. * If image processing is enabled.
  70947. */
  70948. set imageProcessingEnabled(enabled: boolean);
  70949. get imageProcessingEnabled(): boolean;
  70950. /**
  70951. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  70952. */
  70953. set glowLayerEnabled(enabled: boolean);
  70954. get glowLayerEnabled(): boolean;
  70955. /**
  70956. * Gets the glow layer (or null if not defined)
  70957. */
  70958. get glowLayer(): Nullable<GlowLayer>;
  70959. /**
  70960. * Enable or disable the chromaticAberration process from the pipeline
  70961. */
  70962. set chromaticAberrationEnabled(enabled: boolean);
  70963. get chromaticAberrationEnabled(): boolean;
  70964. /**
  70965. * Enable or disable the grain process from the pipeline
  70966. */
  70967. set grainEnabled(enabled: boolean);
  70968. get grainEnabled(): boolean;
  70969. /**
  70970. * @constructor
  70971. * @param name - The rendering pipeline name (default: "")
  70972. * @param hdr - If high dynamic range textures should be used (default: true)
  70973. * @param scene - The scene linked to this pipeline (default: the last created scene)
  70974. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  70975. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  70976. */
  70977. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  70978. /**
  70979. * Get the class name
  70980. * @returns "DefaultRenderingPipeline"
  70981. */
  70982. getClassName(): string;
  70983. /**
  70984. * Force the compilation of the entire pipeline.
  70985. */
  70986. prepare(): void;
  70987. private _hasCleared;
  70988. private _prevPostProcess;
  70989. private _prevPrevPostProcess;
  70990. private _setAutoClearAndTextureSharing;
  70991. private _depthOfFieldSceneObserver;
  70992. private _buildPipeline;
  70993. private _disposePostProcesses;
  70994. /**
  70995. * Adds a camera to the pipeline
  70996. * @param camera the camera to be added
  70997. */
  70998. addCamera(camera: Camera): void;
  70999. /**
  71000. * Removes a camera from the pipeline
  71001. * @param camera the camera to remove
  71002. */
  71003. removeCamera(camera: Camera): void;
  71004. /**
  71005. * Dispose of the pipeline and stop all post processes
  71006. */
  71007. dispose(): void;
  71008. /**
  71009. * Serialize the rendering pipeline (Used when exporting)
  71010. * @returns the serialized object
  71011. */
  71012. serialize(): any;
  71013. /**
  71014. * Parse the serialized pipeline
  71015. * @param source Source pipeline.
  71016. * @param scene The scene to load the pipeline to.
  71017. * @param rootUrl The URL of the serialized pipeline.
  71018. * @returns An instantiated pipeline from the serialized object.
  71019. */
  71020. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  71021. }
  71022. }
  71023. declare module BABYLON {
  71024. /** @hidden */
  71025. export var lensHighlightsPixelShader: {
  71026. name: string;
  71027. shader: string;
  71028. };
  71029. }
  71030. declare module BABYLON {
  71031. /** @hidden */
  71032. export var depthOfFieldPixelShader: {
  71033. name: string;
  71034. shader: string;
  71035. };
  71036. }
  71037. declare module BABYLON {
  71038. /**
  71039. * BABYLON.JS Chromatic Aberration GLSL Shader
  71040. * Author: Olivier Guyot
  71041. * Separates very slightly R, G and B colors on the edges of the screen
  71042. * Inspired by Francois Tarlier & Martins Upitis
  71043. */
  71044. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  71045. /**
  71046. * @ignore
  71047. * The chromatic aberration PostProcess id in the pipeline
  71048. */
  71049. LensChromaticAberrationEffect: string;
  71050. /**
  71051. * @ignore
  71052. * The highlights enhancing PostProcess id in the pipeline
  71053. */
  71054. HighlightsEnhancingEffect: string;
  71055. /**
  71056. * @ignore
  71057. * The depth-of-field PostProcess id in the pipeline
  71058. */
  71059. LensDepthOfFieldEffect: string;
  71060. private _scene;
  71061. private _depthTexture;
  71062. private _grainTexture;
  71063. private _chromaticAberrationPostProcess;
  71064. private _highlightsPostProcess;
  71065. private _depthOfFieldPostProcess;
  71066. private _edgeBlur;
  71067. private _grainAmount;
  71068. private _chromaticAberration;
  71069. private _distortion;
  71070. private _highlightsGain;
  71071. private _highlightsThreshold;
  71072. private _dofDistance;
  71073. private _dofAperture;
  71074. private _dofDarken;
  71075. private _dofPentagon;
  71076. private _blurNoise;
  71077. /**
  71078. * @constructor
  71079. *
  71080. * Effect parameters are as follow:
  71081. * {
  71082. * chromatic_aberration: number; // from 0 to x (1 for realism)
  71083. * edge_blur: number; // from 0 to x (1 for realism)
  71084. * distortion: number; // from 0 to x (1 for realism)
  71085. * grain_amount: number; // from 0 to 1
  71086. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  71087. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  71088. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  71089. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  71090. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  71091. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  71092. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  71093. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  71094. * }
  71095. * Note: if an effect parameter is unset, effect is disabled
  71096. *
  71097. * @param name The rendering pipeline name
  71098. * @param parameters - An object containing all parameters (see above)
  71099. * @param scene The scene linked to this pipeline
  71100. * @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)
  71101. * @param cameras The array of cameras that the rendering pipeline will be attached to
  71102. */
  71103. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  71104. /**
  71105. * Get the class name
  71106. * @returns "LensRenderingPipeline"
  71107. */
  71108. getClassName(): string;
  71109. /**
  71110. * Gets associated scene
  71111. */
  71112. get scene(): Scene;
  71113. /**
  71114. * Gets or sets the edge blur
  71115. */
  71116. get edgeBlur(): number;
  71117. set edgeBlur(value: number);
  71118. /**
  71119. * Gets or sets the grain amount
  71120. */
  71121. get grainAmount(): number;
  71122. set grainAmount(value: number);
  71123. /**
  71124. * Gets or sets the chromatic aberration amount
  71125. */
  71126. get chromaticAberration(): number;
  71127. set chromaticAberration(value: number);
  71128. /**
  71129. * Gets or sets the depth of field aperture
  71130. */
  71131. get dofAperture(): number;
  71132. set dofAperture(value: number);
  71133. /**
  71134. * Gets or sets the edge distortion
  71135. */
  71136. get edgeDistortion(): number;
  71137. set edgeDistortion(value: number);
  71138. /**
  71139. * Gets or sets the depth of field distortion
  71140. */
  71141. get dofDistortion(): number;
  71142. set dofDistortion(value: number);
  71143. /**
  71144. * Gets or sets the darken out of focus amount
  71145. */
  71146. get darkenOutOfFocus(): number;
  71147. set darkenOutOfFocus(value: number);
  71148. /**
  71149. * Gets or sets a boolean indicating if blur noise is enabled
  71150. */
  71151. get blurNoise(): boolean;
  71152. set blurNoise(value: boolean);
  71153. /**
  71154. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  71155. */
  71156. get pentagonBokeh(): boolean;
  71157. set pentagonBokeh(value: boolean);
  71158. /**
  71159. * Gets or sets the highlight grain amount
  71160. */
  71161. get highlightsGain(): number;
  71162. set highlightsGain(value: number);
  71163. /**
  71164. * Gets or sets the highlight threshold
  71165. */
  71166. get highlightsThreshold(): number;
  71167. set highlightsThreshold(value: number);
  71168. /**
  71169. * Sets the amount of blur at the edges
  71170. * @param amount blur amount
  71171. */
  71172. setEdgeBlur(amount: number): void;
  71173. /**
  71174. * Sets edge blur to 0
  71175. */
  71176. disableEdgeBlur(): void;
  71177. /**
  71178. * Sets the amout of grain
  71179. * @param amount Amount of grain
  71180. */
  71181. setGrainAmount(amount: number): void;
  71182. /**
  71183. * Set grain amount to 0
  71184. */
  71185. disableGrain(): void;
  71186. /**
  71187. * Sets the chromatic aberration amount
  71188. * @param amount amount of chromatic aberration
  71189. */
  71190. setChromaticAberration(amount: number): void;
  71191. /**
  71192. * Sets chromatic aberration amount to 0
  71193. */
  71194. disableChromaticAberration(): void;
  71195. /**
  71196. * Sets the EdgeDistortion amount
  71197. * @param amount amount of EdgeDistortion
  71198. */
  71199. setEdgeDistortion(amount: number): void;
  71200. /**
  71201. * Sets edge distortion to 0
  71202. */
  71203. disableEdgeDistortion(): void;
  71204. /**
  71205. * Sets the FocusDistance amount
  71206. * @param amount amount of FocusDistance
  71207. */
  71208. setFocusDistance(amount: number): void;
  71209. /**
  71210. * Disables depth of field
  71211. */
  71212. disableDepthOfField(): void;
  71213. /**
  71214. * Sets the Aperture amount
  71215. * @param amount amount of Aperture
  71216. */
  71217. setAperture(amount: number): void;
  71218. /**
  71219. * Sets the DarkenOutOfFocus amount
  71220. * @param amount amount of DarkenOutOfFocus
  71221. */
  71222. setDarkenOutOfFocus(amount: number): void;
  71223. private _pentagonBokehIsEnabled;
  71224. /**
  71225. * Creates a pentagon bokeh effect
  71226. */
  71227. enablePentagonBokeh(): void;
  71228. /**
  71229. * Disables the pentagon bokeh effect
  71230. */
  71231. disablePentagonBokeh(): void;
  71232. /**
  71233. * Enables noise blur
  71234. */
  71235. enableNoiseBlur(): void;
  71236. /**
  71237. * Disables noise blur
  71238. */
  71239. disableNoiseBlur(): void;
  71240. /**
  71241. * Sets the HighlightsGain amount
  71242. * @param amount amount of HighlightsGain
  71243. */
  71244. setHighlightsGain(amount: number): void;
  71245. /**
  71246. * Sets the HighlightsThreshold amount
  71247. * @param amount amount of HighlightsThreshold
  71248. */
  71249. setHighlightsThreshold(amount: number): void;
  71250. /**
  71251. * Disables highlights
  71252. */
  71253. disableHighlights(): void;
  71254. /**
  71255. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  71256. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  71257. */
  71258. dispose(disableDepthRender?: boolean): void;
  71259. private _createChromaticAberrationPostProcess;
  71260. private _createHighlightsPostProcess;
  71261. private _createDepthOfFieldPostProcess;
  71262. private _createGrainTexture;
  71263. }
  71264. }
  71265. declare module BABYLON {
  71266. /**
  71267. * Contains all parameters needed for the prepass to perform
  71268. * screen space subsurface scattering
  71269. */
  71270. export class SSAO2Configuration implements PrePassEffectConfiguration {
  71271. /**
  71272. * Is subsurface enabled
  71273. */
  71274. enabled: boolean;
  71275. /**
  71276. * Name of the configuration
  71277. */
  71278. name: string;
  71279. /**
  71280. * Textures that should be present in the MRT for this effect to work
  71281. */
  71282. readonly texturesRequired: number[];
  71283. }
  71284. }
  71285. declare module BABYLON {
  71286. /** @hidden */
  71287. export var ssao2PixelShader: {
  71288. name: string;
  71289. shader: string;
  71290. };
  71291. }
  71292. declare module BABYLON {
  71293. /** @hidden */
  71294. export var ssaoCombinePixelShader: {
  71295. name: string;
  71296. shader: string;
  71297. };
  71298. }
  71299. declare module BABYLON {
  71300. /**
  71301. * Render pipeline to produce ssao effect
  71302. */
  71303. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  71304. /**
  71305. * @ignore
  71306. * The PassPostProcess id in the pipeline that contains the original scene color
  71307. */
  71308. SSAOOriginalSceneColorEffect: string;
  71309. /**
  71310. * @ignore
  71311. * The SSAO PostProcess id in the pipeline
  71312. */
  71313. SSAORenderEffect: string;
  71314. /**
  71315. * @ignore
  71316. * The horizontal blur PostProcess id in the pipeline
  71317. */
  71318. SSAOBlurHRenderEffect: string;
  71319. /**
  71320. * @ignore
  71321. * The vertical blur PostProcess id in the pipeline
  71322. */
  71323. SSAOBlurVRenderEffect: string;
  71324. /**
  71325. * @ignore
  71326. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  71327. */
  71328. SSAOCombineRenderEffect: string;
  71329. /**
  71330. * The output strength of the SSAO post-process. Default value is 1.0.
  71331. */
  71332. totalStrength: number;
  71333. /**
  71334. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  71335. */
  71336. maxZ: number;
  71337. /**
  71338. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  71339. */
  71340. minZAspect: number;
  71341. private _samples;
  71342. /**
  71343. * Number of samples used for the SSAO calculations. Default value is 8
  71344. */
  71345. set samples(n: number);
  71346. get samples(): number;
  71347. private _textureSamples;
  71348. /**
  71349. * Number of samples to use for antialiasing
  71350. */
  71351. set textureSamples(n: number);
  71352. get textureSamples(): number;
  71353. /**
  71354. * Force rendering the geometry through geometry buffer
  71355. */
  71356. private _forceGeometryBuffer;
  71357. /**
  71358. * Ratio object used for SSAO ratio and blur ratio
  71359. */
  71360. private _ratio;
  71361. /**
  71362. * Dynamically generated sphere sampler.
  71363. */
  71364. private _sampleSphere;
  71365. /**
  71366. * Blur filter offsets
  71367. */
  71368. private _samplerOffsets;
  71369. private _expensiveBlur;
  71370. /**
  71371. * If bilateral blur should be used
  71372. */
  71373. set expensiveBlur(b: boolean);
  71374. get expensiveBlur(): boolean;
  71375. /**
  71376. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  71377. */
  71378. radius: number;
  71379. /**
  71380. * The base color of the SSAO post-process
  71381. * The final result is "base + ssao" between [0, 1]
  71382. */
  71383. base: number;
  71384. /**
  71385. * Support test.
  71386. */
  71387. static get IsSupported(): boolean;
  71388. private _scene;
  71389. private _randomTexture;
  71390. private _originalColorPostProcess;
  71391. private _ssaoPostProcess;
  71392. private _blurHPostProcess;
  71393. private _blurVPostProcess;
  71394. private _ssaoCombinePostProcess;
  71395. private _prePassRenderer;
  71396. /**
  71397. * Gets active scene
  71398. */
  71399. get scene(): Scene;
  71400. /**
  71401. * @constructor
  71402. * @param name The rendering pipeline name
  71403. * @param scene The scene linked to this pipeline
  71404. * @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 }
  71405. * @param cameras The array of cameras that the rendering pipeline will be attached to
  71406. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  71407. */
  71408. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  71409. /**
  71410. * Get the class name
  71411. * @returns "SSAO2RenderingPipeline"
  71412. */
  71413. getClassName(): string;
  71414. /**
  71415. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  71416. */
  71417. dispose(disableGeometryBufferRenderer?: boolean): void;
  71418. private _createBlurPostProcess;
  71419. /** @hidden */
  71420. _rebuild(): void;
  71421. private _bits;
  71422. private _radicalInverse_VdC;
  71423. private _hammersley;
  71424. private _hemisphereSample_uniform;
  71425. private _generateHemisphere;
  71426. private _getDefinesForSSAO;
  71427. private _createSSAOPostProcess;
  71428. private _createSSAOCombinePostProcess;
  71429. private _createRandomTexture;
  71430. /**
  71431. * Serialize the rendering pipeline (Used when exporting)
  71432. * @returns the serialized object
  71433. */
  71434. serialize(): any;
  71435. /**
  71436. * Parse the serialized pipeline
  71437. * @param source Source pipeline.
  71438. * @param scene The scene to load the pipeline to.
  71439. * @param rootUrl The URL of the serialized pipeline.
  71440. * @returns An instantiated pipeline from the serialized object.
  71441. */
  71442. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  71443. }
  71444. }
  71445. declare module BABYLON {
  71446. /** @hidden */
  71447. export var ssaoPixelShader: {
  71448. name: string;
  71449. shader: string;
  71450. };
  71451. }
  71452. declare module BABYLON {
  71453. /**
  71454. * Render pipeline to produce ssao effect
  71455. */
  71456. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  71457. /**
  71458. * @ignore
  71459. * The PassPostProcess id in the pipeline that contains the original scene color
  71460. */
  71461. SSAOOriginalSceneColorEffect: string;
  71462. /**
  71463. * @ignore
  71464. * The SSAO PostProcess id in the pipeline
  71465. */
  71466. SSAORenderEffect: string;
  71467. /**
  71468. * @ignore
  71469. * The horizontal blur PostProcess id in the pipeline
  71470. */
  71471. SSAOBlurHRenderEffect: string;
  71472. /**
  71473. * @ignore
  71474. * The vertical blur PostProcess id in the pipeline
  71475. */
  71476. SSAOBlurVRenderEffect: string;
  71477. /**
  71478. * @ignore
  71479. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  71480. */
  71481. SSAOCombineRenderEffect: string;
  71482. /**
  71483. * The output strength of the SSAO post-process. Default value is 1.0.
  71484. */
  71485. totalStrength: number;
  71486. /**
  71487. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  71488. */
  71489. radius: number;
  71490. /**
  71491. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  71492. * Must not be equal to fallOff and superior to fallOff.
  71493. * Default value is 0.0075
  71494. */
  71495. area: number;
  71496. /**
  71497. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  71498. * Must not be equal to area and inferior to area.
  71499. * Default value is 0.000001
  71500. */
  71501. fallOff: number;
  71502. /**
  71503. * The base color of the SSAO post-process
  71504. * The final result is "base + ssao" between [0, 1]
  71505. */
  71506. base: number;
  71507. private _scene;
  71508. private _depthTexture;
  71509. private _randomTexture;
  71510. private _originalColorPostProcess;
  71511. private _ssaoPostProcess;
  71512. private _blurHPostProcess;
  71513. private _blurVPostProcess;
  71514. private _ssaoCombinePostProcess;
  71515. private _firstUpdate;
  71516. /**
  71517. * Gets active scene
  71518. */
  71519. get scene(): Scene;
  71520. /**
  71521. * @constructor
  71522. * @param name - The rendering pipeline name
  71523. * @param scene - The scene linked to this pipeline
  71524. * @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 }
  71525. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  71526. */
  71527. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  71528. /**
  71529. * Get the class name
  71530. * @returns "SSAORenderingPipeline"
  71531. */
  71532. getClassName(): string;
  71533. /**
  71534. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  71535. */
  71536. dispose(disableDepthRender?: boolean): void;
  71537. private _createBlurPostProcess;
  71538. /** @hidden */
  71539. _rebuild(): void;
  71540. private _createSSAOPostProcess;
  71541. private _createSSAOCombinePostProcess;
  71542. private _createRandomTexture;
  71543. }
  71544. }
  71545. declare module BABYLON {
  71546. /**
  71547. * Contains all parameters needed for the prepass to perform
  71548. * screen space reflections
  71549. */
  71550. export class ScreenSpaceReflectionsConfiguration implements PrePassEffectConfiguration {
  71551. /**
  71552. * Is ssr enabled
  71553. */
  71554. enabled: boolean;
  71555. /**
  71556. * Name of the configuration
  71557. */
  71558. name: string;
  71559. /**
  71560. * Textures that should be present in the MRT for this effect to work
  71561. */
  71562. readonly texturesRequired: number[];
  71563. }
  71564. }
  71565. declare module BABYLON {
  71566. /** @hidden */
  71567. export var screenSpaceReflectionPixelShader: {
  71568. name: string;
  71569. shader: string;
  71570. };
  71571. }
  71572. declare module BABYLON {
  71573. /**
  71574. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  71575. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  71576. */
  71577. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  71578. /**
  71579. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  71580. */
  71581. threshold: number;
  71582. /**
  71583. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  71584. */
  71585. strength: number;
  71586. /**
  71587. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  71588. */
  71589. reflectionSpecularFalloffExponent: number;
  71590. /**
  71591. * 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]
  71592. */
  71593. step: number;
  71594. /**
  71595. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  71596. */
  71597. roughnessFactor: number;
  71598. private _forceGeometryBuffer;
  71599. private _geometryBufferRenderer;
  71600. private _prePassRenderer;
  71601. private _enableSmoothReflections;
  71602. private _reflectionSamples;
  71603. private _smoothSteps;
  71604. /**
  71605. * Gets a string identifying the name of the class
  71606. * @returns "ScreenSpaceReflectionPostProcess" string
  71607. */
  71608. getClassName(): string;
  71609. /**
  71610. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  71611. * @param name The name of the effect.
  71612. * @param scene The scene containing the objects to calculate reflections.
  71613. * @param options The required width/height ratio to downsize to before computing the render pass.
  71614. * @param camera The camera to apply the render pass to.
  71615. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71616. * @param engine The engine which the post process will be applied. (default: current engine)
  71617. * @param reusable If the post process can be reused on the same frame. (default: false)
  71618. * @param textureType Type of textures used when performing the post process. (default: 0)
  71619. * @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)
  71620. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  71621. */
  71622. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  71623. /**
  71624. * Gets wether or not smoothing reflections is enabled.
  71625. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  71626. */
  71627. get enableSmoothReflections(): boolean;
  71628. /**
  71629. * Sets wether or not smoothing reflections is enabled.
  71630. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  71631. */
  71632. set enableSmoothReflections(enabled: boolean);
  71633. /**
  71634. * Gets the number of samples taken while computing reflections. More samples count is high,
  71635. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  71636. */
  71637. get reflectionSamples(): number;
  71638. /**
  71639. * Sets the number of samples taken while computing reflections. More samples count is high,
  71640. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  71641. */
  71642. set reflectionSamples(samples: number);
  71643. /**
  71644. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  71645. * more the post-process will require GPU power and can generate a drop in FPS.
  71646. * Default value (5.0) work pretty well in all cases but can be adjusted.
  71647. */
  71648. get smoothSteps(): number;
  71649. set smoothSteps(steps: number);
  71650. private _updateEffectDefines;
  71651. /** @hidden */
  71652. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  71653. }
  71654. }
  71655. declare module BABYLON {
  71656. /** @hidden */
  71657. export var standardPixelShader: {
  71658. name: string;
  71659. shader: string;
  71660. };
  71661. }
  71662. declare module BABYLON {
  71663. /**
  71664. * Standard rendering pipeline
  71665. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  71666. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  71667. */
  71668. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  71669. /**
  71670. * Public members
  71671. */
  71672. /**
  71673. * Post-process which contains the original scene color before the pipeline applies all the effects
  71674. */
  71675. originalPostProcess: Nullable<PostProcess>;
  71676. /**
  71677. * Post-process used to down scale an image x4
  71678. */
  71679. downSampleX4PostProcess: Nullable<PostProcess>;
  71680. /**
  71681. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  71682. */
  71683. brightPassPostProcess: Nullable<PostProcess>;
  71684. /**
  71685. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  71686. */
  71687. blurHPostProcesses: PostProcess[];
  71688. /**
  71689. * Post-process array storing all the vertical blur post-processes used by the pipeline
  71690. */
  71691. blurVPostProcesses: PostProcess[];
  71692. /**
  71693. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  71694. */
  71695. textureAdderPostProcess: Nullable<PostProcess>;
  71696. /**
  71697. * Post-process used to create volumetric lighting effect
  71698. */
  71699. volumetricLightPostProcess: Nullable<PostProcess>;
  71700. /**
  71701. * Post-process used to smooth the previous volumetric light post-process on the X axis
  71702. */
  71703. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  71704. /**
  71705. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  71706. */
  71707. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  71708. /**
  71709. * Post-process used to merge the volumetric light effect and the real scene color
  71710. */
  71711. volumetricLightMergePostProces: Nullable<PostProcess>;
  71712. /**
  71713. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  71714. */
  71715. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  71716. /**
  71717. * Base post-process used to calculate the average luminance of the final image for HDR
  71718. */
  71719. luminancePostProcess: Nullable<PostProcess>;
  71720. /**
  71721. * Post-processes used to create down sample post-processes in order to get
  71722. * the average luminance of the final image for HDR
  71723. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  71724. */
  71725. luminanceDownSamplePostProcesses: PostProcess[];
  71726. /**
  71727. * Post-process used to create a HDR effect (light adaptation)
  71728. */
  71729. hdrPostProcess: Nullable<PostProcess>;
  71730. /**
  71731. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  71732. */
  71733. textureAdderFinalPostProcess: Nullable<PostProcess>;
  71734. /**
  71735. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  71736. */
  71737. lensFlareFinalPostProcess: Nullable<PostProcess>;
  71738. /**
  71739. * Post-process used to merge the final HDR post-process and the real scene color
  71740. */
  71741. hdrFinalPostProcess: Nullable<PostProcess>;
  71742. /**
  71743. * Post-process used to create a lens flare effect
  71744. */
  71745. lensFlarePostProcess: Nullable<PostProcess>;
  71746. /**
  71747. * Post-process that merges the result of the lens flare post-process and the real scene color
  71748. */
  71749. lensFlareComposePostProcess: Nullable<PostProcess>;
  71750. /**
  71751. * Post-process used to create a motion blur effect
  71752. */
  71753. motionBlurPostProcess: Nullable<PostProcess>;
  71754. /**
  71755. * Post-process used to create a depth of field effect
  71756. */
  71757. depthOfFieldPostProcess: Nullable<PostProcess>;
  71758. /**
  71759. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  71760. */
  71761. fxaaPostProcess: Nullable<FxaaPostProcess>;
  71762. /**
  71763. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  71764. */
  71765. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  71766. /**
  71767. * Represents the brightness threshold in order to configure the illuminated surfaces
  71768. */
  71769. brightThreshold: number;
  71770. /**
  71771. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  71772. */
  71773. blurWidth: number;
  71774. /**
  71775. * Sets if the blur for highlighted surfaces must be only horizontal
  71776. */
  71777. horizontalBlur: boolean;
  71778. /**
  71779. * Gets the overall exposure used by the pipeline
  71780. */
  71781. get exposure(): number;
  71782. /**
  71783. * Sets the overall exposure used by the pipeline
  71784. */
  71785. set exposure(value: number);
  71786. /**
  71787. * Texture used typically to simulate "dirty" on camera lens
  71788. */
  71789. lensTexture: Nullable<Texture>;
  71790. /**
  71791. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  71792. */
  71793. volumetricLightCoefficient: number;
  71794. /**
  71795. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  71796. */
  71797. volumetricLightPower: number;
  71798. /**
  71799. * Used the set the blur intensity to smooth the volumetric lights
  71800. */
  71801. volumetricLightBlurScale: number;
  71802. /**
  71803. * Light (spot or directional) used to generate the volumetric lights rays
  71804. * The source light must have a shadow generate so the pipeline can get its
  71805. * depth map
  71806. */
  71807. sourceLight: Nullable<SpotLight | DirectionalLight>;
  71808. /**
  71809. * For eye adaptation, represents the minimum luminance the eye can see
  71810. */
  71811. hdrMinimumLuminance: number;
  71812. /**
  71813. * For eye adaptation, represents the decrease luminance speed
  71814. */
  71815. hdrDecreaseRate: number;
  71816. /**
  71817. * For eye adaptation, represents the increase luminance speed
  71818. */
  71819. hdrIncreaseRate: number;
  71820. /**
  71821. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  71822. */
  71823. get hdrAutoExposure(): boolean;
  71824. /**
  71825. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  71826. */
  71827. set hdrAutoExposure(value: boolean);
  71828. /**
  71829. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  71830. */
  71831. lensColorTexture: Nullable<Texture>;
  71832. /**
  71833. * The overall strengh for the lens flare effect
  71834. */
  71835. lensFlareStrength: number;
  71836. /**
  71837. * Dispersion coefficient for lens flare ghosts
  71838. */
  71839. lensFlareGhostDispersal: number;
  71840. /**
  71841. * Main lens flare halo width
  71842. */
  71843. lensFlareHaloWidth: number;
  71844. /**
  71845. * Based on the lens distortion effect, defines how much the lens flare result
  71846. * is distorted
  71847. */
  71848. lensFlareDistortionStrength: number;
  71849. /**
  71850. * Configures the blur intensity used for for lens flare (halo)
  71851. */
  71852. lensFlareBlurWidth: number;
  71853. /**
  71854. * Lens star texture must be used to simulate rays on the flares and is available
  71855. * in the documentation
  71856. */
  71857. lensStarTexture: Nullable<Texture>;
  71858. /**
  71859. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  71860. * flare effect by taking account of the dirt texture
  71861. */
  71862. lensFlareDirtTexture: Nullable<Texture>;
  71863. /**
  71864. * Represents the focal length for the depth of field effect
  71865. */
  71866. depthOfFieldDistance: number;
  71867. /**
  71868. * Represents the blur intensity for the blurred part of the depth of field effect
  71869. */
  71870. depthOfFieldBlurWidth: number;
  71871. /**
  71872. * Gets how much the image is blurred by the movement while using the motion blur post-process
  71873. */
  71874. get motionStrength(): number;
  71875. /**
  71876. * Sets how much the image is blurred by the movement while using the motion blur post-process
  71877. */
  71878. set motionStrength(strength: number);
  71879. /**
  71880. * Gets wether or not the motion blur post-process is object based or screen based.
  71881. */
  71882. get objectBasedMotionBlur(): boolean;
  71883. /**
  71884. * Sets wether or not the motion blur post-process should be object based or screen based
  71885. */
  71886. set objectBasedMotionBlur(value: boolean);
  71887. /**
  71888. * List of animations for the pipeline (IAnimatable implementation)
  71889. */
  71890. animations: Animation[];
  71891. /**
  71892. * Private members
  71893. */
  71894. private _scene;
  71895. private _currentDepthOfFieldSource;
  71896. private _basePostProcess;
  71897. private _fixedExposure;
  71898. private _currentExposure;
  71899. private _hdrAutoExposure;
  71900. private _hdrCurrentLuminance;
  71901. private _motionStrength;
  71902. private _isObjectBasedMotionBlur;
  71903. private _floatTextureType;
  71904. private _camerasToBeAttached;
  71905. private _ratio;
  71906. private _bloomEnabled;
  71907. private _depthOfFieldEnabled;
  71908. private _vlsEnabled;
  71909. private _lensFlareEnabled;
  71910. private _hdrEnabled;
  71911. private _motionBlurEnabled;
  71912. private _fxaaEnabled;
  71913. private _screenSpaceReflectionsEnabled;
  71914. private _motionBlurSamples;
  71915. private _volumetricLightStepsCount;
  71916. private _samples;
  71917. /**
  71918. * @ignore
  71919. * Specifies if the bloom pipeline is enabled
  71920. */
  71921. get BloomEnabled(): boolean;
  71922. set BloomEnabled(enabled: boolean);
  71923. /**
  71924. * @ignore
  71925. * Specifies if the depth of field pipeline is enabed
  71926. */
  71927. get DepthOfFieldEnabled(): boolean;
  71928. set DepthOfFieldEnabled(enabled: boolean);
  71929. /**
  71930. * @ignore
  71931. * Specifies if the lens flare pipeline is enabed
  71932. */
  71933. get LensFlareEnabled(): boolean;
  71934. set LensFlareEnabled(enabled: boolean);
  71935. /**
  71936. * @ignore
  71937. * Specifies if the HDR pipeline is enabled
  71938. */
  71939. get HDREnabled(): boolean;
  71940. set HDREnabled(enabled: boolean);
  71941. /**
  71942. * @ignore
  71943. * Specifies if the volumetric lights scattering effect is enabled
  71944. */
  71945. get VLSEnabled(): boolean;
  71946. set VLSEnabled(enabled: boolean);
  71947. /**
  71948. * @ignore
  71949. * Specifies if the motion blur effect is enabled
  71950. */
  71951. get MotionBlurEnabled(): boolean;
  71952. set MotionBlurEnabled(enabled: boolean);
  71953. /**
  71954. * Specifies if anti-aliasing is enabled
  71955. */
  71956. get fxaaEnabled(): boolean;
  71957. set fxaaEnabled(enabled: boolean);
  71958. /**
  71959. * Specifies if screen space reflections are enabled.
  71960. */
  71961. get screenSpaceReflectionsEnabled(): boolean;
  71962. set screenSpaceReflectionsEnabled(enabled: boolean);
  71963. /**
  71964. * Specifies the number of steps used to calculate the volumetric lights
  71965. * Typically in interval [50, 200]
  71966. */
  71967. get volumetricLightStepsCount(): number;
  71968. set volumetricLightStepsCount(count: number);
  71969. /**
  71970. * Specifies the number of samples used for the motion blur effect
  71971. * Typically in interval [16, 64]
  71972. */
  71973. get motionBlurSamples(): number;
  71974. set motionBlurSamples(samples: number);
  71975. /**
  71976. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  71977. */
  71978. get samples(): number;
  71979. set samples(sampleCount: number);
  71980. /**
  71981. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  71982. * @constructor
  71983. * @param name The rendering pipeline name
  71984. * @param scene The scene linked to this pipeline
  71985. * @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)
  71986. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  71987. * @param cameras The array of cameras that the rendering pipeline will be attached to
  71988. */
  71989. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  71990. private _buildPipeline;
  71991. private _createDownSampleX4PostProcess;
  71992. private _createBrightPassPostProcess;
  71993. private _createBlurPostProcesses;
  71994. private _createTextureAdderPostProcess;
  71995. private _createVolumetricLightPostProcess;
  71996. private _createLuminancePostProcesses;
  71997. private _createHdrPostProcess;
  71998. private _createLensFlarePostProcess;
  71999. private _createDepthOfFieldPostProcess;
  72000. private _createMotionBlurPostProcess;
  72001. private _getDepthTexture;
  72002. private _disposePostProcesses;
  72003. /**
  72004. * Dispose of the pipeline and stop all post processes
  72005. */
  72006. dispose(): void;
  72007. /**
  72008. * Serialize the rendering pipeline (Used when exporting)
  72009. * @returns the serialized object
  72010. */
  72011. serialize(): any;
  72012. /**
  72013. * Parse the serialized pipeline
  72014. * @param source Source pipeline.
  72015. * @param scene The scene to load the pipeline to.
  72016. * @param rootUrl The URL of the serialized pipeline.
  72017. * @returns An instantiated pipeline from the serialized object.
  72018. */
  72019. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  72020. /**
  72021. * Luminance steps
  72022. */
  72023. static LuminanceSteps: number;
  72024. }
  72025. }
  72026. declare module BABYLON {
  72027. /** @hidden */
  72028. export var stereoscopicInterlacePixelShader: {
  72029. name: string;
  72030. shader: string;
  72031. };
  72032. }
  72033. declare module BABYLON {
  72034. /**
  72035. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  72036. */
  72037. export class StereoscopicInterlacePostProcessI extends PostProcess {
  72038. private _stepSize;
  72039. private _passedProcess;
  72040. /**
  72041. * Gets a string identifying the name of the class
  72042. * @returns "StereoscopicInterlacePostProcessI" string
  72043. */
  72044. getClassName(): string;
  72045. /**
  72046. * Initializes a StereoscopicInterlacePostProcessI
  72047. * @param name The name of the effect.
  72048. * @param rigCameras The rig cameras to be appled to the post process
  72049. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  72050. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  72051. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72052. * @param engine The engine which the post process will be applied. (default: current engine)
  72053. * @param reusable If the post process can be reused on the same frame. (default: false)
  72054. */
  72055. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72056. }
  72057. /**
  72058. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  72059. */
  72060. export class StereoscopicInterlacePostProcess extends PostProcess {
  72061. private _stepSize;
  72062. private _passedProcess;
  72063. /**
  72064. * Gets a string identifying the name of the class
  72065. * @returns "StereoscopicInterlacePostProcess" string
  72066. */
  72067. getClassName(): string;
  72068. /**
  72069. * Initializes a StereoscopicInterlacePostProcess
  72070. * @param name The name of the effect.
  72071. * @param rigCameras The rig cameras to be appled to the post process
  72072. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  72073. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72074. * @param engine The engine which the post process will be applied. (default: current engine)
  72075. * @param reusable If the post process can be reused on the same frame. (default: false)
  72076. */
  72077. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72078. }
  72079. }
  72080. declare module BABYLON {
  72081. /** @hidden */
  72082. export var tonemapPixelShader: {
  72083. name: string;
  72084. shader: string;
  72085. };
  72086. }
  72087. declare module BABYLON {
  72088. /** Defines operator used for tonemapping */
  72089. export enum TonemappingOperator {
  72090. /** Hable */
  72091. Hable = 0,
  72092. /** Reinhard */
  72093. Reinhard = 1,
  72094. /** HejiDawson */
  72095. HejiDawson = 2,
  72096. /** Photographic */
  72097. Photographic = 3
  72098. }
  72099. /**
  72100. * Defines a post process to apply tone mapping
  72101. */
  72102. export class TonemapPostProcess extends PostProcess {
  72103. private _operator;
  72104. /** Defines the required exposure adjustement */
  72105. exposureAdjustment: number;
  72106. /**
  72107. * Gets a string identifying the name of the class
  72108. * @returns "TonemapPostProcess" string
  72109. */
  72110. getClassName(): string;
  72111. /**
  72112. * Creates a new TonemapPostProcess
  72113. * @param name defines the name of the postprocess
  72114. * @param _operator defines the operator to use
  72115. * @param exposureAdjustment defines the required exposure adjustement
  72116. * @param camera defines the camera to use (can be null)
  72117. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  72118. * @param engine defines the hosting engine (can be ignore if camera is set)
  72119. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  72120. */
  72121. constructor(name: string, _operator: TonemappingOperator,
  72122. /** Defines the required exposure adjustement */
  72123. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  72124. }
  72125. }
  72126. declare module BABYLON {
  72127. /** @hidden */
  72128. export var volumetricLightScatteringPixelShader: {
  72129. name: string;
  72130. shader: string;
  72131. };
  72132. }
  72133. declare module BABYLON {
  72134. /** @hidden */
  72135. export var volumetricLightScatteringPassVertexShader: {
  72136. name: string;
  72137. shader: string;
  72138. };
  72139. }
  72140. declare module BABYLON {
  72141. /** @hidden */
  72142. export var volumetricLightScatteringPassPixelShader: {
  72143. name: string;
  72144. shader: string;
  72145. };
  72146. }
  72147. declare module BABYLON {
  72148. /**
  72149. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  72150. */
  72151. export class VolumetricLightScatteringPostProcess extends PostProcess {
  72152. private _volumetricLightScatteringPass;
  72153. private _volumetricLightScatteringRTT;
  72154. private _viewPort;
  72155. private _screenCoordinates;
  72156. private _cachedDefines;
  72157. /**
  72158. * If not undefined, the mesh position is computed from the attached node position
  72159. */
  72160. attachedNode: {
  72161. position: Vector3;
  72162. };
  72163. /**
  72164. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  72165. */
  72166. customMeshPosition: Vector3;
  72167. /**
  72168. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  72169. */
  72170. useCustomMeshPosition: boolean;
  72171. /**
  72172. * If the post-process should inverse the light scattering direction
  72173. */
  72174. invert: boolean;
  72175. /**
  72176. * The internal mesh used by the post-process
  72177. */
  72178. mesh: Mesh;
  72179. /**
  72180. * @hidden
  72181. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  72182. */
  72183. get useDiffuseColor(): boolean;
  72184. set useDiffuseColor(useDiffuseColor: boolean);
  72185. /**
  72186. * Array containing the excluded meshes not rendered in the internal pass
  72187. */
  72188. excludedMeshes: AbstractMesh[];
  72189. /**
  72190. * Controls the overall intensity of the post-process
  72191. */
  72192. exposure: number;
  72193. /**
  72194. * Dissipates each sample's contribution in range [0, 1]
  72195. */
  72196. decay: number;
  72197. /**
  72198. * Controls the overall intensity of each sample
  72199. */
  72200. weight: number;
  72201. /**
  72202. * Controls the density of each sample
  72203. */
  72204. density: number;
  72205. /**
  72206. * @constructor
  72207. * @param name The post-process name
  72208. * @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)
  72209. * @param camera The camera that the post-process will be attached to
  72210. * @param mesh The mesh used to create the light scattering
  72211. * @param samples The post-process quality, default 100
  72212. * @param samplingModeThe post-process filtering mode
  72213. * @param engine The babylon engine
  72214. * @param reusable If the post-process is reusable
  72215. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  72216. */
  72217. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  72218. /**
  72219. * Returns the string "VolumetricLightScatteringPostProcess"
  72220. * @returns "VolumetricLightScatteringPostProcess"
  72221. */
  72222. getClassName(): string;
  72223. private _isReady;
  72224. /**
  72225. * Sets the new light position for light scattering effect
  72226. * @param position The new custom light position
  72227. */
  72228. setCustomMeshPosition(position: Vector3): void;
  72229. /**
  72230. * Returns the light position for light scattering effect
  72231. * @return Vector3 The custom light position
  72232. */
  72233. getCustomMeshPosition(): Vector3;
  72234. /**
  72235. * Disposes the internal assets and detaches the post-process from the camera
  72236. */
  72237. dispose(camera: Camera): void;
  72238. /**
  72239. * Returns the render target texture used by the post-process
  72240. * @return the render target texture used by the post-process
  72241. */
  72242. getPass(): RenderTargetTexture;
  72243. private _meshExcluded;
  72244. private _createPass;
  72245. private _updateMeshScreenCoordinates;
  72246. /**
  72247. * Creates a default mesh for the Volumeric Light Scattering post-process
  72248. * @param name The mesh name
  72249. * @param scene The scene where to create the mesh
  72250. * @return the default mesh
  72251. */
  72252. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  72253. }
  72254. }
  72255. declare module BABYLON {
  72256. /** @hidden */
  72257. export var screenSpaceCurvaturePixelShader: {
  72258. name: string;
  72259. shader: string;
  72260. };
  72261. }
  72262. declare module BABYLON {
  72263. /**
  72264. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  72265. */
  72266. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  72267. /**
  72268. * Defines how much ridge the curvature effect displays.
  72269. */
  72270. ridge: number;
  72271. /**
  72272. * Defines how much valley the curvature effect displays.
  72273. */
  72274. valley: number;
  72275. private _geometryBufferRenderer;
  72276. /**
  72277. * Gets a string identifying the name of the class
  72278. * @returns "ScreenSpaceCurvaturePostProcess" string
  72279. */
  72280. getClassName(): string;
  72281. /**
  72282. * Creates a new instance ScreenSpaceCurvaturePostProcess
  72283. * @param name The name of the effect.
  72284. * @param scene The scene containing the objects to blur according to their velocity.
  72285. * @param options The required width/height ratio to downsize to before computing the render pass.
  72286. * @param camera The camera to apply the render pass to.
  72287. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72288. * @param engine The engine which the post process will be applied. (default: current engine)
  72289. * @param reusable If the post process can be reused on the same frame. (default: false)
  72290. * @param textureType Type of textures used when performing the post process. (default: 0)
  72291. * @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)
  72292. */
  72293. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  72294. /**
  72295. * Support test.
  72296. */
  72297. static get IsSupported(): boolean;
  72298. /** @hidden */
  72299. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  72300. }
  72301. }
  72302. declare module BABYLON {
  72303. interface Scene {
  72304. /** @hidden (Backing field) */
  72305. _boundingBoxRenderer: BoundingBoxRenderer;
  72306. /** @hidden (Backing field) */
  72307. _forceShowBoundingBoxes: boolean;
  72308. /**
  72309. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  72310. */
  72311. forceShowBoundingBoxes: boolean;
  72312. /**
  72313. * Gets the bounding box renderer associated with the scene
  72314. * @returns a BoundingBoxRenderer
  72315. */
  72316. getBoundingBoxRenderer(): BoundingBoxRenderer;
  72317. }
  72318. interface AbstractMesh {
  72319. /** @hidden (Backing field) */
  72320. _showBoundingBox: boolean;
  72321. /**
  72322. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  72323. */
  72324. showBoundingBox: boolean;
  72325. }
  72326. /**
  72327. * Component responsible of rendering the bounding box of the meshes in a scene.
  72328. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  72329. */
  72330. export class BoundingBoxRenderer implements ISceneComponent {
  72331. /**
  72332. * The component name helpfull to identify the component in the list of scene components.
  72333. */
  72334. readonly name: string;
  72335. /**
  72336. * The scene the component belongs to.
  72337. */
  72338. scene: Scene;
  72339. /**
  72340. * Color of the bounding box lines placed in front of an object
  72341. */
  72342. frontColor: Color3;
  72343. /**
  72344. * Color of the bounding box lines placed behind an object
  72345. */
  72346. backColor: Color3;
  72347. /**
  72348. * Defines if the renderer should show the back lines or not
  72349. */
  72350. showBackLines: boolean;
  72351. /**
  72352. * Observable raised before rendering a bounding box
  72353. */
  72354. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  72355. /**
  72356. * Observable raised after rendering a bounding box
  72357. */
  72358. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  72359. /**
  72360. * @hidden
  72361. */
  72362. renderList: SmartArray<BoundingBox>;
  72363. private _colorShader;
  72364. private _vertexBuffers;
  72365. private _indexBuffer;
  72366. private _fillIndexBuffer;
  72367. private _fillIndexData;
  72368. /**
  72369. * Instantiates a new bounding box renderer in a scene.
  72370. * @param scene the scene the renderer renders in
  72371. */
  72372. constructor(scene: Scene);
  72373. /**
  72374. * Registers the component in a given scene
  72375. */
  72376. register(): void;
  72377. private _evaluateSubMesh;
  72378. private _activeMesh;
  72379. private _prepareRessources;
  72380. private _createIndexBuffer;
  72381. /**
  72382. * Rebuilds the elements related to this component in case of
  72383. * context lost for instance.
  72384. */
  72385. rebuild(): void;
  72386. /**
  72387. * @hidden
  72388. */
  72389. reset(): void;
  72390. /**
  72391. * Render the bounding boxes of a specific rendering group
  72392. * @param renderingGroupId defines the rendering group to render
  72393. */
  72394. render(renderingGroupId: number): void;
  72395. /**
  72396. * In case of occlusion queries, we can render the occlusion bounding box through this method
  72397. * @param mesh Define the mesh to render the occlusion bounding box for
  72398. */
  72399. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  72400. /**
  72401. * Dispose and release the resources attached to this renderer.
  72402. */
  72403. dispose(): void;
  72404. }
  72405. }
  72406. declare module BABYLON {
  72407. interface Scene {
  72408. /** @hidden (Backing field) */
  72409. _depthRenderer: {
  72410. [id: string]: DepthRenderer;
  72411. };
  72412. /**
  72413. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  72414. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  72415. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  72416. * @param force32bitsFloat Forces 32 bits float when supported (else 16 bits float is prioritized over 32 bits float if supported)
  72417. * @returns the created depth renderer
  72418. */
  72419. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, force32bitsFloat?: boolean): DepthRenderer;
  72420. /**
  72421. * Disables a depth renderer for a given camera
  72422. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  72423. */
  72424. disableDepthRenderer(camera?: Nullable<Camera>): void;
  72425. }
  72426. /**
  72427. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  72428. * in several rendering techniques.
  72429. */
  72430. export class DepthRendererSceneComponent implements ISceneComponent {
  72431. /**
  72432. * The component name helpfull to identify the component in the list of scene components.
  72433. */
  72434. readonly name: string;
  72435. /**
  72436. * The scene the component belongs to.
  72437. */
  72438. scene: Scene;
  72439. /**
  72440. * Creates a new instance of the component for the given scene
  72441. * @param scene Defines the scene to register the component in
  72442. */
  72443. constructor(scene: Scene);
  72444. /**
  72445. * Registers the component in a given scene
  72446. */
  72447. register(): void;
  72448. /**
  72449. * Rebuilds the elements related to this component in case of
  72450. * context lost for instance.
  72451. */
  72452. rebuild(): void;
  72453. /**
  72454. * Disposes the component and the associated ressources
  72455. */
  72456. dispose(): void;
  72457. private _gatherRenderTargets;
  72458. private _gatherActiveCameraRenderTargets;
  72459. }
  72460. }
  72461. declare module BABYLON {
  72462. interface AbstractScene {
  72463. /** @hidden (Backing field) */
  72464. _prePassRenderer: Nullable<PrePassRenderer>;
  72465. /**
  72466. * Gets or Sets the current prepass renderer associated to the scene.
  72467. */
  72468. prePassRenderer: Nullable<PrePassRenderer>;
  72469. /**
  72470. * Enables the prepass and associates it with the scene
  72471. * @returns the PrePassRenderer
  72472. */
  72473. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  72474. /**
  72475. * Disables the prepass associated with the scene
  72476. */
  72477. disablePrePassRenderer(): void;
  72478. }
  72479. /**
  72480. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  72481. * in several rendering techniques.
  72482. */
  72483. export class PrePassRendererSceneComponent implements ISceneComponent {
  72484. /**
  72485. * The component name helpful to identify the component in the list of scene components.
  72486. */
  72487. readonly name: string;
  72488. /**
  72489. * The scene the component belongs to.
  72490. */
  72491. scene: Scene;
  72492. /**
  72493. * Creates a new instance of the component for the given scene
  72494. * @param scene Defines the scene to register the component in
  72495. */
  72496. constructor(scene: Scene);
  72497. /**
  72498. * Registers the component in a given scene
  72499. */
  72500. register(): void;
  72501. private _beforeCameraDraw;
  72502. private _afterCameraDraw;
  72503. private _beforeClearStage;
  72504. /**
  72505. * Rebuilds the elements related to this component in case of
  72506. * context lost for instance.
  72507. */
  72508. rebuild(): void;
  72509. /**
  72510. * Disposes the component and the associated ressources
  72511. */
  72512. dispose(): void;
  72513. }
  72514. }
  72515. declare module BABYLON {
  72516. /** @hidden */
  72517. export var fibonacci: {
  72518. name: string;
  72519. shader: string;
  72520. };
  72521. }
  72522. declare module BABYLON {
  72523. /** @hidden */
  72524. export var diffusionProfile: {
  72525. name: string;
  72526. shader: string;
  72527. };
  72528. }
  72529. declare module BABYLON {
  72530. /** @hidden */
  72531. export var subSurfaceScatteringPixelShader: {
  72532. name: string;
  72533. shader: string;
  72534. };
  72535. }
  72536. declare module BABYLON {
  72537. /**
  72538. * Sub surface scattering post process
  72539. */
  72540. export class SubSurfaceScatteringPostProcess extends PostProcess {
  72541. /**
  72542. * Gets a string identifying the name of the class
  72543. * @returns "SubSurfaceScatteringPostProcess" string
  72544. */
  72545. getClassName(): string;
  72546. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  72547. }
  72548. }
  72549. declare module BABYLON {
  72550. /**
  72551. * Contains all parameters needed for the prepass to perform
  72552. * screen space subsurface scattering
  72553. */
  72554. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  72555. /** @hidden */
  72556. static _SceneComponentInitialization: (scene: Scene) => void;
  72557. private _ssDiffusionS;
  72558. private _ssFilterRadii;
  72559. private _ssDiffusionD;
  72560. /**
  72561. * Post process to attach for screen space subsurface scattering
  72562. */
  72563. postProcess: SubSurfaceScatteringPostProcess;
  72564. /**
  72565. * Diffusion profile color for subsurface scattering
  72566. */
  72567. get ssDiffusionS(): number[];
  72568. /**
  72569. * Diffusion profile max color channel value for subsurface scattering
  72570. */
  72571. get ssDiffusionD(): number[];
  72572. /**
  72573. * Diffusion profile filter radius for subsurface scattering
  72574. */
  72575. get ssFilterRadii(): number[];
  72576. /**
  72577. * Is subsurface enabled
  72578. */
  72579. enabled: boolean;
  72580. /**
  72581. * Name of the configuration
  72582. */
  72583. name: string;
  72584. /**
  72585. * Diffusion profile colors for subsurface scattering
  72586. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  72587. * See ...
  72588. * Note that you can only store up to 5 of them
  72589. */
  72590. ssDiffusionProfileColors: Color3[];
  72591. /**
  72592. * Defines the ratio real world => scene units.
  72593. * Used for subsurface scattering
  72594. */
  72595. metersPerUnit: number;
  72596. /**
  72597. * Textures that should be present in the MRT for this effect to work
  72598. */
  72599. readonly texturesRequired: number[];
  72600. private _scene;
  72601. /**
  72602. * Builds a subsurface configuration object
  72603. * @param scene The scene
  72604. */
  72605. constructor(scene: Scene);
  72606. /**
  72607. * Adds a new diffusion profile.
  72608. * Useful for more realistic subsurface scattering on diverse materials.
  72609. * @param color The color of the diffusion profile. Should be the average color of the material.
  72610. * @return The index of the diffusion profile for the material subsurface configuration
  72611. */
  72612. addDiffusionProfile(color: Color3): number;
  72613. /**
  72614. * Creates the sss post process
  72615. * @return The created post process
  72616. */
  72617. createPostProcess(): SubSurfaceScatteringPostProcess;
  72618. /**
  72619. * Deletes all diffusion profiles.
  72620. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  72621. */
  72622. clearAllDiffusionProfiles(): void;
  72623. /**
  72624. * Disposes this object
  72625. */
  72626. dispose(): void;
  72627. /**
  72628. * @hidden
  72629. * https://zero-radiance.github.io/post/sampling-diffusion/
  72630. *
  72631. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  72632. * ------------------------------------------------------------------------------------
  72633. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  72634. * PDF[r, phi, s] = r * R[r, phi, s]
  72635. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  72636. * ------------------------------------------------------------------------------------
  72637. * We importance sample the color channel with the widest scattering distance.
  72638. */
  72639. getDiffusionProfileParameters(color: Color3): number;
  72640. /**
  72641. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  72642. * 'u' is the random number (the value of the CDF): [0, 1).
  72643. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  72644. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  72645. */
  72646. private _sampleBurleyDiffusionProfile;
  72647. }
  72648. }
  72649. declare module BABYLON {
  72650. interface AbstractScene {
  72651. /** @hidden (Backing field) */
  72652. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  72653. /**
  72654. * Gets or Sets the current prepass renderer associated to the scene.
  72655. */
  72656. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  72657. /**
  72658. * Enables the subsurface effect for prepass
  72659. * @returns the SubSurfaceConfiguration
  72660. */
  72661. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  72662. /**
  72663. * Disables the subsurface effect for prepass
  72664. */
  72665. disableSubSurfaceForPrePass(): void;
  72666. }
  72667. /**
  72668. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  72669. * in several rendering techniques.
  72670. */
  72671. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  72672. /**
  72673. * The component name helpful to identify the component in the list of scene components.
  72674. */
  72675. readonly name: string;
  72676. /**
  72677. * The scene the component belongs to.
  72678. */
  72679. scene: Scene;
  72680. /**
  72681. * Creates a new instance of the component for the given scene
  72682. * @param scene Defines the scene to register the component in
  72683. */
  72684. constructor(scene: Scene);
  72685. /**
  72686. * Registers the component in a given scene
  72687. */
  72688. register(): void;
  72689. /**
  72690. * Serializes the component data to the specified json object
  72691. * @param serializationObject The object to serialize to
  72692. */
  72693. serialize(serializationObject: any): void;
  72694. /**
  72695. * Adds all the elements from the container to the scene
  72696. * @param container the container holding the elements
  72697. */
  72698. addFromContainer(container: AbstractScene): void;
  72699. /**
  72700. * Removes all the elements in the container from the scene
  72701. * @param container contains the elements to remove
  72702. * @param dispose if the removed element should be disposed (default: false)
  72703. */
  72704. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  72705. /**
  72706. * Rebuilds the elements related to this component in case of
  72707. * context lost for instance.
  72708. */
  72709. rebuild(): void;
  72710. /**
  72711. * Disposes the component and the associated ressources
  72712. */
  72713. dispose(): void;
  72714. }
  72715. }
  72716. declare module BABYLON {
  72717. /** @hidden */
  72718. export var outlinePixelShader: {
  72719. name: string;
  72720. shader: string;
  72721. };
  72722. }
  72723. declare module BABYLON {
  72724. /** @hidden */
  72725. export var outlineVertexShader: {
  72726. name: string;
  72727. shader: string;
  72728. };
  72729. }
  72730. declare module BABYLON {
  72731. interface Scene {
  72732. /** @hidden */
  72733. _outlineRenderer: OutlineRenderer;
  72734. /**
  72735. * Gets the outline renderer associated with the scene
  72736. * @returns a OutlineRenderer
  72737. */
  72738. getOutlineRenderer(): OutlineRenderer;
  72739. }
  72740. interface AbstractMesh {
  72741. /** @hidden (Backing field) */
  72742. _renderOutline: boolean;
  72743. /**
  72744. * Gets or sets a boolean indicating if the outline must be rendered as well
  72745. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  72746. */
  72747. renderOutline: boolean;
  72748. /** @hidden (Backing field) */
  72749. _renderOverlay: boolean;
  72750. /**
  72751. * Gets or sets a boolean indicating if the overlay must be rendered as well
  72752. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  72753. */
  72754. renderOverlay: boolean;
  72755. }
  72756. /**
  72757. * This class is responsible to draw bothe outline/overlay of meshes.
  72758. * It should not be used directly but through the available method on mesh.
  72759. */
  72760. export class OutlineRenderer implements ISceneComponent {
  72761. /**
  72762. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  72763. */
  72764. private static _StencilReference;
  72765. /**
  72766. * The name of the component. Each component must have a unique name.
  72767. */
  72768. name: string;
  72769. /**
  72770. * The scene the component belongs to.
  72771. */
  72772. scene: Scene;
  72773. /**
  72774. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  72775. */
  72776. zOffset: number;
  72777. private _engine;
  72778. private _effect;
  72779. private _cachedDefines;
  72780. private _savedDepthWrite;
  72781. /**
  72782. * Instantiates a new outline renderer. (There could be only one per scene).
  72783. * @param scene Defines the scene it belongs to
  72784. */
  72785. constructor(scene: Scene);
  72786. /**
  72787. * Register the component to one instance of a scene.
  72788. */
  72789. register(): void;
  72790. /**
  72791. * Rebuilds the elements related to this component in case of
  72792. * context lost for instance.
  72793. */
  72794. rebuild(): void;
  72795. /**
  72796. * Disposes the component and the associated ressources.
  72797. */
  72798. dispose(): void;
  72799. /**
  72800. * Renders the outline in the canvas.
  72801. * @param subMesh Defines the sumesh to render
  72802. * @param batch Defines the batch of meshes in case of instances
  72803. * @param useOverlay Defines if the rendering is for the overlay or the outline
  72804. */
  72805. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  72806. /**
  72807. * Returns whether or not the outline renderer is ready for a given submesh.
  72808. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  72809. * @param subMesh Defines the submesh to check readyness for
  72810. * @param useInstances Defines wheter wee are trying to render instances or not
  72811. * @returns true if ready otherwise false
  72812. */
  72813. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  72814. private _beforeRenderingMesh;
  72815. private _afterRenderingMesh;
  72816. }
  72817. }
  72818. declare module BABYLON {
  72819. /**
  72820. * Defines the basic options interface of a Sprite Frame Source Size.
  72821. */
  72822. export interface ISpriteJSONSpriteSourceSize {
  72823. /**
  72824. * number of the original width of the Frame
  72825. */
  72826. w: number;
  72827. /**
  72828. * number of the original height of the Frame
  72829. */
  72830. h: number;
  72831. }
  72832. /**
  72833. * Defines the basic options interface of a Sprite Frame Data.
  72834. */
  72835. export interface ISpriteJSONSpriteFrameData {
  72836. /**
  72837. * number of the x offset of the Frame
  72838. */
  72839. x: number;
  72840. /**
  72841. * number of the y offset of the Frame
  72842. */
  72843. y: number;
  72844. /**
  72845. * number of the width of the Frame
  72846. */
  72847. w: number;
  72848. /**
  72849. * number of the height of the Frame
  72850. */
  72851. h: number;
  72852. }
  72853. /**
  72854. * Defines the basic options interface of a JSON Sprite.
  72855. */
  72856. export interface ISpriteJSONSprite {
  72857. /**
  72858. * string name of the Frame
  72859. */
  72860. filename: string;
  72861. /**
  72862. * ISpriteJSONSpriteFrame basic object of the frame data
  72863. */
  72864. frame: ISpriteJSONSpriteFrameData;
  72865. /**
  72866. * boolean to flag is the frame was rotated.
  72867. */
  72868. rotated: boolean;
  72869. /**
  72870. * boolean to flag is the frame was trimmed.
  72871. */
  72872. trimmed: boolean;
  72873. /**
  72874. * ISpriteJSONSpriteFrame basic object of the source data
  72875. */
  72876. spriteSourceSize: ISpriteJSONSpriteFrameData;
  72877. /**
  72878. * ISpriteJSONSpriteFrame basic object of the source data
  72879. */
  72880. sourceSize: ISpriteJSONSpriteSourceSize;
  72881. }
  72882. /**
  72883. * Defines the basic options interface of a JSON atlas.
  72884. */
  72885. export interface ISpriteJSONAtlas {
  72886. /**
  72887. * Array of objects that contain the frame data.
  72888. */
  72889. frames: Array<ISpriteJSONSprite>;
  72890. /**
  72891. * object basic object containing the sprite meta data.
  72892. */
  72893. meta?: object;
  72894. }
  72895. }
  72896. declare module BABYLON {
  72897. /** @hidden */
  72898. export var spriteMapPixelShader: {
  72899. name: string;
  72900. shader: string;
  72901. };
  72902. }
  72903. declare module BABYLON {
  72904. /** @hidden */
  72905. export var spriteMapVertexShader: {
  72906. name: string;
  72907. shader: string;
  72908. };
  72909. }
  72910. declare module BABYLON {
  72911. /**
  72912. * Defines the basic options interface of a SpriteMap
  72913. */
  72914. export interface ISpriteMapOptions {
  72915. /**
  72916. * Vector2 of the number of cells in the grid.
  72917. */
  72918. stageSize?: Vector2;
  72919. /**
  72920. * Vector2 of the size of the output plane in World Units.
  72921. */
  72922. outputSize?: Vector2;
  72923. /**
  72924. * Vector3 of the position of the output plane in World Units.
  72925. */
  72926. outputPosition?: Vector3;
  72927. /**
  72928. * Vector3 of the rotation of the output plane.
  72929. */
  72930. outputRotation?: Vector3;
  72931. /**
  72932. * number of layers that the system will reserve in resources.
  72933. */
  72934. layerCount?: number;
  72935. /**
  72936. * number of max animation frames a single cell will reserve in resources.
  72937. */
  72938. maxAnimationFrames?: number;
  72939. /**
  72940. * number cell index of the base tile when the system compiles.
  72941. */
  72942. baseTile?: number;
  72943. /**
  72944. * boolean flip the sprite after its been repositioned by the framing data.
  72945. */
  72946. flipU?: boolean;
  72947. /**
  72948. * Vector3 scalar of the global RGB values of the SpriteMap.
  72949. */
  72950. colorMultiply?: Vector3;
  72951. }
  72952. /**
  72953. * Defines the IDisposable interface in order to be cleanable from resources.
  72954. */
  72955. export interface ISpriteMap extends IDisposable {
  72956. /**
  72957. * String name of the SpriteMap.
  72958. */
  72959. name: string;
  72960. /**
  72961. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  72962. */
  72963. atlasJSON: ISpriteJSONAtlas;
  72964. /**
  72965. * Texture of the SpriteMap.
  72966. */
  72967. spriteSheet: Texture;
  72968. /**
  72969. * The parameters to initialize the SpriteMap with.
  72970. */
  72971. options: ISpriteMapOptions;
  72972. }
  72973. /**
  72974. * Class used to manage a grid restricted sprite deployment on an Output plane.
  72975. */
  72976. export class SpriteMap implements ISpriteMap {
  72977. /** The Name of the spriteMap */
  72978. name: string;
  72979. /** The JSON file with the frame and meta data */
  72980. atlasJSON: ISpriteJSONAtlas;
  72981. /** The systems Sprite Sheet Texture */
  72982. spriteSheet: Texture;
  72983. /** Arguments passed with the Constructor */
  72984. options: ISpriteMapOptions;
  72985. /** Public Sprite Storage array, parsed from atlasJSON */
  72986. sprites: Array<ISpriteJSONSprite>;
  72987. /** Returns the Number of Sprites in the System */
  72988. get spriteCount(): number;
  72989. /** Returns the Position of Output Plane*/
  72990. get position(): Vector3;
  72991. /** Returns the Position of Output Plane*/
  72992. set position(v: Vector3);
  72993. /** Returns the Rotation of Output Plane*/
  72994. get rotation(): Vector3;
  72995. /** Returns the Rotation of Output Plane*/
  72996. set rotation(v: Vector3);
  72997. /** Sets the AnimationMap*/
  72998. get animationMap(): RawTexture;
  72999. /** Sets the AnimationMap*/
  73000. set animationMap(v: RawTexture);
  73001. /** Scene that the SpriteMap was created in */
  73002. private _scene;
  73003. /** Texture Buffer of Float32 that holds tile frame data*/
  73004. private _frameMap;
  73005. /** Texture Buffers of Float32 that holds tileMap data*/
  73006. private _tileMaps;
  73007. /** Texture Buffer of Float32 that holds Animation Data*/
  73008. private _animationMap;
  73009. /** Custom ShaderMaterial Central to the System*/
  73010. private _material;
  73011. /** Custom ShaderMaterial Central to the System*/
  73012. private _output;
  73013. /** Systems Time Ticker*/
  73014. private _time;
  73015. /**
  73016. * Creates a new SpriteMap
  73017. * @param name defines the SpriteMaps Name
  73018. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  73019. * @param spriteSheet is the Texture that the Sprites are on.
  73020. * @param options a basic deployment configuration
  73021. * @param scene The Scene that the map is deployed on
  73022. */
  73023. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  73024. /**
  73025. * Returns tileID location
  73026. * @returns Vector2 the cell position ID
  73027. */
  73028. getTileID(): Vector2;
  73029. /**
  73030. * Gets the UV location of the mouse over the SpriteMap.
  73031. * @returns Vector2 the UV position of the mouse interaction
  73032. */
  73033. getMousePosition(): Vector2;
  73034. /**
  73035. * Creates the "frame" texture Buffer
  73036. * -------------------------------------
  73037. * Structure of frames
  73038. * "filename": "Falling-Water-2.png",
  73039. * "frame": {"x":69,"y":103,"w":24,"h":32},
  73040. * "rotated": true,
  73041. * "trimmed": true,
  73042. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  73043. * "sourceSize": {"w":32,"h":32}
  73044. * @returns RawTexture of the frameMap
  73045. */
  73046. private _createFrameBuffer;
  73047. /**
  73048. * Creates the tileMap texture Buffer
  73049. * @param buffer normally and array of numbers, or a false to generate from scratch
  73050. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  73051. * @returns RawTexture of the tileMap
  73052. */
  73053. private _createTileBuffer;
  73054. /**
  73055. * Modifies the data of the tileMaps
  73056. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  73057. * @param pos is the iVector2 Coordinates of the Tile
  73058. * @param tile The SpriteIndex of the new Tile
  73059. */
  73060. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  73061. /**
  73062. * Creates the animationMap texture Buffer
  73063. * @param buffer normally and array of numbers, or a false to generate from scratch
  73064. * @returns RawTexture of the animationMap
  73065. */
  73066. private _createTileAnimationBuffer;
  73067. /**
  73068. * Modifies the data of the animationMap
  73069. * @param cellID is the Index of the Sprite
  73070. * @param _frame is the target Animation frame
  73071. * @param toCell is the Target Index of the next frame of the animation
  73072. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  73073. * @param speed is a global scalar of the time variable on the map.
  73074. */
  73075. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  73076. /**
  73077. * Exports the .tilemaps file
  73078. */
  73079. saveTileMaps(): void;
  73080. /**
  73081. * Imports the .tilemaps file
  73082. * @param url of the .tilemaps file
  73083. */
  73084. loadTileMaps(url: string): void;
  73085. /**
  73086. * Release associated resources
  73087. */
  73088. dispose(): void;
  73089. }
  73090. }
  73091. declare module BABYLON {
  73092. /**
  73093. * Class used to manage multiple sprites of different sizes on the same spritesheet
  73094. * @see https://doc.babylonjs.com/babylon101/sprites
  73095. */
  73096. export class SpritePackedManager extends SpriteManager {
  73097. /** defines the packed manager's name */
  73098. name: string;
  73099. /**
  73100. * Creates a new sprite manager from a packed sprite sheet
  73101. * @param name defines the manager's name
  73102. * @param imgUrl defines the sprite sheet url
  73103. * @param capacity defines the maximum allowed number of sprites
  73104. * @param scene defines the hosting scene
  73105. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  73106. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  73107. * @param samplingMode defines the smapling mode to use with spritesheet
  73108. * @param fromPacked set to true; do not alter
  73109. */
  73110. constructor(
  73111. /** defines the packed manager's name */
  73112. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  73113. }
  73114. }
  73115. declare module BABYLON {
  73116. /**
  73117. * Defines the list of states available for a task inside a AssetsManager
  73118. */
  73119. export enum AssetTaskState {
  73120. /**
  73121. * Initialization
  73122. */
  73123. INIT = 0,
  73124. /**
  73125. * Running
  73126. */
  73127. RUNNING = 1,
  73128. /**
  73129. * Done
  73130. */
  73131. DONE = 2,
  73132. /**
  73133. * Error
  73134. */
  73135. ERROR = 3
  73136. }
  73137. /**
  73138. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  73139. */
  73140. export abstract class AbstractAssetTask {
  73141. /**
  73142. * Task name
  73143. */ name: string;
  73144. /**
  73145. * Callback called when the task is successful
  73146. */
  73147. onSuccess: (task: any) => void;
  73148. /**
  73149. * Callback called when the task is not successful
  73150. */
  73151. onError: (task: any, message?: string, exception?: any) => void;
  73152. /**
  73153. * Creates a new AssetsManager
  73154. * @param name defines the name of the task
  73155. */
  73156. constructor(
  73157. /**
  73158. * Task name
  73159. */ name: string);
  73160. private _isCompleted;
  73161. private _taskState;
  73162. private _errorObject;
  73163. /**
  73164. * Get if the task is completed
  73165. */
  73166. get isCompleted(): boolean;
  73167. /**
  73168. * Gets the current state of the task
  73169. */
  73170. get taskState(): AssetTaskState;
  73171. /**
  73172. * Gets the current error object (if task is in error)
  73173. */
  73174. get errorObject(): {
  73175. message?: string;
  73176. exception?: any;
  73177. };
  73178. /**
  73179. * Internal only
  73180. * @hidden
  73181. */
  73182. _setErrorObject(message?: string, exception?: any): void;
  73183. /**
  73184. * Execute the current task
  73185. * @param scene defines the scene where you want your assets to be loaded
  73186. * @param onSuccess is a callback called when the task is successfully executed
  73187. * @param onError is a callback called if an error occurs
  73188. */
  73189. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73190. /**
  73191. * Execute the current task
  73192. * @param scene defines the scene where you want your assets to be loaded
  73193. * @param onSuccess is a callback called when the task is successfully executed
  73194. * @param onError is a callback called if an error occurs
  73195. */
  73196. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73197. /**
  73198. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  73199. * This can be used with failed tasks that have the reason for failure fixed.
  73200. */
  73201. reset(): void;
  73202. private onErrorCallback;
  73203. private onDoneCallback;
  73204. }
  73205. /**
  73206. * Define the interface used by progress events raised during assets loading
  73207. */
  73208. export interface IAssetsProgressEvent {
  73209. /**
  73210. * Defines the number of remaining tasks to process
  73211. */
  73212. remainingCount: number;
  73213. /**
  73214. * Defines the total number of tasks
  73215. */
  73216. totalCount: number;
  73217. /**
  73218. * Defines the task that was just processed
  73219. */
  73220. task: AbstractAssetTask;
  73221. }
  73222. /**
  73223. * Class used to share progress information about assets loading
  73224. */
  73225. export class AssetsProgressEvent implements IAssetsProgressEvent {
  73226. /**
  73227. * Defines the number of remaining tasks to process
  73228. */
  73229. remainingCount: number;
  73230. /**
  73231. * Defines the total number of tasks
  73232. */
  73233. totalCount: number;
  73234. /**
  73235. * Defines the task that was just processed
  73236. */
  73237. task: AbstractAssetTask;
  73238. /**
  73239. * Creates a AssetsProgressEvent
  73240. * @param remainingCount defines the number of remaining tasks to process
  73241. * @param totalCount defines the total number of tasks
  73242. * @param task defines the task that was just processed
  73243. */
  73244. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  73245. }
  73246. /**
  73247. * Define a task used by AssetsManager to load assets into a container
  73248. */
  73249. export class ContainerAssetTask extends AbstractAssetTask {
  73250. /**
  73251. * Defines the name of the task
  73252. */
  73253. name: string;
  73254. /**
  73255. * Defines the list of mesh's names you want to load
  73256. */
  73257. meshesNames: any;
  73258. /**
  73259. * Defines the root url to use as a base to load your meshes and associated resources
  73260. */
  73261. rootUrl: string;
  73262. /**
  73263. * Defines the filename or File of the scene to load from
  73264. */
  73265. sceneFilename: string | File;
  73266. /**
  73267. * Get the loaded asset container
  73268. */
  73269. loadedContainer: AssetContainer;
  73270. /**
  73271. * Gets the list of loaded meshes
  73272. */
  73273. loadedMeshes: Array<AbstractMesh>;
  73274. /**
  73275. * Gets the list of loaded particle systems
  73276. */
  73277. loadedParticleSystems: Array<IParticleSystem>;
  73278. /**
  73279. * Gets the list of loaded skeletons
  73280. */
  73281. loadedSkeletons: Array<Skeleton>;
  73282. /**
  73283. * Gets the list of loaded animation groups
  73284. */
  73285. loadedAnimationGroups: Array<AnimationGroup>;
  73286. /**
  73287. * Callback called when the task is successful
  73288. */
  73289. onSuccess: (task: ContainerAssetTask) => void;
  73290. /**
  73291. * Callback called when the task is successful
  73292. */
  73293. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  73294. /**
  73295. * Creates a new ContainerAssetTask
  73296. * @param name defines the name of the task
  73297. * @param meshesNames defines the list of mesh's names you want to load
  73298. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  73299. * @param sceneFilename defines the filename or File of the scene to load from
  73300. */
  73301. constructor(
  73302. /**
  73303. * Defines the name of the task
  73304. */
  73305. name: string,
  73306. /**
  73307. * Defines the list of mesh's names you want to load
  73308. */
  73309. meshesNames: any,
  73310. /**
  73311. * Defines the root url to use as a base to load your meshes and associated resources
  73312. */
  73313. rootUrl: string,
  73314. /**
  73315. * Defines the filename or File of the scene to load from
  73316. */
  73317. sceneFilename: string | File);
  73318. /**
  73319. * Execute the current task
  73320. * @param scene defines the scene where you want your assets to be loaded
  73321. * @param onSuccess is a callback called when the task is successfully executed
  73322. * @param onError is a callback called if an error occurs
  73323. */
  73324. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73325. }
  73326. /**
  73327. * Define a task used by AssetsManager to load meshes
  73328. */
  73329. export class MeshAssetTask extends AbstractAssetTask {
  73330. /**
  73331. * Defines the name of the task
  73332. */
  73333. name: string;
  73334. /**
  73335. * Defines the list of mesh's names you want to load
  73336. */
  73337. meshesNames: any;
  73338. /**
  73339. * Defines the root url to use as a base to load your meshes and associated resources
  73340. */
  73341. rootUrl: string;
  73342. /**
  73343. * Defines the filename or File of the scene to load from
  73344. */
  73345. sceneFilename: string | File;
  73346. /**
  73347. * Gets the list of loaded meshes
  73348. */
  73349. loadedMeshes: Array<AbstractMesh>;
  73350. /**
  73351. * Gets the list of loaded particle systems
  73352. */
  73353. loadedParticleSystems: Array<IParticleSystem>;
  73354. /**
  73355. * Gets the list of loaded skeletons
  73356. */
  73357. loadedSkeletons: Array<Skeleton>;
  73358. /**
  73359. * Gets the list of loaded animation groups
  73360. */
  73361. loadedAnimationGroups: Array<AnimationGroup>;
  73362. /**
  73363. * Callback called when the task is successful
  73364. */
  73365. onSuccess: (task: MeshAssetTask) => void;
  73366. /**
  73367. * Callback called when the task is successful
  73368. */
  73369. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  73370. /**
  73371. * Creates a new MeshAssetTask
  73372. * @param name defines the name of the task
  73373. * @param meshesNames defines the list of mesh's names you want to load
  73374. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  73375. * @param sceneFilename defines the filename or File of the scene to load from
  73376. */
  73377. constructor(
  73378. /**
  73379. * Defines the name of the task
  73380. */
  73381. name: string,
  73382. /**
  73383. * Defines the list of mesh's names you want to load
  73384. */
  73385. meshesNames: any,
  73386. /**
  73387. * Defines the root url to use as a base to load your meshes and associated resources
  73388. */
  73389. rootUrl: string,
  73390. /**
  73391. * Defines the filename or File of the scene to load from
  73392. */
  73393. sceneFilename: string | File);
  73394. /**
  73395. * Execute the current task
  73396. * @param scene defines the scene where you want your assets to be loaded
  73397. * @param onSuccess is a callback called when the task is successfully executed
  73398. * @param onError is a callback called if an error occurs
  73399. */
  73400. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73401. }
  73402. /**
  73403. * Define a task used by AssetsManager to load text content
  73404. */
  73405. export class TextFileAssetTask extends AbstractAssetTask {
  73406. /**
  73407. * Defines the name of the task
  73408. */
  73409. name: string;
  73410. /**
  73411. * Defines the location of the file to load
  73412. */
  73413. url: string;
  73414. /**
  73415. * Gets the loaded text string
  73416. */
  73417. text: string;
  73418. /**
  73419. * Callback called when the task is successful
  73420. */
  73421. onSuccess: (task: TextFileAssetTask) => void;
  73422. /**
  73423. * Callback called when the task is successful
  73424. */
  73425. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  73426. /**
  73427. * Creates a new TextFileAssetTask object
  73428. * @param name defines the name of the task
  73429. * @param url defines the location of the file to load
  73430. */
  73431. constructor(
  73432. /**
  73433. * Defines the name of the task
  73434. */
  73435. name: string,
  73436. /**
  73437. * Defines the location of the file to load
  73438. */
  73439. url: string);
  73440. /**
  73441. * Execute the current task
  73442. * @param scene defines the scene where you want your assets to be loaded
  73443. * @param onSuccess is a callback called when the task is successfully executed
  73444. * @param onError is a callback called if an error occurs
  73445. */
  73446. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73447. }
  73448. /**
  73449. * Define a task used by AssetsManager to load binary data
  73450. */
  73451. export class BinaryFileAssetTask extends AbstractAssetTask {
  73452. /**
  73453. * Defines the name of the task
  73454. */
  73455. name: string;
  73456. /**
  73457. * Defines the location of the file to load
  73458. */
  73459. url: string;
  73460. /**
  73461. * Gets the lodaded data (as an array buffer)
  73462. */
  73463. data: ArrayBuffer;
  73464. /**
  73465. * Callback called when the task is successful
  73466. */
  73467. onSuccess: (task: BinaryFileAssetTask) => void;
  73468. /**
  73469. * Callback called when the task is successful
  73470. */
  73471. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  73472. /**
  73473. * Creates a new BinaryFileAssetTask object
  73474. * @param name defines the name of the new task
  73475. * @param url defines the location of the file to load
  73476. */
  73477. constructor(
  73478. /**
  73479. * Defines the name of the task
  73480. */
  73481. name: string,
  73482. /**
  73483. * Defines the location of the file to load
  73484. */
  73485. url: string);
  73486. /**
  73487. * Execute the current task
  73488. * @param scene defines the scene where you want your assets to be loaded
  73489. * @param onSuccess is a callback called when the task is successfully executed
  73490. * @param onError is a callback called if an error occurs
  73491. */
  73492. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73493. }
  73494. /**
  73495. * Define a task used by AssetsManager to load images
  73496. */
  73497. export class ImageAssetTask extends AbstractAssetTask {
  73498. /**
  73499. * Defines the name of the task
  73500. */
  73501. name: string;
  73502. /**
  73503. * Defines the location of the image to load
  73504. */
  73505. url: string;
  73506. /**
  73507. * Gets the loaded images
  73508. */
  73509. image: HTMLImageElement;
  73510. /**
  73511. * Callback called when the task is successful
  73512. */
  73513. onSuccess: (task: ImageAssetTask) => void;
  73514. /**
  73515. * Callback called when the task is successful
  73516. */
  73517. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  73518. /**
  73519. * Creates a new ImageAssetTask
  73520. * @param name defines the name of the task
  73521. * @param url defines the location of the image to load
  73522. */
  73523. constructor(
  73524. /**
  73525. * Defines the name of the task
  73526. */
  73527. name: string,
  73528. /**
  73529. * Defines the location of the image to load
  73530. */
  73531. url: string);
  73532. /**
  73533. * Execute the current task
  73534. * @param scene defines the scene where you want your assets to be loaded
  73535. * @param onSuccess is a callback called when the task is successfully executed
  73536. * @param onError is a callback called if an error occurs
  73537. */
  73538. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73539. }
  73540. /**
  73541. * Defines the interface used by texture loading tasks
  73542. */
  73543. export interface ITextureAssetTask<TEX extends BaseTexture> {
  73544. /**
  73545. * Gets the loaded texture
  73546. */
  73547. texture: TEX;
  73548. }
  73549. /**
  73550. * Define a task used by AssetsManager to load 2D textures
  73551. */
  73552. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  73553. /**
  73554. * Defines the name of the task
  73555. */
  73556. name: string;
  73557. /**
  73558. * Defines the location of the file to load
  73559. */
  73560. url: string;
  73561. /**
  73562. * Defines if mipmap should not be generated (default is false)
  73563. */
  73564. noMipmap?: boolean | undefined;
  73565. /**
  73566. * Defines if texture must be inverted on Y axis (default is true)
  73567. */
  73568. invertY: boolean;
  73569. /**
  73570. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  73571. */
  73572. samplingMode: number;
  73573. /**
  73574. * Gets the loaded texture
  73575. */
  73576. texture: Texture;
  73577. /**
  73578. * Callback called when the task is successful
  73579. */
  73580. onSuccess: (task: TextureAssetTask) => void;
  73581. /**
  73582. * Callback called when the task is successful
  73583. */
  73584. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  73585. /**
  73586. * Creates a new TextureAssetTask object
  73587. * @param name defines the name of the task
  73588. * @param url defines the location of the file to load
  73589. * @param noMipmap defines if mipmap should not be generated (default is false)
  73590. * @param invertY defines if texture must be inverted on Y axis (default is true)
  73591. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  73592. */
  73593. constructor(
  73594. /**
  73595. * Defines the name of the task
  73596. */
  73597. name: string,
  73598. /**
  73599. * Defines the location of the file to load
  73600. */
  73601. url: string,
  73602. /**
  73603. * Defines if mipmap should not be generated (default is false)
  73604. */
  73605. noMipmap?: boolean | undefined,
  73606. /**
  73607. * Defines if texture must be inverted on Y axis (default is true)
  73608. */
  73609. invertY?: boolean,
  73610. /**
  73611. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  73612. */
  73613. samplingMode?: number);
  73614. /**
  73615. * Execute the current task
  73616. * @param scene defines the scene where you want your assets to be loaded
  73617. * @param onSuccess is a callback called when the task is successfully executed
  73618. * @param onError is a callback called if an error occurs
  73619. */
  73620. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73621. }
  73622. /**
  73623. * Define a task used by AssetsManager to load cube textures
  73624. */
  73625. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  73626. /**
  73627. * Defines the name of the task
  73628. */
  73629. name: string;
  73630. /**
  73631. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  73632. */
  73633. url: string;
  73634. /**
  73635. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  73636. */
  73637. extensions?: string[] | undefined;
  73638. /**
  73639. * Defines if mipmaps should not be generated (default is false)
  73640. */
  73641. noMipmap?: boolean | undefined;
  73642. /**
  73643. * Defines the explicit list of files (undefined by default)
  73644. */
  73645. files?: string[] | undefined;
  73646. /**
  73647. * Gets the loaded texture
  73648. */
  73649. texture: CubeTexture;
  73650. /**
  73651. * Callback called when the task is successful
  73652. */
  73653. onSuccess: (task: CubeTextureAssetTask) => void;
  73654. /**
  73655. * Callback called when the task is successful
  73656. */
  73657. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  73658. /**
  73659. * Creates a new CubeTextureAssetTask
  73660. * @param name defines the name of the task
  73661. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  73662. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  73663. * @param noMipmap defines if mipmaps should not be generated (default is false)
  73664. * @param files defines the explicit list of files (undefined by default)
  73665. */
  73666. constructor(
  73667. /**
  73668. * Defines the name of the task
  73669. */
  73670. name: string,
  73671. /**
  73672. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  73673. */
  73674. url: string,
  73675. /**
  73676. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  73677. */
  73678. extensions?: string[] | undefined,
  73679. /**
  73680. * Defines if mipmaps should not be generated (default is false)
  73681. */
  73682. noMipmap?: boolean | undefined,
  73683. /**
  73684. * Defines the explicit list of files (undefined by default)
  73685. */
  73686. files?: string[] | undefined);
  73687. /**
  73688. * Execute the current task
  73689. * @param scene defines the scene where you want your assets to be loaded
  73690. * @param onSuccess is a callback called when the task is successfully executed
  73691. * @param onError is a callback called if an error occurs
  73692. */
  73693. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73694. }
  73695. /**
  73696. * Define a task used by AssetsManager to load HDR cube textures
  73697. */
  73698. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  73699. /**
  73700. * Defines the name of the task
  73701. */
  73702. name: string;
  73703. /**
  73704. * Defines the location of the file to load
  73705. */
  73706. url: string;
  73707. /**
  73708. * Defines the desired size (the more it increases the longer the generation will be)
  73709. */
  73710. size: number;
  73711. /**
  73712. * Defines if mipmaps should not be generated (default is false)
  73713. */
  73714. noMipmap: boolean;
  73715. /**
  73716. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  73717. */
  73718. generateHarmonics: boolean;
  73719. /**
  73720. * 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)
  73721. */
  73722. gammaSpace: boolean;
  73723. /**
  73724. * Internal Use Only
  73725. */
  73726. reserved: boolean;
  73727. /**
  73728. * Gets the loaded texture
  73729. */
  73730. texture: HDRCubeTexture;
  73731. /**
  73732. * Callback called when the task is successful
  73733. */
  73734. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  73735. /**
  73736. * Callback called when the task is successful
  73737. */
  73738. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  73739. /**
  73740. * Creates a new HDRCubeTextureAssetTask object
  73741. * @param name defines the name of the task
  73742. * @param url defines the location of the file to load
  73743. * @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.
  73744. * @param noMipmap defines if mipmaps should not be generated (default is false)
  73745. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  73746. * @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)
  73747. * @param reserved Internal use only
  73748. */
  73749. constructor(
  73750. /**
  73751. * Defines the name of the task
  73752. */
  73753. name: string,
  73754. /**
  73755. * Defines the location of the file to load
  73756. */
  73757. url: string,
  73758. /**
  73759. * Defines the desired size (the more it increases the longer the generation will be)
  73760. */
  73761. size: number,
  73762. /**
  73763. * Defines if mipmaps should not be generated (default is false)
  73764. */
  73765. noMipmap?: boolean,
  73766. /**
  73767. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  73768. */
  73769. generateHarmonics?: boolean,
  73770. /**
  73771. * 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)
  73772. */
  73773. gammaSpace?: boolean,
  73774. /**
  73775. * Internal Use Only
  73776. */
  73777. reserved?: boolean);
  73778. /**
  73779. * Execute the current task
  73780. * @param scene defines the scene where you want your assets to be loaded
  73781. * @param onSuccess is a callback called when the task is successfully executed
  73782. * @param onError is a callback called if an error occurs
  73783. */
  73784. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73785. }
  73786. /**
  73787. * Define a task used by AssetsManager to load Equirectangular cube textures
  73788. */
  73789. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  73790. /**
  73791. * Defines the name of the task
  73792. */
  73793. name: string;
  73794. /**
  73795. * Defines the location of the file to load
  73796. */
  73797. url: string;
  73798. /**
  73799. * Defines the desired size (the more it increases the longer the generation will be)
  73800. */
  73801. size: number;
  73802. /**
  73803. * Defines if mipmaps should not be generated (default is false)
  73804. */
  73805. noMipmap: boolean;
  73806. /**
  73807. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  73808. * but the standard material would require them in Gamma space) (default is true)
  73809. */
  73810. gammaSpace: boolean;
  73811. /**
  73812. * Gets the loaded texture
  73813. */
  73814. texture: EquiRectangularCubeTexture;
  73815. /**
  73816. * Callback called when the task is successful
  73817. */
  73818. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  73819. /**
  73820. * Callback called when the task is successful
  73821. */
  73822. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  73823. /**
  73824. * Creates a new EquiRectangularCubeTextureAssetTask object
  73825. * @param name defines the name of the task
  73826. * @param url defines the location of the file to load
  73827. * @param size defines the desired size (the more it increases the longer the generation will be)
  73828. * If the size is omitted this implies you are using a preprocessed cubemap.
  73829. * @param noMipmap defines if mipmaps should not be generated (default is false)
  73830. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  73831. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  73832. * (default is true)
  73833. */
  73834. constructor(
  73835. /**
  73836. * Defines the name of the task
  73837. */
  73838. name: string,
  73839. /**
  73840. * Defines the location of the file to load
  73841. */
  73842. url: string,
  73843. /**
  73844. * Defines the desired size (the more it increases the longer the generation will be)
  73845. */
  73846. size: number,
  73847. /**
  73848. * Defines if mipmaps should not be generated (default is false)
  73849. */
  73850. noMipmap?: boolean,
  73851. /**
  73852. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  73853. * but the standard material would require them in Gamma space) (default is true)
  73854. */
  73855. gammaSpace?: boolean);
  73856. /**
  73857. * Execute the current task
  73858. * @param scene defines the scene where you want your assets to be loaded
  73859. * @param onSuccess is a callback called when the task is successfully executed
  73860. * @param onError is a callback called if an error occurs
  73861. */
  73862. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  73863. }
  73864. /**
  73865. * This class can be used to easily import assets into a scene
  73866. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  73867. */
  73868. export class AssetsManager {
  73869. private _scene;
  73870. private _isLoading;
  73871. protected _tasks: AbstractAssetTask[];
  73872. protected _waitingTasksCount: number;
  73873. protected _totalTasksCount: number;
  73874. /**
  73875. * Callback called when all tasks are processed
  73876. */
  73877. onFinish: (tasks: AbstractAssetTask[]) => void;
  73878. /**
  73879. * Callback called when a task is successful
  73880. */
  73881. onTaskSuccess: (task: AbstractAssetTask) => void;
  73882. /**
  73883. * Callback called when a task had an error
  73884. */
  73885. onTaskError: (task: AbstractAssetTask) => void;
  73886. /**
  73887. * Callback called when a task is done (whatever the result is)
  73888. */
  73889. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  73890. /**
  73891. * Observable called when all tasks are processed
  73892. */
  73893. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  73894. /**
  73895. * Observable called when a task had an error
  73896. */
  73897. onTaskErrorObservable: Observable<AbstractAssetTask>;
  73898. /**
  73899. * Observable called when all tasks were executed
  73900. */
  73901. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  73902. /**
  73903. * Observable called when a task is done (whatever the result is)
  73904. */
  73905. onProgressObservable: Observable<IAssetsProgressEvent>;
  73906. /**
  73907. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  73908. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  73909. */
  73910. useDefaultLoadingScreen: boolean;
  73911. /**
  73912. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  73913. * when all assets have been downloaded.
  73914. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  73915. */
  73916. autoHideLoadingUI: boolean;
  73917. /**
  73918. * Creates a new AssetsManager
  73919. * @param scene defines the scene to work on
  73920. */
  73921. constructor(scene: Scene);
  73922. /**
  73923. * Add a ContainerAssetTask to the list of active tasks
  73924. * @param taskName defines the name of the new task
  73925. * @param meshesNames defines the name of meshes to load
  73926. * @param rootUrl defines the root url to use to locate files
  73927. * @param sceneFilename defines the filename of the scene file
  73928. * @returns a new ContainerAssetTask object
  73929. */
  73930. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  73931. /**
  73932. * Add a MeshAssetTask to the list of active tasks
  73933. * @param taskName defines the name of the new task
  73934. * @param meshesNames defines the name of meshes to load
  73935. * @param rootUrl defines the root url to use to locate files
  73936. * @param sceneFilename defines the filename of the scene file
  73937. * @returns a new MeshAssetTask object
  73938. */
  73939. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  73940. /**
  73941. * Add a TextFileAssetTask to the list of active tasks
  73942. * @param taskName defines the name of the new task
  73943. * @param url defines the url of the file to load
  73944. * @returns a new TextFileAssetTask object
  73945. */
  73946. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  73947. /**
  73948. * Add a BinaryFileAssetTask to the list of active tasks
  73949. * @param taskName defines the name of the new task
  73950. * @param url defines the url of the file to load
  73951. * @returns a new BinaryFileAssetTask object
  73952. */
  73953. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  73954. /**
  73955. * Add a ImageAssetTask to the list of active tasks
  73956. * @param taskName defines the name of the new task
  73957. * @param url defines the url of the file to load
  73958. * @returns a new ImageAssetTask object
  73959. */
  73960. addImageTask(taskName: string, url: string): ImageAssetTask;
  73961. /**
  73962. * Add a TextureAssetTask to the list of active tasks
  73963. * @param taskName defines the name of the new task
  73964. * @param url defines the url of the file to load
  73965. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  73966. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  73967. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  73968. * @returns a new TextureAssetTask object
  73969. */
  73970. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  73971. /**
  73972. * Add a CubeTextureAssetTask to the list of active tasks
  73973. * @param taskName defines the name of the new task
  73974. * @param url defines the url of the file to load
  73975. * @param extensions defines the extension to use to load the cube map (can be null)
  73976. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  73977. * @param files defines the list of files to load (can be null)
  73978. * @returns a new CubeTextureAssetTask object
  73979. */
  73980. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  73981. /**
  73982. *
  73983. * Add a HDRCubeTextureAssetTask to the list of active tasks
  73984. * @param taskName defines the name of the new task
  73985. * @param url defines the url of the file to load
  73986. * @param size defines the size you want for the cubemap (can be null)
  73987. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  73988. * @param generateHarmonics defines if you want to automatically generate (true by default)
  73989. * @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)
  73990. * @param reserved Internal use only
  73991. * @returns a new HDRCubeTextureAssetTask object
  73992. */
  73993. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  73994. /**
  73995. *
  73996. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  73997. * @param taskName defines the name of the new task
  73998. * @param url defines the url of the file to load
  73999. * @param size defines the size you want for the cubemap (can be null)
  74000. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  74001. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  74002. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  74003. * @returns a new EquiRectangularCubeTextureAssetTask object
  74004. */
  74005. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  74006. /**
  74007. * Remove a task from the assets manager.
  74008. * @param task the task to remove
  74009. */
  74010. removeTask(task: AbstractAssetTask): void;
  74011. private _decreaseWaitingTasksCount;
  74012. private _runTask;
  74013. /**
  74014. * Reset the AssetsManager and remove all tasks
  74015. * @return the current instance of the AssetsManager
  74016. */
  74017. reset(): AssetsManager;
  74018. /**
  74019. * Start the loading process
  74020. * @return the current instance of the AssetsManager
  74021. */
  74022. load(): AssetsManager;
  74023. /**
  74024. * Start the loading process as an async operation
  74025. * @return a promise returning the list of failed tasks
  74026. */
  74027. loadAsync(): Promise<void>;
  74028. }
  74029. }
  74030. declare module BABYLON {
  74031. /**
  74032. * Wrapper class for promise with external resolve and reject.
  74033. */
  74034. export class Deferred<T> {
  74035. /**
  74036. * The promise associated with this deferred object.
  74037. */
  74038. readonly promise: Promise<T>;
  74039. private _resolve;
  74040. private _reject;
  74041. /**
  74042. * The resolve method of the promise associated with this deferred object.
  74043. */
  74044. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  74045. /**
  74046. * The reject method of the promise associated with this deferred object.
  74047. */
  74048. get reject(): (reason?: any) => void;
  74049. /**
  74050. * Constructor for this deferred object.
  74051. */
  74052. constructor();
  74053. }
  74054. }
  74055. declare module BABYLON {
  74056. /**
  74057. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  74058. */
  74059. export class MeshExploder {
  74060. private _centerMesh;
  74061. private _meshes;
  74062. private _meshesOrigins;
  74063. private _toCenterVectors;
  74064. private _scaledDirection;
  74065. private _newPosition;
  74066. private _centerPosition;
  74067. /**
  74068. * Explodes meshes from a center mesh.
  74069. * @param meshes The meshes to explode.
  74070. * @param centerMesh The mesh to be center of explosion.
  74071. */
  74072. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  74073. private _setCenterMesh;
  74074. /**
  74075. * Get class name
  74076. * @returns "MeshExploder"
  74077. */
  74078. getClassName(): string;
  74079. /**
  74080. * "Exploded meshes"
  74081. * @returns Array of meshes with the centerMesh at index 0.
  74082. */
  74083. getMeshes(): Array<Mesh>;
  74084. /**
  74085. * Explodes meshes giving a specific direction
  74086. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  74087. */
  74088. explode(direction?: number): void;
  74089. }
  74090. }
  74091. declare module BABYLON {
  74092. /**
  74093. * Class used to help managing file picking and drag'n'drop
  74094. */
  74095. export class FilesInput {
  74096. /**
  74097. * List of files ready to be loaded
  74098. */
  74099. static get FilesToLoad(): {
  74100. [key: string]: File;
  74101. };
  74102. /**
  74103. * Callback called when a file is processed
  74104. */
  74105. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  74106. private _engine;
  74107. private _currentScene;
  74108. private _sceneLoadedCallback;
  74109. private _progressCallback;
  74110. private _additionalRenderLoopLogicCallback;
  74111. private _textureLoadingCallback;
  74112. private _startingProcessingFilesCallback;
  74113. private _onReloadCallback;
  74114. private _errorCallback;
  74115. private _elementToMonitor;
  74116. private _sceneFileToLoad;
  74117. private _filesToLoad;
  74118. /**
  74119. * Creates a new FilesInput
  74120. * @param engine defines the rendering engine
  74121. * @param scene defines the hosting scene
  74122. * @param sceneLoadedCallback callback called when scene is loaded
  74123. * @param progressCallback callback called to track progress
  74124. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  74125. * @param textureLoadingCallback callback called when a texture is loading
  74126. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  74127. * @param onReloadCallback callback called when a reload is requested
  74128. * @param errorCallback callback call if an error occurs
  74129. */
  74130. 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>);
  74131. private _dragEnterHandler;
  74132. private _dragOverHandler;
  74133. private _dropHandler;
  74134. /**
  74135. * Calls this function to listen to drag'n'drop events on a specific DOM element
  74136. * @param elementToMonitor defines the DOM element to track
  74137. */
  74138. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  74139. /** Gets the current list of files to load */
  74140. get filesToLoad(): File[];
  74141. /**
  74142. * Release all associated resources
  74143. */
  74144. dispose(): void;
  74145. private renderFunction;
  74146. private drag;
  74147. private drop;
  74148. private _traverseFolder;
  74149. private _processFiles;
  74150. /**
  74151. * Load files from a drop event
  74152. * @param event defines the drop event to use as source
  74153. */
  74154. loadFiles(event: any): void;
  74155. private _processReload;
  74156. /**
  74157. * Reload the current scene from the loaded files
  74158. */
  74159. reload(): void;
  74160. }
  74161. }
  74162. declare module BABYLON {
  74163. /**
  74164. * Defines the root class used to create scene optimization to use with SceneOptimizer
  74165. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74166. */
  74167. export class SceneOptimization {
  74168. /**
  74169. * Defines the priority of this optimization (0 by default which means first in the list)
  74170. */
  74171. priority: number;
  74172. /**
  74173. * Gets a string describing the action executed by the current optimization
  74174. * @returns description string
  74175. */
  74176. getDescription(): string;
  74177. /**
  74178. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74179. * @param scene defines the current scene where to apply this optimization
  74180. * @param optimizer defines the current optimizer
  74181. * @returns true if everything that can be done was applied
  74182. */
  74183. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74184. /**
  74185. * Creates the SceneOptimization object
  74186. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  74187. * @param desc defines the description associated with the optimization
  74188. */
  74189. constructor(
  74190. /**
  74191. * Defines the priority of this optimization (0 by default which means first in the list)
  74192. */
  74193. priority?: number);
  74194. }
  74195. /**
  74196. * Defines an optimization used to reduce the size of render target textures
  74197. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74198. */
  74199. export class TextureOptimization extends SceneOptimization {
  74200. /**
  74201. * Defines the priority of this optimization (0 by default which means first in the list)
  74202. */
  74203. priority: number;
  74204. /**
  74205. * 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
  74206. */
  74207. maximumSize: number;
  74208. /**
  74209. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  74210. */
  74211. step: number;
  74212. /**
  74213. * Gets a string describing the action executed by the current optimization
  74214. * @returns description string
  74215. */
  74216. getDescription(): string;
  74217. /**
  74218. * Creates the TextureOptimization object
  74219. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  74220. * @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
  74221. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  74222. */
  74223. constructor(
  74224. /**
  74225. * Defines the priority of this optimization (0 by default which means first in the list)
  74226. */
  74227. priority?: number,
  74228. /**
  74229. * 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
  74230. */
  74231. maximumSize?: number,
  74232. /**
  74233. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  74234. */
  74235. step?: number);
  74236. /**
  74237. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74238. * @param scene defines the current scene where to apply this optimization
  74239. * @param optimizer defines the current optimizer
  74240. * @returns true if everything that can be done was applied
  74241. */
  74242. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74243. }
  74244. /**
  74245. * Defines an optimization used to increase or decrease the rendering resolution
  74246. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74247. */
  74248. export class HardwareScalingOptimization extends SceneOptimization {
  74249. /**
  74250. * Defines the priority of this optimization (0 by default which means first in the list)
  74251. */
  74252. priority: number;
  74253. /**
  74254. * Defines the maximum scale to use (2 by default)
  74255. */
  74256. maximumScale: number;
  74257. /**
  74258. * Defines the step to use between two passes (0.5 by default)
  74259. */
  74260. step: number;
  74261. private _currentScale;
  74262. private _directionOffset;
  74263. /**
  74264. * Gets a string describing the action executed by the current optimization
  74265. * @return description string
  74266. */
  74267. getDescription(): string;
  74268. /**
  74269. * Creates the HardwareScalingOptimization object
  74270. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  74271. * @param maximumScale defines the maximum scale to use (2 by default)
  74272. * @param step defines the step to use between two passes (0.5 by default)
  74273. */
  74274. constructor(
  74275. /**
  74276. * Defines the priority of this optimization (0 by default which means first in the list)
  74277. */
  74278. priority?: number,
  74279. /**
  74280. * Defines the maximum scale to use (2 by default)
  74281. */
  74282. maximumScale?: number,
  74283. /**
  74284. * Defines the step to use between two passes (0.5 by default)
  74285. */
  74286. step?: number);
  74287. /**
  74288. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74289. * @param scene defines the current scene where to apply this optimization
  74290. * @param optimizer defines the current optimizer
  74291. * @returns true if everything that can be done was applied
  74292. */
  74293. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74294. }
  74295. /**
  74296. * Defines an optimization used to remove shadows
  74297. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74298. */
  74299. export class ShadowsOptimization extends SceneOptimization {
  74300. /**
  74301. * Gets a string describing the action executed by the current optimization
  74302. * @return description string
  74303. */
  74304. getDescription(): string;
  74305. /**
  74306. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74307. * @param scene defines the current scene where to apply this optimization
  74308. * @param optimizer defines the current optimizer
  74309. * @returns true if everything that can be done was applied
  74310. */
  74311. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74312. }
  74313. /**
  74314. * Defines an optimization used to turn post-processes off
  74315. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74316. */
  74317. export class PostProcessesOptimization extends SceneOptimization {
  74318. /**
  74319. * Gets a string describing the action executed by the current optimization
  74320. * @return description string
  74321. */
  74322. getDescription(): string;
  74323. /**
  74324. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74325. * @param scene defines the current scene where to apply this optimization
  74326. * @param optimizer defines the current optimizer
  74327. * @returns true if everything that can be done was applied
  74328. */
  74329. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74330. }
  74331. /**
  74332. * Defines an optimization used to turn lens flares off
  74333. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74334. */
  74335. export class LensFlaresOptimization extends SceneOptimization {
  74336. /**
  74337. * Gets a string describing the action executed by the current optimization
  74338. * @return description string
  74339. */
  74340. getDescription(): string;
  74341. /**
  74342. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74343. * @param scene defines the current scene where to apply this optimization
  74344. * @param optimizer defines the current optimizer
  74345. * @returns true if everything that can be done was applied
  74346. */
  74347. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74348. }
  74349. /**
  74350. * Defines an optimization based on user defined callback.
  74351. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74352. */
  74353. export class CustomOptimization extends SceneOptimization {
  74354. /**
  74355. * Callback called to apply the custom optimization.
  74356. */
  74357. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  74358. /**
  74359. * Callback called to get custom description
  74360. */
  74361. onGetDescription: () => string;
  74362. /**
  74363. * Gets a string describing the action executed by the current optimization
  74364. * @returns description string
  74365. */
  74366. getDescription(): string;
  74367. /**
  74368. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74369. * @param scene defines the current scene where to apply this optimization
  74370. * @param optimizer defines the current optimizer
  74371. * @returns true if everything that can be done was applied
  74372. */
  74373. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74374. }
  74375. /**
  74376. * Defines an optimization used to turn particles off
  74377. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74378. */
  74379. export class ParticlesOptimization extends SceneOptimization {
  74380. /**
  74381. * Gets a string describing the action executed by the current optimization
  74382. * @return description string
  74383. */
  74384. getDescription(): string;
  74385. /**
  74386. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74387. * @param scene defines the current scene where to apply this optimization
  74388. * @param optimizer defines the current optimizer
  74389. * @returns true if everything that can be done was applied
  74390. */
  74391. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74392. }
  74393. /**
  74394. * Defines an optimization used to turn render targets off
  74395. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74396. */
  74397. export class RenderTargetsOptimization extends SceneOptimization {
  74398. /**
  74399. * Gets a string describing the action executed by the current optimization
  74400. * @return description string
  74401. */
  74402. getDescription(): string;
  74403. /**
  74404. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74405. * @param scene defines the current scene where to apply this optimization
  74406. * @param optimizer defines the current optimizer
  74407. * @returns true if everything that can be done was applied
  74408. */
  74409. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  74410. }
  74411. /**
  74412. * Defines an optimization used to merge meshes with compatible materials
  74413. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74414. */
  74415. export class MergeMeshesOptimization extends SceneOptimization {
  74416. private static _UpdateSelectionTree;
  74417. /**
  74418. * Gets or sets a boolean which defines if optimization octree has to be updated
  74419. */
  74420. static get UpdateSelectionTree(): boolean;
  74421. /**
  74422. * Gets or sets a boolean which defines if optimization octree has to be updated
  74423. */
  74424. static set UpdateSelectionTree(value: boolean);
  74425. /**
  74426. * Gets a string describing the action executed by the current optimization
  74427. * @return description string
  74428. */
  74429. getDescription(): string;
  74430. private _canBeMerged;
  74431. /**
  74432. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  74433. * @param scene defines the current scene where to apply this optimization
  74434. * @param optimizer defines the current optimizer
  74435. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  74436. * @returns true if everything that can be done was applied
  74437. */
  74438. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  74439. }
  74440. /**
  74441. * Defines a list of options used by SceneOptimizer
  74442. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74443. */
  74444. export class SceneOptimizerOptions {
  74445. /**
  74446. * Defines the target frame rate to reach (60 by default)
  74447. */
  74448. targetFrameRate: number;
  74449. /**
  74450. * Defines the interval between two checkes (2000ms by default)
  74451. */
  74452. trackerDuration: number;
  74453. /**
  74454. * Gets the list of optimizations to apply
  74455. */
  74456. optimizations: SceneOptimization[];
  74457. /**
  74458. * Creates a new list of options used by SceneOptimizer
  74459. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  74460. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  74461. */
  74462. constructor(
  74463. /**
  74464. * Defines the target frame rate to reach (60 by default)
  74465. */
  74466. targetFrameRate?: number,
  74467. /**
  74468. * Defines the interval between two checkes (2000ms by default)
  74469. */
  74470. trackerDuration?: number);
  74471. /**
  74472. * Add a new optimization
  74473. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  74474. * @returns the current SceneOptimizerOptions
  74475. */
  74476. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  74477. /**
  74478. * Add a new custom optimization
  74479. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  74480. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  74481. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  74482. * @returns the current SceneOptimizerOptions
  74483. */
  74484. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  74485. /**
  74486. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  74487. * @param targetFrameRate defines the target frame rate (60 by default)
  74488. * @returns a SceneOptimizerOptions object
  74489. */
  74490. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  74491. /**
  74492. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  74493. * @param targetFrameRate defines the target frame rate (60 by default)
  74494. * @returns a SceneOptimizerOptions object
  74495. */
  74496. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  74497. /**
  74498. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  74499. * @param targetFrameRate defines the target frame rate (60 by default)
  74500. * @returns a SceneOptimizerOptions object
  74501. */
  74502. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  74503. }
  74504. /**
  74505. * Class used to run optimizations in order to reach a target frame rate
  74506. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  74507. */
  74508. export class SceneOptimizer implements IDisposable {
  74509. private _isRunning;
  74510. private _options;
  74511. private _scene;
  74512. private _currentPriorityLevel;
  74513. private _targetFrameRate;
  74514. private _trackerDuration;
  74515. private _currentFrameRate;
  74516. private _sceneDisposeObserver;
  74517. private _improvementMode;
  74518. /**
  74519. * Defines an observable called when the optimizer reaches the target frame rate
  74520. */
  74521. onSuccessObservable: Observable<SceneOptimizer>;
  74522. /**
  74523. * Defines an observable called when the optimizer enables an optimization
  74524. */
  74525. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  74526. /**
  74527. * Defines an observable called when the optimizer is not able to reach the target frame rate
  74528. */
  74529. onFailureObservable: Observable<SceneOptimizer>;
  74530. /**
  74531. * Gets a boolean indicating if the optimizer is in improvement mode
  74532. */
  74533. get isInImprovementMode(): boolean;
  74534. /**
  74535. * Gets the current priority level (0 at start)
  74536. */
  74537. get currentPriorityLevel(): number;
  74538. /**
  74539. * Gets the current frame rate checked by the SceneOptimizer
  74540. */
  74541. get currentFrameRate(): number;
  74542. /**
  74543. * Gets or sets the current target frame rate (60 by default)
  74544. */
  74545. get targetFrameRate(): number;
  74546. /**
  74547. * Gets or sets the current target frame rate (60 by default)
  74548. */
  74549. set targetFrameRate(value: number);
  74550. /**
  74551. * Gets or sets the current interval between two checks (every 2000ms by default)
  74552. */
  74553. get trackerDuration(): number;
  74554. /**
  74555. * Gets or sets the current interval between two checks (every 2000ms by default)
  74556. */
  74557. set trackerDuration(value: number);
  74558. /**
  74559. * Gets the list of active optimizations
  74560. */
  74561. get optimizations(): SceneOptimization[];
  74562. /**
  74563. * Creates a new SceneOptimizer
  74564. * @param scene defines the scene to work on
  74565. * @param options defines the options to use with the SceneOptimizer
  74566. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  74567. * @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)
  74568. */
  74569. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  74570. /**
  74571. * Stops the current optimizer
  74572. */
  74573. stop(): void;
  74574. /**
  74575. * Reset the optimizer to initial step (current priority level = 0)
  74576. */
  74577. reset(): void;
  74578. /**
  74579. * Start the optimizer. By default it will try to reach a specific framerate
  74580. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  74581. */
  74582. start(): void;
  74583. private _checkCurrentState;
  74584. /**
  74585. * Release all resources
  74586. */
  74587. dispose(): void;
  74588. /**
  74589. * Helper function to create a SceneOptimizer with one single line of code
  74590. * @param scene defines the scene to work on
  74591. * @param options defines the options to use with the SceneOptimizer
  74592. * @param onSuccess defines a callback to call on success
  74593. * @param onFailure defines a callback to call on failure
  74594. * @returns the new SceneOptimizer object
  74595. */
  74596. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  74597. }
  74598. }
  74599. declare module BABYLON {
  74600. /**
  74601. * Class used to serialize a scene into a string
  74602. */
  74603. export class SceneSerializer {
  74604. /**
  74605. * Clear cache used by a previous serialization
  74606. */
  74607. static ClearCache(): void;
  74608. /**
  74609. * Serialize a scene into a JSON compatible object
  74610. * @param scene defines the scene to serialize
  74611. * @returns a JSON compatible object
  74612. */
  74613. static Serialize(scene: Scene): any;
  74614. /**
  74615. * Serialize a mesh into a JSON compatible object
  74616. * @param toSerialize defines the mesh to serialize
  74617. * @param withParents defines if parents must be serialized as well
  74618. * @param withChildren defines if children must be serialized as well
  74619. * @returns a JSON compatible object
  74620. */
  74621. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  74622. }
  74623. }
  74624. declare module BABYLON {
  74625. /**
  74626. * Class used to host texture specific utilities
  74627. */
  74628. export class TextureTools {
  74629. /**
  74630. * Uses the GPU to create a copy texture rescaled at a given size
  74631. * @param texture Texture to copy from
  74632. * @param width defines the desired width
  74633. * @param height defines the desired height
  74634. * @param useBilinearMode defines if bilinear mode has to be used
  74635. * @return the generated texture
  74636. */
  74637. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  74638. }
  74639. }
  74640. declare module BABYLON {
  74641. /**
  74642. * This represents the different options available for the video capture.
  74643. */
  74644. export interface VideoRecorderOptions {
  74645. /** Defines the mime type of the video. */
  74646. mimeType: string;
  74647. /** Defines the FPS the video should be recorded at. */
  74648. fps: number;
  74649. /** Defines the chunk size for the recording data. */
  74650. recordChunckSize: number;
  74651. /** The audio tracks to attach to the recording. */
  74652. audioTracks?: MediaStreamTrack[];
  74653. }
  74654. /**
  74655. * This can help with recording videos from BabylonJS.
  74656. * This is based on the available WebRTC functionalities of the browser.
  74657. *
  74658. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  74659. */
  74660. export class VideoRecorder {
  74661. private static readonly _defaultOptions;
  74662. /**
  74663. * Returns whether or not the VideoRecorder is available in your browser.
  74664. * @param engine Defines the Babylon Engine.
  74665. * @returns true if supported otherwise false.
  74666. */
  74667. static IsSupported(engine: Engine): boolean;
  74668. private readonly _options;
  74669. private _canvas;
  74670. private _mediaRecorder;
  74671. private _recordedChunks;
  74672. private _fileName;
  74673. private _resolve;
  74674. private _reject;
  74675. /**
  74676. * True when a recording is already in progress.
  74677. */
  74678. get isRecording(): boolean;
  74679. /**
  74680. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  74681. * @param engine Defines the BabylonJS Engine you wish to record.
  74682. * @param options Defines options that can be used to customize the capture.
  74683. */
  74684. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  74685. /**
  74686. * Stops the current recording before the default capture timeout passed in the startRecording function.
  74687. */
  74688. stopRecording(): void;
  74689. /**
  74690. * Starts recording the canvas for a max duration specified in parameters.
  74691. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  74692. * If null no automatic download will start and you can rely on the promise to get the data back.
  74693. * @param maxDuration Defines the maximum recording time in seconds.
  74694. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  74695. * @return A promise callback at the end of the recording with the video data in Blob.
  74696. */
  74697. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  74698. /**
  74699. * Releases internal resources used during the recording.
  74700. */
  74701. dispose(): void;
  74702. private _handleDataAvailable;
  74703. private _handleError;
  74704. private _handleStop;
  74705. }
  74706. }
  74707. declare module BABYLON {
  74708. /**
  74709. * Class containing a set of static utilities functions for screenshots
  74710. */
  74711. export class ScreenshotTools {
  74712. /**
  74713. * Captures a screenshot of the current rendering
  74714. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  74715. * @param engine defines the rendering engine
  74716. * @param camera defines the source camera
  74717. * @param size This parameter can be set to a single number or to an object with the
  74718. * following (optional) properties: precision, width, height. If a single number is passed,
  74719. * it will be used for both width and height. If an object is passed, the screenshot size
  74720. * will be derived from the parameters. The precision property is a multiplier allowing
  74721. * rendering at a higher or lower resolution
  74722. * @param successCallback defines the callback receives a single parameter which contains the
  74723. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  74724. * src parameter of an <img> to display it
  74725. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  74726. * Check your browser for supported MIME types
  74727. */
  74728. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  74729. /**
  74730. * Captures a screenshot of the current rendering
  74731. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  74732. * @param engine defines the rendering engine
  74733. * @param camera defines the source camera
  74734. * @param size This parameter can be set to a single number or to an object with the
  74735. * following (optional) properties: precision, width, height. If a single number is passed,
  74736. * it will be used for both width and height. If an object is passed, the screenshot size
  74737. * will be derived from the parameters. The precision property is a multiplier allowing
  74738. * rendering at a higher or lower resolution
  74739. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  74740. * Check your browser for supported MIME types
  74741. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  74742. * to the src parameter of an <img> to display it
  74743. */
  74744. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  74745. /**
  74746. * Generates an image screenshot from the specified camera.
  74747. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  74748. * @param engine The engine to use for rendering
  74749. * @param camera The camera to use for rendering
  74750. * @param size This parameter can be set to a single number or to an object with the
  74751. * following (optional) properties: precision, width, height. If a single number is passed,
  74752. * it will be used for both width and height. If an object is passed, the screenshot size
  74753. * will be derived from the parameters. The precision property is a multiplier allowing
  74754. * rendering at a higher or lower resolution
  74755. * @param successCallback The callback receives a single parameter which contains the
  74756. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  74757. * src parameter of an <img> to display it
  74758. * @param mimeType The MIME type of the screenshot image (default: image/png).
  74759. * Check your browser for supported MIME types
  74760. * @param samples Texture samples (default: 1)
  74761. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  74762. * @param fileName A name for for the downloaded file.
  74763. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  74764. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  74765. */
  74766. 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;
  74767. /**
  74768. * Generates an image screenshot from the specified camera.
  74769. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  74770. * @param engine The engine to use for rendering
  74771. * @param camera The camera to use for rendering
  74772. * @param size This parameter can be set to a single number or to an object with the
  74773. * following (optional) properties: precision, width, height. If a single number is passed,
  74774. * it will be used for both width and height. If an object is passed, the screenshot size
  74775. * will be derived from the parameters. The precision property is a multiplier allowing
  74776. * rendering at a higher or lower resolution
  74777. * @param mimeType The MIME type of the screenshot image (default: image/png).
  74778. * Check your browser for supported MIME types
  74779. * @param samples Texture samples (default: 1)
  74780. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  74781. * @param fileName A name for for the downloaded file.
  74782. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  74783. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  74784. * to the src parameter of an <img> to display it
  74785. */
  74786. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  74787. /**
  74788. * Gets height and width for screenshot size
  74789. * @private
  74790. */
  74791. private static _getScreenshotSize;
  74792. }
  74793. }
  74794. declare module BABYLON {
  74795. /**
  74796. * Interface for a data buffer
  74797. */
  74798. export interface IDataBuffer {
  74799. /**
  74800. * Reads bytes from the data buffer.
  74801. * @param byteOffset The byte offset to read
  74802. * @param byteLength The byte length to read
  74803. * @returns A promise that resolves when the bytes are read
  74804. */
  74805. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  74806. /**
  74807. * The byte length of the buffer.
  74808. */
  74809. readonly byteLength: number;
  74810. }
  74811. /**
  74812. * Utility class for reading from a data buffer
  74813. */
  74814. export class DataReader {
  74815. /**
  74816. * The data buffer associated with this data reader.
  74817. */
  74818. readonly buffer: IDataBuffer;
  74819. /**
  74820. * The current byte offset from the beginning of the data buffer.
  74821. */
  74822. byteOffset: number;
  74823. private _dataView;
  74824. private _dataByteOffset;
  74825. /**
  74826. * Constructor
  74827. * @param buffer The buffer to read
  74828. */
  74829. constructor(buffer: IDataBuffer);
  74830. /**
  74831. * Loads the given byte length.
  74832. * @param byteLength The byte length to load
  74833. * @returns A promise that resolves when the load is complete
  74834. */
  74835. loadAsync(byteLength: number): Promise<void>;
  74836. /**
  74837. * Read a unsigned 32-bit integer from the currently loaded data range.
  74838. * @returns The 32-bit integer read
  74839. */
  74840. readUint32(): number;
  74841. /**
  74842. * Read a byte array from the currently loaded data range.
  74843. * @param byteLength The byte length to read
  74844. * @returns The byte array read
  74845. */
  74846. readUint8Array(byteLength: number): Uint8Array;
  74847. /**
  74848. * Read a string from the currently loaded data range.
  74849. * @param byteLength The byte length to read
  74850. * @returns The string read
  74851. */
  74852. readString(byteLength: number): string;
  74853. /**
  74854. * Skips the given byte length the currently loaded data range.
  74855. * @param byteLength The byte length to skip
  74856. */
  74857. skipBytes(byteLength: number): void;
  74858. }
  74859. }
  74860. declare module BABYLON {
  74861. /**
  74862. * Class for storing data to local storage if available or in-memory storage otherwise
  74863. */
  74864. export class DataStorage {
  74865. private static _Storage;
  74866. private static _GetStorage;
  74867. /**
  74868. * Reads a string from the data storage
  74869. * @param key The key to read
  74870. * @param defaultValue The value if the key doesn't exist
  74871. * @returns The string value
  74872. */
  74873. static ReadString(key: string, defaultValue: string): string;
  74874. /**
  74875. * Writes a string to the data storage
  74876. * @param key The key to write
  74877. * @param value The value to write
  74878. */
  74879. static WriteString(key: string, value: string): void;
  74880. /**
  74881. * Reads a boolean from the data storage
  74882. * @param key The key to read
  74883. * @param defaultValue The value if the key doesn't exist
  74884. * @returns The boolean value
  74885. */
  74886. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  74887. /**
  74888. * Writes a boolean to the data storage
  74889. * @param key The key to write
  74890. * @param value The value to write
  74891. */
  74892. static WriteBoolean(key: string, value: boolean): void;
  74893. /**
  74894. * Reads a number from the data storage
  74895. * @param key The key to read
  74896. * @param defaultValue The value if the key doesn't exist
  74897. * @returns The number value
  74898. */
  74899. static ReadNumber(key: string, defaultValue: number): number;
  74900. /**
  74901. * Writes a number to the data storage
  74902. * @param key The key to write
  74903. * @param value The value to write
  74904. */
  74905. static WriteNumber(key: string, value: number): void;
  74906. }
  74907. }
  74908. declare module BABYLON {
  74909. /**
  74910. * Class used to record delta files between 2 scene states
  74911. */
  74912. export class SceneRecorder {
  74913. private _trackedScene;
  74914. private _savedJSON;
  74915. /**
  74916. * Track a given scene. This means the current scene state will be considered the original state
  74917. * @param scene defines the scene to track
  74918. */
  74919. track(scene: Scene): void;
  74920. /**
  74921. * Get the delta between current state and original state
  74922. * @returns a string containing the delta
  74923. */
  74924. getDelta(): any;
  74925. private _compareArray;
  74926. private _compareObjects;
  74927. private _compareCollections;
  74928. private static GetShadowGeneratorById;
  74929. /**
  74930. * Apply a given delta to a given scene
  74931. * @param deltaJSON defines the JSON containing the delta
  74932. * @param scene defines the scene to apply the delta to
  74933. */
  74934. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  74935. private static _ApplyPropertiesToEntity;
  74936. private static _ApplyDeltaForEntity;
  74937. }
  74938. }
  74939. declare module BABYLON {
  74940. /**
  74941. * A 3D trajectory consisting of an order list of vectors describing a
  74942. * path of motion through 3D space.
  74943. */
  74944. export class Trajectory {
  74945. private _points;
  74946. private readonly _segmentLength;
  74947. /**
  74948. * Serialize to JSON.
  74949. * @returns serialized JSON string
  74950. */
  74951. serialize(): string;
  74952. /**
  74953. * Deserialize from JSON.
  74954. * @param json serialized JSON string
  74955. * @returns deserialized Trajectory
  74956. */
  74957. static Deserialize(json: string): Trajectory;
  74958. /**
  74959. * Create a new empty Trajectory.
  74960. * @param segmentLength radius of discretization for Trajectory points
  74961. */
  74962. constructor(segmentLength?: number);
  74963. /**
  74964. * Get the length of the Trajectory.
  74965. * @returns length of the Trajectory
  74966. */
  74967. getLength(): number;
  74968. /**
  74969. * Append a new point to the Trajectory.
  74970. * NOTE: This implementation has many allocations.
  74971. * @param point point to append to the Trajectory
  74972. */
  74973. add(point: DeepImmutable<Vector3>): void;
  74974. /**
  74975. * Create a new Trajectory with a segment length chosen to make it
  74976. * probable that the new Trajectory will have a specified number of
  74977. * segments. This operation is imprecise.
  74978. * @param targetResolution number of segments desired
  74979. * @returns new Trajectory with approximately the requested number of segments
  74980. */
  74981. resampleAtTargetResolution(targetResolution: number): Trajectory;
  74982. /**
  74983. * Convert Trajectory segments into tokenized representation. This
  74984. * representation is an array of numbers where each nth number is the
  74985. * index of the token which is most similar to the nth segment of the
  74986. * Trajectory.
  74987. * @param tokens list of vectors which serve as discrete tokens
  74988. * @returns list of indices of most similar token per segment
  74989. */
  74990. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  74991. private static _forwardDir;
  74992. private static _inverseFromVec;
  74993. private static _upDir;
  74994. private static _fromToVec;
  74995. private static _lookMatrix;
  74996. /**
  74997. * Transform the rotation (i.e., direction) of a segment to isolate
  74998. * the relative transformation represented by the segment. This operation
  74999. * may or may not succeed due to singularities in the equations that define
  75000. * motion relativity in this context.
  75001. * @param priorVec the origin of the prior segment
  75002. * @param fromVec the origin of the current segment
  75003. * @param toVec the destination of the current segment
  75004. * @param result reference to output variable
  75005. * @returns whether or not transformation was successful
  75006. */
  75007. private static _transformSegmentDirToRef;
  75008. private static _bestMatch;
  75009. private static _score;
  75010. private static _bestScore;
  75011. /**
  75012. * Determine which token vector is most similar to the
  75013. * segment vector.
  75014. * @param segment segment vector
  75015. * @param tokens token vector list
  75016. * @returns index of the most similar token to the segment
  75017. */
  75018. private static _tokenizeSegment;
  75019. }
  75020. /**
  75021. * Class representing a set of known, named trajectories to which Trajectories can be
  75022. * added and using which Trajectories can be recognized.
  75023. */
  75024. export class TrajectoryClassifier {
  75025. private _maximumAllowableMatchCost;
  75026. private _vector3Alphabet;
  75027. private _levenshteinAlphabet;
  75028. private _nameToDescribedTrajectory;
  75029. /**
  75030. * Serialize to JSON.
  75031. * @returns JSON serialization
  75032. */
  75033. serialize(): string;
  75034. /**
  75035. * Deserialize from JSON.
  75036. * @param json JSON serialization
  75037. * @returns deserialized TrajectorySet
  75038. */
  75039. static Deserialize(json: string): TrajectoryClassifier;
  75040. /**
  75041. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  75042. * VERY naive, need to be generating these things from known
  75043. * sets. Better version later, probably eliminating this one.
  75044. * @returns auto-generated TrajectorySet
  75045. */
  75046. static Generate(): TrajectoryClassifier;
  75047. private constructor();
  75048. /**
  75049. * Add a new Trajectory to the set with a given name.
  75050. * @param trajectory new Trajectory to be added
  75051. * @param classification name to which to add the Trajectory
  75052. */
  75053. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  75054. /**
  75055. * Remove a known named trajectory and all Trajectories associated with it.
  75056. * @param classification name to remove
  75057. * @returns whether anything was removed
  75058. */
  75059. deleteClassification(classification: string): boolean;
  75060. /**
  75061. * Attempt to recognize a Trajectory from among all the classifications
  75062. * already known to the classifier.
  75063. * @param trajectory Trajectory to be recognized
  75064. * @returns classification of Trajectory if recognized, null otherwise
  75065. */
  75066. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  75067. }
  75068. }
  75069. declare module BABYLON {
  75070. /**
  75071. * An interface for all Hit test features
  75072. */
  75073. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  75074. /**
  75075. * Triggered when new babylon (transformed) hit test results are available
  75076. */
  75077. onHitTestResultObservable: Observable<T[]>;
  75078. }
  75079. /**
  75080. * Options used for hit testing
  75081. */
  75082. export interface IWebXRLegacyHitTestOptions {
  75083. /**
  75084. * Only test when user interacted with the scene. Default - hit test every frame
  75085. */
  75086. testOnPointerDownOnly?: boolean;
  75087. /**
  75088. * The node to use to transform the local results to world coordinates
  75089. */
  75090. worldParentNode?: TransformNode;
  75091. }
  75092. /**
  75093. * Interface defining the babylon result of raycasting/hit-test
  75094. */
  75095. export interface IWebXRLegacyHitResult {
  75096. /**
  75097. * Transformation matrix that can be applied to a node that will put it in the hit point location
  75098. */
  75099. transformationMatrix: Matrix;
  75100. /**
  75101. * The native hit test result
  75102. */
  75103. xrHitResult: XRHitResult | XRHitTestResult;
  75104. }
  75105. /**
  75106. * The currently-working hit-test module.
  75107. * Hit test (or Ray-casting) is used to interact with the real world.
  75108. * For further information read here - https://github.com/immersive-web/hit-test
  75109. */
  75110. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  75111. /**
  75112. * options to use when constructing this feature
  75113. */
  75114. readonly options: IWebXRLegacyHitTestOptions;
  75115. private _direction;
  75116. private _mat;
  75117. private _onSelectEnabled;
  75118. private _origin;
  75119. /**
  75120. * The module's name
  75121. */
  75122. static readonly Name: string;
  75123. /**
  75124. * The (Babylon) version of this module.
  75125. * This is an integer representing the implementation version.
  75126. * This number does not correspond to the WebXR specs version
  75127. */
  75128. static readonly Version: number;
  75129. /**
  75130. * Populated with the last native XR Hit Results
  75131. */
  75132. lastNativeXRHitResults: XRHitResult[];
  75133. /**
  75134. * Triggered when new babylon (transformed) hit test results are available
  75135. */
  75136. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  75137. /**
  75138. * Creates a new instance of the (legacy version) hit test feature
  75139. * @param _xrSessionManager an instance of WebXRSessionManager
  75140. * @param options options to use when constructing this feature
  75141. */
  75142. constructor(_xrSessionManager: WebXRSessionManager,
  75143. /**
  75144. * options to use when constructing this feature
  75145. */
  75146. options?: IWebXRLegacyHitTestOptions);
  75147. /**
  75148. * execute a hit test with an XR Ray
  75149. *
  75150. * @param xrSession a native xrSession that will execute this hit test
  75151. * @param xrRay the ray (position and direction) to use for ray-casting
  75152. * @param referenceSpace native XR reference space to use for the hit-test
  75153. * @param filter filter function that will filter the results
  75154. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  75155. */
  75156. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  75157. /**
  75158. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  75159. * @param event the (select) event to use to select with
  75160. * @param referenceSpace the reference space to use for this hit test
  75161. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  75162. */
  75163. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  75164. /**
  75165. * attach this feature
  75166. * Will usually be called by the features manager
  75167. *
  75168. * @returns true if successful.
  75169. */
  75170. attach(): boolean;
  75171. /**
  75172. * detach this feature.
  75173. * Will usually be called by the features manager
  75174. *
  75175. * @returns true if successful.
  75176. */
  75177. detach(): boolean;
  75178. /**
  75179. * Dispose this feature and all of the resources attached
  75180. */
  75181. dispose(): void;
  75182. protected _onXRFrame(frame: XRFrame): void;
  75183. private _onHitTestResults;
  75184. private _onSelect;
  75185. }
  75186. }
  75187. declare module BABYLON {
  75188. /**
  75189. * Options used for hit testing (version 2)
  75190. */
  75191. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  75192. /**
  75193. * Do not create a permanent hit test. Will usually be used when only
  75194. * transient inputs are needed.
  75195. */
  75196. disablePermanentHitTest?: boolean;
  75197. /**
  75198. * Enable transient (for example touch-based) hit test inspections
  75199. */
  75200. enableTransientHitTest?: boolean;
  75201. /**
  75202. * Offset ray for the permanent hit test
  75203. */
  75204. offsetRay?: Vector3;
  75205. /**
  75206. * Offset ray for the transient hit test
  75207. */
  75208. transientOffsetRay?: Vector3;
  75209. /**
  75210. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  75211. */
  75212. useReferenceSpace?: boolean;
  75213. /**
  75214. * Override the default entity type(s) of the hit-test result
  75215. */
  75216. entityTypes?: XRHitTestTrackableType[];
  75217. }
  75218. /**
  75219. * Interface defining the babylon result of hit-test
  75220. */
  75221. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  75222. /**
  75223. * The input source that generated this hit test (if transient)
  75224. */
  75225. inputSource?: XRInputSource;
  75226. /**
  75227. * Is this a transient hit test
  75228. */
  75229. isTransient?: boolean;
  75230. /**
  75231. * Position of the hit test result
  75232. */
  75233. position: Vector3;
  75234. /**
  75235. * Rotation of the hit test result
  75236. */
  75237. rotationQuaternion: Quaternion;
  75238. /**
  75239. * The native hit test result
  75240. */
  75241. xrHitResult: XRHitTestResult;
  75242. }
  75243. /**
  75244. * The currently-working hit-test module.
  75245. * Hit test (or Ray-casting) is used to interact with the real world.
  75246. * For further information read here - https://github.com/immersive-web/hit-test
  75247. *
  75248. * Tested on chrome (mobile) 80.
  75249. */
  75250. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  75251. /**
  75252. * options to use when constructing this feature
  75253. */
  75254. readonly options: IWebXRHitTestOptions;
  75255. private _tmpMat;
  75256. private _tmpPos;
  75257. private _tmpQuat;
  75258. private _transientXrHitTestSource;
  75259. private _xrHitTestSource;
  75260. private initHitTestSource;
  75261. /**
  75262. * The module's name
  75263. */
  75264. static readonly Name: string;
  75265. /**
  75266. * The (Babylon) version of this module.
  75267. * This is an integer representing the implementation version.
  75268. * This number does not correspond to the WebXR specs version
  75269. */
  75270. static readonly Version: number;
  75271. /**
  75272. * When set to true, each hit test will have its own position/rotation objects
  75273. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  75274. * the developers will clone them or copy them as they see fit.
  75275. */
  75276. autoCloneTransformation: boolean;
  75277. /**
  75278. * Triggered when new babylon (transformed) hit test results are available
  75279. * Note - this will be called when results come back from the device. It can be an empty array!!
  75280. */
  75281. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  75282. /**
  75283. * Use this to temporarily pause hit test checks.
  75284. */
  75285. paused: boolean;
  75286. /**
  75287. * Creates a new instance of the hit test feature
  75288. * @param _xrSessionManager an instance of WebXRSessionManager
  75289. * @param options options to use when constructing this feature
  75290. */
  75291. constructor(_xrSessionManager: WebXRSessionManager,
  75292. /**
  75293. * options to use when constructing this feature
  75294. */
  75295. options?: IWebXRHitTestOptions);
  75296. /**
  75297. * attach this feature
  75298. * Will usually be called by the features manager
  75299. *
  75300. * @returns true if successful.
  75301. */
  75302. attach(): boolean;
  75303. /**
  75304. * detach this feature.
  75305. * Will usually be called by the features manager
  75306. *
  75307. * @returns true if successful.
  75308. */
  75309. detach(): boolean;
  75310. /**
  75311. * Dispose this feature and all of the resources attached
  75312. */
  75313. dispose(): void;
  75314. protected _onXRFrame(frame: XRFrame): void;
  75315. private _processWebXRHitTestResult;
  75316. }
  75317. }
  75318. declare module BABYLON {
  75319. /**
  75320. * Configuration options of the anchor system
  75321. */
  75322. export interface IWebXRAnchorSystemOptions {
  75323. /**
  75324. * a node that will be used to convert local to world coordinates
  75325. */
  75326. worldParentNode?: TransformNode;
  75327. /**
  75328. * If set to true a reference of the created anchors will be kept until the next session starts
  75329. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  75330. */
  75331. doNotRemoveAnchorsOnSessionEnded?: boolean;
  75332. }
  75333. /**
  75334. * A babylon container for an XR Anchor
  75335. */
  75336. export interface IWebXRAnchor {
  75337. /**
  75338. * A babylon-assigned ID for this anchor
  75339. */
  75340. id: number;
  75341. /**
  75342. * Transformation matrix to apply to an object attached to this anchor
  75343. */
  75344. transformationMatrix: Matrix;
  75345. /**
  75346. * The native anchor object
  75347. */
  75348. xrAnchor: XRAnchor;
  75349. /**
  75350. * if defined, this object will be constantly updated by the anchor's position and rotation
  75351. */
  75352. attachedNode?: TransformNode;
  75353. }
  75354. /**
  75355. * An implementation of the anchor system for WebXR.
  75356. * For further information see https://github.com/immersive-web/anchors/
  75357. */
  75358. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  75359. private _options;
  75360. private _lastFrameDetected;
  75361. private _trackedAnchors;
  75362. private _referenceSpaceForFrameAnchors;
  75363. private _futureAnchors;
  75364. /**
  75365. * The module's name
  75366. */
  75367. static readonly Name: string;
  75368. /**
  75369. * The (Babylon) version of this module.
  75370. * This is an integer representing the implementation version.
  75371. * This number does not correspond to the WebXR specs version
  75372. */
  75373. static readonly Version: number;
  75374. /**
  75375. * Observers registered here will be executed when a new anchor was added to the session
  75376. */
  75377. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  75378. /**
  75379. * Observers registered here will be executed when an anchor was removed from the session
  75380. */
  75381. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  75382. /**
  75383. * Observers registered here will be executed when an existing anchor updates
  75384. * This can execute N times every frame
  75385. */
  75386. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  75387. /**
  75388. * Set the reference space to use for anchor creation, when not using a hit test.
  75389. * Will default to the session's reference space if not defined
  75390. */
  75391. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  75392. /**
  75393. * constructs a new anchor system
  75394. * @param _xrSessionManager an instance of WebXRSessionManager
  75395. * @param _options configuration object for this feature
  75396. */
  75397. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  75398. private _tmpVector;
  75399. private _tmpQuaternion;
  75400. private _populateTmpTransformation;
  75401. /**
  75402. * Create a new anchor point using a hit test result at a specific point in the scene
  75403. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  75404. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  75405. *
  75406. * @param hitTestResult The hit test result to use for this anchor creation
  75407. * @param position an optional position offset for this anchor
  75408. * @param rotationQuaternion an optional rotation offset for this anchor
  75409. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  75410. */
  75411. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  75412. /**
  75413. * Add a new anchor at a specific position and rotation
  75414. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  75415. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  75416. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  75417. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  75418. *
  75419. * @param position the position in which to add an anchor
  75420. * @param rotationQuaternion an optional rotation for the anchor transformation
  75421. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  75422. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  75423. */
  75424. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  75425. /**
  75426. * detach this feature.
  75427. * Will usually be called by the features manager
  75428. *
  75429. * @returns true if successful.
  75430. */
  75431. detach(): boolean;
  75432. /**
  75433. * Dispose this feature and all of the resources attached
  75434. */
  75435. dispose(): void;
  75436. protected _onXRFrame(frame: XRFrame): void;
  75437. /**
  75438. * avoiding using Array.find for global support.
  75439. * @param xrAnchor the plane to find in the array
  75440. */
  75441. private _findIndexInAnchorArray;
  75442. private _updateAnchorWithXRFrame;
  75443. private _createAnchorAtTransformation;
  75444. }
  75445. }
  75446. declare module BABYLON {
  75447. /**
  75448. * Options used in the plane detector module
  75449. */
  75450. export interface IWebXRPlaneDetectorOptions {
  75451. /**
  75452. * The node to use to transform the local results to world coordinates
  75453. */
  75454. worldParentNode?: TransformNode;
  75455. /**
  75456. * If set to true a reference of the created planes will be kept until the next session starts
  75457. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  75458. */
  75459. doNotRemovePlanesOnSessionEnded?: boolean;
  75460. }
  75461. /**
  75462. * A babylon interface for a WebXR plane.
  75463. * A Plane is actually a polygon, built from N points in space
  75464. *
  75465. * Supported in chrome 79, not supported in canary 81 ATM
  75466. */
  75467. export interface IWebXRPlane {
  75468. /**
  75469. * a babylon-assigned ID for this polygon
  75470. */
  75471. id: number;
  75472. /**
  75473. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  75474. */
  75475. polygonDefinition: Array<Vector3>;
  75476. /**
  75477. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  75478. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  75479. */
  75480. transformationMatrix: Matrix;
  75481. /**
  75482. * the native xr-plane object
  75483. */
  75484. xrPlane: XRPlane;
  75485. }
  75486. /**
  75487. * The plane detector is used to detect planes in the real world when in AR
  75488. * For more information see https://github.com/immersive-web/real-world-geometry/
  75489. */
  75490. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  75491. private _options;
  75492. private _detectedPlanes;
  75493. private _enabled;
  75494. private _lastFrameDetected;
  75495. /**
  75496. * The module's name
  75497. */
  75498. static readonly Name: string;
  75499. /**
  75500. * The (Babylon) version of this module.
  75501. * This is an integer representing the implementation version.
  75502. * This number does not correspond to the WebXR specs version
  75503. */
  75504. static readonly Version: number;
  75505. /**
  75506. * Observers registered here will be executed when a new plane was added to the session
  75507. */
  75508. onPlaneAddedObservable: Observable<IWebXRPlane>;
  75509. /**
  75510. * Observers registered here will be executed when a plane is no longer detected in the session
  75511. */
  75512. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  75513. /**
  75514. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  75515. * This can execute N times every frame
  75516. */
  75517. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  75518. /**
  75519. * construct a new Plane Detector
  75520. * @param _xrSessionManager an instance of xr Session manager
  75521. * @param _options configuration to use when constructing this feature
  75522. */
  75523. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  75524. /**
  75525. * detach this feature.
  75526. * Will usually be called by the features manager
  75527. *
  75528. * @returns true if successful.
  75529. */
  75530. detach(): boolean;
  75531. /**
  75532. * Dispose this feature and all of the resources attached
  75533. */
  75534. dispose(): void;
  75535. protected _onXRFrame(frame: XRFrame): void;
  75536. private _init;
  75537. private _updatePlaneWithXRPlane;
  75538. /**
  75539. * avoiding using Array.find for global support.
  75540. * @param xrPlane the plane to find in the array
  75541. */
  75542. private findIndexInPlaneArray;
  75543. }
  75544. }
  75545. declare module BABYLON {
  75546. /**
  75547. * Options interface for the background remover plugin
  75548. */
  75549. export interface IWebXRBackgroundRemoverOptions {
  75550. /**
  75551. * Further background meshes to disable when entering AR
  75552. */
  75553. backgroundMeshes?: AbstractMesh[];
  75554. /**
  75555. * flags to configure the removal of the environment helper.
  75556. * If not set, the entire background will be removed. If set, flags should be set as well.
  75557. */
  75558. environmentHelperRemovalFlags?: {
  75559. /**
  75560. * Should the skybox be removed (default false)
  75561. */
  75562. skyBox?: boolean;
  75563. /**
  75564. * Should the ground be removed (default false)
  75565. */
  75566. ground?: boolean;
  75567. };
  75568. /**
  75569. * don't disable the environment helper
  75570. */
  75571. ignoreEnvironmentHelper?: boolean;
  75572. }
  75573. /**
  75574. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  75575. */
  75576. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  75577. /**
  75578. * read-only options to be used in this module
  75579. */
  75580. readonly options: IWebXRBackgroundRemoverOptions;
  75581. /**
  75582. * The module's name
  75583. */
  75584. static readonly Name: string;
  75585. /**
  75586. * The (Babylon) version of this module.
  75587. * This is an integer representing the implementation version.
  75588. * This number does not correspond to the WebXR specs version
  75589. */
  75590. static readonly Version: number;
  75591. /**
  75592. * registered observers will be triggered when the background state changes
  75593. */
  75594. onBackgroundStateChangedObservable: Observable<boolean>;
  75595. /**
  75596. * constructs a new background remover module
  75597. * @param _xrSessionManager the session manager for this module
  75598. * @param options read-only options to be used in this module
  75599. */
  75600. constructor(_xrSessionManager: WebXRSessionManager,
  75601. /**
  75602. * read-only options to be used in this module
  75603. */
  75604. options?: IWebXRBackgroundRemoverOptions);
  75605. /**
  75606. * attach this feature
  75607. * Will usually be called by the features manager
  75608. *
  75609. * @returns true if successful.
  75610. */
  75611. attach(): boolean;
  75612. /**
  75613. * detach this feature.
  75614. * Will usually be called by the features manager
  75615. *
  75616. * @returns true if successful.
  75617. */
  75618. detach(): boolean;
  75619. /**
  75620. * Dispose this feature and all of the resources attached
  75621. */
  75622. dispose(): void;
  75623. protected _onXRFrame(_xrFrame: XRFrame): void;
  75624. private _setBackgroundState;
  75625. }
  75626. }
  75627. declare module BABYLON {
  75628. /**
  75629. * Options for the controller physics feature
  75630. */
  75631. export class IWebXRControllerPhysicsOptions {
  75632. /**
  75633. * Should the headset get its own impostor
  75634. */
  75635. enableHeadsetImpostor?: boolean;
  75636. /**
  75637. * Optional parameters for the headset impostor
  75638. */
  75639. headsetImpostorParams?: {
  75640. /**
  75641. * The type of impostor to create. Default is sphere
  75642. */
  75643. impostorType: number;
  75644. /**
  75645. * the size of the impostor. Defaults to 10cm
  75646. */
  75647. impostorSize?: number | {
  75648. width: number;
  75649. height: number;
  75650. depth: number;
  75651. };
  75652. /**
  75653. * Friction definitions
  75654. */
  75655. friction?: number;
  75656. /**
  75657. * Restitution
  75658. */
  75659. restitution?: number;
  75660. };
  75661. /**
  75662. * The physics properties of the future impostors
  75663. */
  75664. physicsProperties?: {
  75665. /**
  75666. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  75667. * Note that this requires a physics engine that supports mesh impostors!
  75668. */
  75669. useControllerMesh?: boolean;
  75670. /**
  75671. * The type of impostor to create. Default is sphere
  75672. */
  75673. impostorType?: number;
  75674. /**
  75675. * the size of the impostor. Defaults to 10cm
  75676. */
  75677. impostorSize?: number | {
  75678. width: number;
  75679. height: number;
  75680. depth: number;
  75681. };
  75682. /**
  75683. * Friction definitions
  75684. */
  75685. friction?: number;
  75686. /**
  75687. * Restitution
  75688. */
  75689. restitution?: number;
  75690. };
  75691. /**
  75692. * the xr input to use with this pointer selection
  75693. */
  75694. xrInput: WebXRInput;
  75695. }
  75696. /**
  75697. * Add physics impostor to your webxr controllers,
  75698. * including naive calculation of their linear and angular velocity
  75699. */
  75700. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  75701. private readonly _options;
  75702. private _attachController;
  75703. private _controllers;
  75704. private _debugMode;
  75705. private _delta;
  75706. private _headsetImpostor?;
  75707. private _headsetMesh?;
  75708. private _lastTimestamp;
  75709. private _tmpQuaternion;
  75710. private _tmpVector;
  75711. /**
  75712. * The module's name
  75713. */
  75714. static readonly Name: string;
  75715. /**
  75716. * The (Babylon) version of this module.
  75717. * This is an integer representing the implementation version.
  75718. * This number does not correspond to the webxr specs version
  75719. */
  75720. static readonly Version: number;
  75721. /**
  75722. * Construct a new Controller Physics Feature
  75723. * @param _xrSessionManager the corresponding xr session manager
  75724. * @param _options options to create this feature with
  75725. */
  75726. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  75727. /**
  75728. * @hidden
  75729. * enable debugging - will show console outputs and the impostor mesh
  75730. */
  75731. _enablePhysicsDebug(): void;
  75732. /**
  75733. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  75734. * @param xrController the controller to add
  75735. */
  75736. addController(xrController: WebXRInputSource): void;
  75737. /**
  75738. * attach this feature
  75739. * Will usually be called by the features manager
  75740. *
  75741. * @returns true if successful.
  75742. */
  75743. attach(): boolean;
  75744. /**
  75745. * detach this feature.
  75746. * Will usually be called by the features manager
  75747. *
  75748. * @returns true if successful.
  75749. */
  75750. detach(): boolean;
  75751. /**
  75752. * Get the headset impostor, if enabled
  75753. * @returns the impostor
  75754. */
  75755. getHeadsetImpostor(): PhysicsImpostor | undefined;
  75756. /**
  75757. * Get the physics impostor of a specific controller.
  75758. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  75759. * @param controller the controller or the controller id of which to get the impostor
  75760. * @returns the impostor or null
  75761. */
  75762. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  75763. /**
  75764. * Update the physics properties provided in the constructor
  75765. * @param newProperties the new properties object
  75766. */
  75767. setPhysicsProperties(newProperties: {
  75768. impostorType?: number;
  75769. impostorSize?: number | {
  75770. width: number;
  75771. height: number;
  75772. depth: number;
  75773. };
  75774. friction?: number;
  75775. restitution?: number;
  75776. }): void;
  75777. protected _onXRFrame(_xrFrame: any): void;
  75778. private _detachController;
  75779. }
  75780. }
  75781. declare module BABYLON {
  75782. /**
  75783. * A babylon interface for a "WebXR" feature point.
  75784. * Represents the position and confidence value of a given feature point.
  75785. */
  75786. export interface IWebXRFeaturePoint {
  75787. /**
  75788. * Represents the position of the feature point in world space.
  75789. */
  75790. position: Vector3;
  75791. /**
  75792. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  75793. */
  75794. confidenceValue: number;
  75795. }
  75796. /**
  75797. * The feature point system is used to detect feature points from real world geometry.
  75798. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  75799. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  75800. */
  75801. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  75802. private _enabled;
  75803. private _featurePointCloud;
  75804. /**
  75805. * The module's name
  75806. */
  75807. static readonly Name: string;
  75808. /**
  75809. * The (Babylon) version of this module.
  75810. * This is an integer representing the implementation version.
  75811. * This number does not correspond to the WebXR specs version
  75812. */
  75813. static readonly Version: number;
  75814. /**
  75815. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  75816. * Will notify the observers about which feature points have been added.
  75817. */
  75818. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  75819. /**
  75820. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  75821. * Will notify the observers about which feature points have been updated.
  75822. */
  75823. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  75824. /**
  75825. * The current feature point cloud maintained across frames.
  75826. */
  75827. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  75828. /**
  75829. * construct the feature point system
  75830. * @param _xrSessionManager an instance of xr Session manager
  75831. */
  75832. constructor(_xrSessionManager: WebXRSessionManager);
  75833. /**
  75834. * Detach this feature.
  75835. * Will usually be called by the features manager
  75836. *
  75837. * @returns true if successful.
  75838. */
  75839. detach(): boolean;
  75840. /**
  75841. * Dispose this feature and all of the resources attached
  75842. */
  75843. dispose(): void;
  75844. /**
  75845. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  75846. */
  75847. protected _onXRFrame(frame: XRFrame): void;
  75848. /**
  75849. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  75850. */
  75851. private _init;
  75852. }
  75853. }
  75854. declare module BABYLON {
  75855. /**
  75856. * Configuration interface for the hand tracking feature
  75857. */
  75858. export interface IWebXRHandTrackingOptions {
  75859. /**
  75860. * The xrInput that will be used as source for new hands
  75861. */
  75862. xrInput: WebXRInput;
  75863. /**
  75864. * Configuration object for the joint meshes
  75865. */
  75866. jointMeshes?: {
  75867. /**
  75868. * Should the meshes created be invisible (defaults to false)
  75869. */
  75870. invisible?: boolean;
  75871. /**
  75872. * A source mesh to be used to create instances. Defaults to a sphere.
  75873. * This mesh will be the source for all other (25) meshes.
  75874. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  75875. */
  75876. sourceMesh?: Mesh;
  75877. /**
  75878. * This function will be called after a mesh was created for a specific joint.
  75879. * Using this function you can either manipulate the instance or return a new mesh.
  75880. * When returning a new mesh the instance created before will be disposed
  75881. */
  75882. onHandJointMeshGenerated?: (meshInstance: InstancedMesh, jointId: number, controllerId: string) => Mesh | undefined;
  75883. /**
  75884. * Should the source mesh stay visible. Defaults to false
  75885. */
  75886. keepOriginalVisible?: boolean;
  75887. /**
  75888. * Scale factor for all instances (defaults to 2)
  75889. */
  75890. scaleFactor?: number;
  75891. /**
  75892. * Should each instance have its own physics impostor
  75893. */
  75894. enablePhysics?: boolean;
  75895. /**
  75896. * If enabled, override default physics properties
  75897. */
  75898. physicsProps?: {
  75899. friction?: number;
  75900. restitution?: number;
  75901. impostorType?: number;
  75902. };
  75903. /**
  75904. * For future use - a single hand-mesh that will be updated according to the XRHand data provided
  75905. */
  75906. handMesh?: AbstractMesh;
  75907. };
  75908. }
  75909. /**
  75910. * Parts of the hands divided to writs and finger names
  75911. */
  75912. export const enum HandPart {
  75913. /**
  75914. * HandPart - Wrist
  75915. */
  75916. WRIST = "wrist",
  75917. /**
  75918. * HandPart - The THumb
  75919. */
  75920. THUMB = "thumb",
  75921. /**
  75922. * HandPart - Index finger
  75923. */
  75924. INDEX = "index",
  75925. /**
  75926. * HandPart - Middle finger
  75927. */
  75928. MIDDLE = "middle",
  75929. /**
  75930. * HandPart - Ring finger
  75931. */
  75932. RING = "ring",
  75933. /**
  75934. * HandPart - Little finger
  75935. */
  75936. LITTLE = "little"
  75937. }
  75938. /**
  75939. * Representing a single hand (with its corresponding native XRHand object)
  75940. */
  75941. export class WebXRHand implements IDisposable {
  75942. /** the controller to which the hand correlates */
  75943. readonly xrController: WebXRInputSource;
  75944. /** the meshes to be used to track the hand joints */
  75945. readonly trackedMeshes: AbstractMesh[];
  75946. /**
  75947. * Hand-parts definition (key is HandPart)
  75948. */
  75949. handPartsDefinition: {
  75950. [key: string]: number[];
  75951. };
  75952. /**
  75953. * Populate the HandPartsDefinition object.
  75954. * This is called as a side effect since certain browsers don't have XRHand defined.
  75955. */
  75956. private generateHandPartsDefinition;
  75957. /**
  75958. * Construct a new hand object
  75959. * @param xrController the controller to which the hand correlates
  75960. * @param trackedMeshes the meshes to be used to track the hand joints
  75961. */
  75962. constructor(
  75963. /** the controller to which the hand correlates */
  75964. xrController: WebXRInputSource,
  75965. /** the meshes to be used to track the hand joints */
  75966. trackedMeshes: AbstractMesh[]);
  75967. /**
  75968. * Update this hand from the latest xr frame
  75969. * @param xrFrame xrFrame to update from
  75970. * @param referenceSpace The current viewer reference space
  75971. * @param scaleFactor optional scale factor for the meshes
  75972. */
  75973. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  75974. /**
  75975. * Get meshes of part of the hand
  75976. * @param part the part of hand to get
  75977. * @returns An array of meshes that correlate to the hand part requested
  75978. */
  75979. getHandPartMeshes(part: HandPart): AbstractMesh[];
  75980. /**
  75981. * Dispose this Hand object
  75982. */
  75983. dispose(): void;
  75984. }
  75985. /**
  75986. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  75987. */
  75988. export class WebXRHandTracking extends WebXRAbstractFeature {
  75989. /**
  75990. * options to use when constructing this feature
  75991. */
  75992. readonly options: IWebXRHandTrackingOptions;
  75993. private static _idCounter;
  75994. /**
  75995. * The module's name
  75996. */
  75997. static readonly Name: string;
  75998. /**
  75999. * The (Babylon) version of this module.
  76000. * This is an integer representing the implementation version.
  76001. * This number does not correspond to the WebXR specs version
  76002. */
  76003. static readonly Version: number;
  76004. /**
  76005. * This observable will notify registered observers when a new hand object was added and initialized
  76006. */
  76007. onHandAddedObservable: Observable<WebXRHand>;
  76008. /**
  76009. * This observable will notify its observers right before the hand object is disposed
  76010. */
  76011. onHandRemovedObservable: Observable<WebXRHand>;
  76012. private _hands;
  76013. /**
  76014. * Creates a new instance of the hit test feature
  76015. * @param _xrSessionManager an instance of WebXRSessionManager
  76016. * @param options options to use when constructing this feature
  76017. */
  76018. constructor(_xrSessionManager: WebXRSessionManager,
  76019. /**
  76020. * options to use when constructing this feature
  76021. */
  76022. options: IWebXRHandTrackingOptions);
  76023. /**
  76024. * Check if the needed objects are defined.
  76025. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  76026. */
  76027. isCompatible(): boolean;
  76028. /**
  76029. * attach this feature
  76030. * Will usually be called by the features manager
  76031. *
  76032. * @returns true if successful.
  76033. */
  76034. attach(): boolean;
  76035. /**
  76036. * detach this feature.
  76037. * Will usually be called by the features manager
  76038. *
  76039. * @returns true if successful.
  76040. */
  76041. detach(): boolean;
  76042. /**
  76043. * Dispose this feature and all of the resources attached
  76044. */
  76045. dispose(): void;
  76046. /**
  76047. * Get the hand object according to the controller id
  76048. * @param controllerId the controller id to which we want to get the hand
  76049. * @returns null if not found or the WebXRHand object if found
  76050. */
  76051. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  76052. /**
  76053. * Get a hand object according to the requested handedness
  76054. * @param handedness the handedness to request
  76055. * @returns null if not found or the WebXRHand object if found
  76056. */
  76057. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  76058. protected _onXRFrame(_xrFrame: XRFrame): void;
  76059. private _attachHand;
  76060. private _detachHand;
  76061. }
  76062. }
  76063. declare module BABYLON {
  76064. /**
  76065. * The motion controller class for all microsoft mixed reality controllers
  76066. */
  76067. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  76068. protected readonly _mapping: {
  76069. defaultButton: {
  76070. valueNodeName: string;
  76071. unpressedNodeName: string;
  76072. pressedNodeName: string;
  76073. };
  76074. defaultAxis: {
  76075. valueNodeName: string;
  76076. minNodeName: string;
  76077. maxNodeName: string;
  76078. };
  76079. buttons: {
  76080. "xr-standard-trigger": {
  76081. rootNodeName: string;
  76082. componentProperty: string;
  76083. states: string[];
  76084. };
  76085. "xr-standard-squeeze": {
  76086. rootNodeName: string;
  76087. componentProperty: string;
  76088. states: string[];
  76089. };
  76090. "xr-standard-touchpad": {
  76091. rootNodeName: string;
  76092. labelAnchorNodeName: string;
  76093. touchPointNodeName: string;
  76094. };
  76095. "xr-standard-thumbstick": {
  76096. rootNodeName: string;
  76097. componentProperty: string;
  76098. states: string[];
  76099. };
  76100. };
  76101. axes: {
  76102. "xr-standard-touchpad": {
  76103. "x-axis": {
  76104. rootNodeName: string;
  76105. };
  76106. "y-axis": {
  76107. rootNodeName: string;
  76108. };
  76109. };
  76110. "xr-standard-thumbstick": {
  76111. "x-axis": {
  76112. rootNodeName: string;
  76113. };
  76114. "y-axis": {
  76115. rootNodeName: string;
  76116. };
  76117. };
  76118. };
  76119. };
  76120. /**
  76121. * The base url used to load the left and right controller models
  76122. */
  76123. static MODEL_BASE_URL: string;
  76124. /**
  76125. * The name of the left controller model file
  76126. */
  76127. static MODEL_LEFT_FILENAME: string;
  76128. /**
  76129. * The name of the right controller model file
  76130. */
  76131. static MODEL_RIGHT_FILENAME: string;
  76132. profileId: string;
  76133. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  76134. protected _getFilenameAndPath(): {
  76135. filename: string;
  76136. path: string;
  76137. };
  76138. protected _getModelLoadingConstraints(): boolean;
  76139. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  76140. protected _setRootMesh(meshes: AbstractMesh[]): void;
  76141. protected _updateModel(): void;
  76142. }
  76143. }
  76144. declare module BABYLON {
  76145. /**
  76146. * The motion controller class for oculus touch (quest, rift).
  76147. * This class supports legacy mapping as well the standard xr mapping
  76148. */
  76149. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  76150. private _forceLegacyControllers;
  76151. private _modelRootNode;
  76152. /**
  76153. * The base url used to load the left and right controller models
  76154. */
  76155. static MODEL_BASE_URL: string;
  76156. /**
  76157. * The name of the left controller model file
  76158. */
  76159. static MODEL_LEFT_FILENAME: string;
  76160. /**
  76161. * The name of the right controller model file
  76162. */
  76163. static MODEL_RIGHT_FILENAME: string;
  76164. /**
  76165. * Base Url for the Quest controller model.
  76166. */
  76167. static QUEST_MODEL_BASE_URL: string;
  76168. profileId: string;
  76169. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  76170. protected _getFilenameAndPath(): {
  76171. filename: string;
  76172. path: string;
  76173. };
  76174. protected _getModelLoadingConstraints(): boolean;
  76175. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  76176. protected _setRootMesh(meshes: AbstractMesh[]): void;
  76177. protected _updateModel(): void;
  76178. /**
  76179. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  76180. * between the touch and touch 2.
  76181. */
  76182. private _isQuest;
  76183. }
  76184. }
  76185. declare module BABYLON {
  76186. /**
  76187. * The motion controller class for the standard HTC-Vive controllers
  76188. */
  76189. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  76190. private _modelRootNode;
  76191. /**
  76192. * The base url used to load the left and right controller models
  76193. */
  76194. static MODEL_BASE_URL: string;
  76195. /**
  76196. * File name for the controller model.
  76197. */
  76198. static MODEL_FILENAME: string;
  76199. profileId: string;
  76200. /**
  76201. * Create a new Vive motion controller object
  76202. * @param scene the scene to use to create this controller
  76203. * @param gamepadObject the corresponding gamepad object
  76204. * @param handedness the handedness of the controller
  76205. */
  76206. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  76207. protected _getFilenameAndPath(): {
  76208. filename: string;
  76209. path: string;
  76210. };
  76211. protected _getModelLoadingConstraints(): boolean;
  76212. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  76213. protected _setRootMesh(meshes: AbstractMesh[]): void;
  76214. protected _updateModel(): void;
  76215. }
  76216. }
  76217. declare module BABYLON {
  76218. /**
  76219. * A cursor which tracks a point on a path
  76220. */
  76221. export class PathCursor {
  76222. private path;
  76223. /**
  76224. * Stores path cursor callbacks for when an onchange event is triggered
  76225. */
  76226. private _onchange;
  76227. /**
  76228. * The value of the path cursor
  76229. */
  76230. value: number;
  76231. /**
  76232. * The animation array of the path cursor
  76233. */
  76234. animations: Animation[];
  76235. /**
  76236. * Initializes the path cursor
  76237. * @param path The path to track
  76238. */
  76239. constructor(path: Path2);
  76240. /**
  76241. * Gets the cursor point on the path
  76242. * @returns A point on the path cursor at the cursor location
  76243. */
  76244. getPoint(): Vector3;
  76245. /**
  76246. * Moves the cursor ahead by the step amount
  76247. * @param step The amount to move the cursor forward
  76248. * @returns This path cursor
  76249. */
  76250. moveAhead(step?: number): PathCursor;
  76251. /**
  76252. * Moves the cursor behind by the step amount
  76253. * @param step The amount to move the cursor back
  76254. * @returns This path cursor
  76255. */
  76256. moveBack(step?: number): PathCursor;
  76257. /**
  76258. * Moves the cursor by the step amount
  76259. * If the step amount is greater than one, an exception is thrown
  76260. * @param step The amount to move the cursor
  76261. * @returns This path cursor
  76262. */
  76263. move(step: number): PathCursor;
  76264. /**
  76265. * Ensures that the value is limited between zero and one
  76266. * @returns This path cursor
  76267. */
  76268. private ensureLimits;
  76269. /**
  76270. * Runs onchange callbacks on change (used by the animation engine)
  76271. * @returns This path cursor
  76272. */
  76273. private raiseOnChange;
  76274. /**
  76275. * Executes a function on change
  76276. * @param f A path cursor onchange callback
  76277. * @returns This path cursor
  76278. */
  76279. onchange(f: (cursor: PathCursor) => void): PathCursor;
  76280. }
  76281. }
  76282. declare module BABYLON {
  76283. /** @hidden */
  76284. export var blurPixelShader: {
  76285. name: string;
  76286. shader: string;
  76287. };
  76288. }
  76289. declare module BABYLON {
  76290. /** @hidden */
  76291. export var pointCloudVertexDeclaration: {
  76292. name: string;
  76293. shader: string;
  76294. };
  76295. }
  76296. // Mixins
  76297. interface Window {
  76298. mozIndexedDB: IDBFactory;
  76299. webkitIndexedDB: IDBFactory;
  76300. msIndexedDB: IDBFactory;
  76301. webkitURL: typeof URL;
  76302. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  76303. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  76304. WebGLRenderingContext: WebGLRenderingContext;
  76305. MSGesture: MSGesture;
  76306. CANNON: any;
  76307. AudioContext: AudioContext;
  76308. webkitAudioContext: AudioContext;
  76309. PointerEvent: any;
  76310. Math: Math;
  76311. Uint8Array: Uint8ArrayConstructor;
  76312. Float32Array: Float32ArrayConstructor;
  76313. mozURL: typeof URL;
  76314. msURL: typeof URL;
  76315. VRFrameData: any; // WebVR, from specs 1.1
  76316. DracoDecoderModule: any;
  76317. setImmediate(handler: (...args: any[]) => void): number;
  76318. }
  76319. interface HTMLCanvasElement {
  76320. requestPointerLock(): void;
  76321. msRequestPointerLock?(): void;
  76322. mozRequestPointerLock?(): void;
  76323. webkitRequestPointerLock?(): void;
  76324. /** Track wether a record is in progress */
  76325. isRecording: boolean;
  76326. /** Capture Stream method defined by some browsers */
  76327. captureStream(fps?: number): MediaStream;
  76328. }
  76329. interface CanvasRenderingContext2D {
  76330. msImageSmoothingEnabled: boolean;
  76331. }
  76332. interface MouseEvent {
  76333. mozMovementX: number;
  76334. mozMovementY: number;
  76335. webkitMovementX: number;
  76336. webkitMovementY: number;
  76337. msMovementX: number;
  76338. msMovementY: number;
  76339. }
  76340. interface Navigator {
  76341. mozGetVRDevices: (any: any) => any;
  76342. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  76343. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  76344. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  76345. webkitGetGamepads(): Gamepad[];
  76346. msGetGamepads(): Gamepad[];
  76347. webkitGamepads(): Gamepad[];
  76348. }
  76349. interface HTMLVideoElement {
  76350. mozSrcObject: any;
  76351. }
  76352. interface Math {
  76353. fround(x: number): number;
  76354. imul(a: number, b: number): number;
  76355. }
  76356. interface WebGLRenderingContext {
  76357. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  76358. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  76359. vertexAttribDivisor(index: number, divisor: number): void;
  76360. createVertexArray(): any;
  76361. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  76362. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  76363. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  76364. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  76365. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  76366. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  76367. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  76368. // Queries
  76369. createQuery(): WebGLQuery;
  76370. deleteQuery(query: WebGLQuery): void;
  76371. beginQuery(target: number, query: WebGLQuery): void;
  76372. endQuery(target: number): void;
  76373. getQueryParameter(query: WebGLQuery, pname: number): any;
  76374. getQuery(target: number, pname: number): any;
  76375. MAX_SAMPLES: number;
  76376. RGBA8: number;
  76377. READ_FRAMEBUFFER: number;
  76378. DRAW_FRAMEBUFFER: number;
  76379. UNIFORM_BUFFER: number;
  76380. HALF_FLOAT_OES: number;
  76381. RGBA16F: number;
  76382. RGBA32F: number;
  76383. R32F: number;
  76384. RG32F: number;
  76385. RGB32F: number;
  76386. R16F: number;
  76387. RG16F: number;
  76388. RGB16F: number;
  76389. RED: number;
  76390. RG: number;
  76391. R8: number;
  76392. RG8: number;
  76393. UNSIGNED_INT_24_8: number;
  76394. DEPTH24_STENCIL8: number;
  76395. MIN: number;
  76396. MAX: number;
  76397. /* Multiple Render Targets */
  76398. drawBuffers(buffers: number[]): void;
  76399. readBuffer(src: number): void;
  76400. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  76401. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  76402. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  76403. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  76404. // Occlusion Query
  76405. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  76406. ANY_SAMPLES_PASSED: number;
  76407. QUERY_RESULT_AVAILABLE: number;
  76408. QUERY_RESULT: number;
  76409. }
  76410. interface WebGLProgram {
  76411. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  76412. }
  76413. interface EXT_disjoint_timer_query {
  76414. QUERY_COUNTER_BITS_EXT: number;
  76415. TIME_ELAPSED_EXT: number;
  76416. TIMESTAMP_EXT: number;
  76417. GPU_DISJOINT_EXT: number;
  76418. QUERY_RESULT_EXT: number;
  76419. QUERY_RESULT_AVAILABLE_EXT: number;
  76420. queryCounterEXT(query: WebGLQuery, target: number): void;
  76421. createQueryEXT(): WebGLQuery;
  76422. beginQueryEXT(target: number, query: WebGLQuery): void;
  76423. endQueryEXT(target: number): void;
  76424. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  76425. deleteQueryEXT(query: WebGLQuery): void;
  76426. }
  76427. interface WebGLUniformLocation {
  76428. _currentState: any;
  76429. }
  76430. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  76431. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  76432. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  76433. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  76434. interface WebGLRenderingContext {
  76435. readonly RASTERIZER_DISCARD: number;
  76436. readonly DEPTH_COMPONENT24: number;
  76437. readonly TEXTURE_3D: number;
  76438. readonly TEXTURE_2D_ARRAY: number;
  76439. readonly TEXTURE_COMPARE_FUNC: number;
  76440. readonly TEXTURE_COMPARE_MODE: number;
  76441. readonly COMPARE_REF_TO_TEXTURE: number;
  76442. readonly TEXTURE_WRAP_R: number;
  76443. readonly HALF_FLOAT: number;
  76444. readonly RGB8: number;
  76445. readonly RED_INTEGER: number;
  76446. readonly RG_INTEGER: number;
  76447. readonly RGB_INTEGER: number;
  76448. readonly RGBA_INTEGER: number;
  76449. readonly R8_SNORM: number;
  76450. readonly RG8_SNORM: number;
  76451. readonly RGB8_SNORM: number;
  76452. readonly RGBA8_SNORM: number;
  76453. readonly R8I: number;
  76454. readonly RG8I: number;
  76455. readonly RGB8I: number;
  76456. readonly RGBA8I: number;
  76457. readonly R8UI: number;
  76458. readonly RG8UI: number;
  76459. readonly RGB8UI: number;
  76460. readonly RGBA8UI: number;
  76461. readonly R16I: number;
  76462. readonly RG16I: number;
  76463. readonly RGB16I: number;
  76464. readonly RGBA16I: number;
  76465. readonly R16UI: number;
  76466. readonly RG16UI: number;
  76467. readonly RGB16UI: number;
  76468. readonly RGBA16UI: number;
  76469. readonly R32I: number;
  76470. readonly RG32I: number;
  76471. readonly RGB32I: number;
  76472. readonly RGBA32I: number;
  76473. readonly R32UI: number;
  76474. readonly RG32UI: number;
  76475. readonly RGB32UI: number;
  76476. readonly RGBA32UI: number;
  76477. readonly RGB10_A2UI: number;
  76478. readonly R11F_G11F_B10F: number;
  76479. readonly RGB9_E5: number;
  76480. readonly RGB10_A2: number;
  76481. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  76482. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  76483. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  76484. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  76485. readonly DEPTH_COMPONENT32F: number;
  76486. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  76487. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  76488. 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;
  76489. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  76490. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  76491. readonly TRANSFORM_FEEDBACK: number;
  76492. readonly INTERLEAVED_ATTRIBS: number;
  76493. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  76494. createTransformFeedback(): WebGLTransformFeedback;
  76495. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  76496. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  76497. beginTransformFeedback(primitiveMode: number): void;
  76498. endTransformFeedback(): void;
  76499. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  76500. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  76501. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  76502. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  76503. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  76504. }
  76505. interface ImageBitmap {
  76506. readonly width: number;
  76507. readonly height: number;
  76508. close(): void;
  76509. }
  76510. interface WebGLQuery extends WebGLObject {
  76511. }
  76512. declare var WebGLQuery: {
  76513. prototype: WebGLQuery;
  76514. new(): WebGLQuery;
  76515. };
  76516. interface WebGLSampler extends WebGLObject {
  76517. }
  76518. declare var WebGLSampler: {
  76519. prototype: WebGLSampler;
  76520. new(): WebGLSampler;
  76521. };
  76522. interface WebGLSync extends WebGLObject {
  76523. }
  76524. declare var WebGLSync: {
  76525. prototype: WebGLSync;
  76526. new(): WebGLSync;
  76527. };
  76528. interface WebGLTransformFeedback extends WebGLObject {
  76529. }
  76530. declare var WebGLTransformFeedback: {
  76531. prototype: WebGLTransformFeedback;
  76532. new(): WebGLTransformFeedback;
  76533. };
  76534. interface WebGLVertexArrayObject extends WebGLObject {
  76535. }
  76536. declare var WebGLVertexArrayObject: {
  76537. prototype: WebGLVertexArrayObject;
  76538. new(): WebGLVertexArrayObject;
  76539. };
  76540. // Type definitions for WebVR API
  76541. // Project: https://w3c.github.io/webvr/
  76542. // Definitions by: six a <https://github.com/lostfictions>
  76543. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  76544. interface VRDisplay extends EventTarget {
  76545. /**
  76546. * Dictionary of capabilities describing the VRDisplay.
  76547. */
  76548. readonly capabilities: VRDisplayCapabilities;
  76549. /**
  76550. * z-depth defining the far plane of the eye view frustum
  76551. * enables mapping of values in the render target depth
  76552. * attachment to scene coordinates. Initially set to 10000.0.
  76553. */
  76554. depthFar: number;
  76555. /**
  76556. * z-depth defining the near plane of the eye view frustum
  76557. * enables mapping of values in the render target depth
  76558. * attachment to scene coordinates. Initially set to 0.01.
  76559. */
  76560. depthNear: number;
  76561. /**
  76562. * An identifier for this distinct VRDisplay. Used as an
  76563. * association point in the Gamepad API.
  76564. */
  76565. readonly displayId: number;
  76566. /**
  76567. * A display name, a user-readable name identifying it.
  76568. */
  76569. readonly displayName: string;
  76570. readonly isConnected: boolean;
  76571. readonly isPresenting: boolean;
  76572. /**
  76573. * If this VRDisplay supports room-scale experiences, the optional
  76574. * stage attribute contains details on the room-scale parameters.
  76575. */
  76576. readonly stageParameters: VRStageParameters | null;
  76577. /**
  76578. * Passing the value returned by `requestAnimationFrame` to
  76579. * `cancelAnimationFrame` will unregister the callback.
  76580. * @param handle Define the hanle of the request to cancel
  76581. */
  76582. cancelAnimationFrame(handle: number): void;
  76583. /**
  76584. * Stops presenting to the VRDisplay.
  76585. * @returns a promise to know when it stopped
  76586. */
  76587. exitPresent(): Promise<void>;
  76588. /**
  76589. * Return the current VREyeParameters for the given eye.
  76590. * @param whichEye Define the eye we want the parameter for
  76591. * @returns the eye parameters
  76592. */
  76593. getEyeParameters(whichEye: string): VREyeParameters;
  76594. /**
  76595. * Populates the passed VRFrameData with the information required to render
  76596. * the current frame.
  76597. * @param frameData Define the data structure to populate
  76598. * @returns true if ok otherwise false
  76599. */
  76600. getFrameData(frameData: VRFrameData): boolean;
  76601. /**
  76602. * Get the layers currently being presented.
  76603. * @returns the list of VR layers
  76604. */
  76605. getLayers(): VRLayer[];
  76606. /**
  76607. * Return a VRPose containing the future predicted pose of the VRDisplay
  76608. * when the current frame will be presented. The value returned will not
  76609. * change until JavaScript has returned control to the browser.
  76610. *
  76611. * The VRPose will contain the position, orientation, velocity,
  76612. * and acceleration of each of these properties.
  76613. * @returns the pose object
  76614. */
  76615. getPose(): VRPose;
  76616. /**
  76617. * Return the current instantaneous pose of the VRDisplay, with no
  76618. * prediction applied.
  76619. * @returns the current instantaneous pose
  76620. */
  76621. getImmediatePose(): VRPose;
  76622. /**
  76623. * The callback passed to `requestAnimationFrame` will be called
  76624. * any time a new frame should be rendered. When the VRDisplay is
  76625. * presenting the callback will be called at the native refresh
  76626. * rate of the HMD. When not presenting this function acts
  76627. * identically to how window.requestAnimationFrame acts. Content should
  76628. * make no assumptions of frame rate or vsync behavior as the HMD runs
  76629. * asynchronously from other displays and at differing refresh rates.
  76630. * @param callback Define the eaction to run next frame
  76631. * @returns the request handle it
  76632. */
  76633. requestAnimationFrame(callback: FrameRequestCallback): number;
  76634. /**
  76635. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  76636. * Repeat calls while already presenting will update the VRLayers being displayed.
  76637. * @param layers Define the list of layer to present
  76638. * @returns a promise to know when the request has been fulfilled
  76639. */
  76640. requestPresent(layers: VRLayer[]): Promise<void>;
  76641. /**
  76642. * Reset the pose for this display, treating its current position and
  76643. * orientation as the "origin/zero" values. VRPose.position,
  76644. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  76645. * updated when calling resetPose(). This should be called in only
  76646. * sitting-space experiences.
  76647. */
  76648. resetPose(): void;
  76649. /**
  76650. * The VRLayer provided to the VRDisplay will be captured and presented
  76651. * in the HMD. Calling this function has the same effect on the source
  76652. * canvas as any other operation that uses its source image, and canvases
  76653. * created without preserveDrawingBuffer set to true will be cleared.
  76654. * @param pose Define the pose to submit
  76655. */
  76656. submitFrame(pose?: VRPose): void;
  76657. }
  76658. declare var VRDisplay: {
  76659. prototype: VRDisplay;
  76660. new(): VRDisplay;
  76661. };
  76662. interface VRLayer {
  76663. leftBounds?: number[] | Float32Array | null;
  76664. rightBounds?: number[] | Float32Array | null;
  76665. source?: HTMLCanvasElement | null;
  76666. }
  76667. interface VRDisplayCapabilities {
  76668. readonly canPresent: boolean;
  76669. readonly hasExternalDisplay: boolean;
  76670. readonly hasOrientation: boolean;
  76671. readonly hasPosition: boolean;
  76672. readonly maxLayers: number;
  76673. }
  76674. interface VREyeParameters {
  76675. /** @deprecated */
  76676. readonly fieldOfView: VRFieldOfView;
  76677. readonly offset: Float32Array;
  76678. readonly renderHeight: number;
  76679. readonly renderWidth: number;
  76680. }
  76681. interface VRFieldOfView {
  76682. readonly downDegrees: number;
  76683. readonly leftDegrees: number;
  76684. readonly rightDegrees: number;
  76685. readonly upDegrees: number;
  76686. }
  76687. interface VRFrameData {
  76688. readonly leftProjectionMatrix: Float32Array;
  76689. readonly leftViewMatrix: Float32Array;
  76690. readonly pose: VRPose;
  76691. readonly rightProjectionMatrix: Float32Array;
  76692. readonly rightViewMatrix: Float32Array;
  76693. readonly timestamp: number;
  76694. }
  76695. interface VRPose {
  76696. readonly angularAcceleration: Float32Array | null;
  76697. readonly angularVelocity: Float32Array | null;
  76698. readonly linearAcceleration: Float32Array | null;
  76699. readonly linearVelocity: Float32Array | null;
  76700. readonly orientation: Float32Array | null;
  76701. readonly position: Float32Array | null;
  76702. readonly timestamp: number;
  76703. }
  76704. interface VRStageParameters {
  76705. sittingToStandingTransform?: Float32Array;
  76706. sizeX?: number;
  76707. sizeY?: number;
  76708. }
  76709. interface Navigator {
  76710. getVRDisplays(): Promise<VRDisplay[]>;
  76711. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  76712. }
  76713. interface Window {
  76714. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  76715. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  76716. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  76717. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  76718. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  76719. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  76720. }
  76721. interface Gamepad {
  76722. readonly displayId: number;
  76723. }
  76724. type XRSessionMode = "inline" | "immersive-vr" | "immersive-ar";
  76725. type XRReferenceSpaceType = "viewer" | "local" | "local-floor" | "bounded-floor" | "unbounded";
  76726. type XREnvironmentBlendMode = "opaque" | "additive" | "alpha-blend";
  76727. type XRVisibilityState = "visible" | "visible-blurred" | "hidden";
  76728. type XRHandedness = "none" | "left" | "right";
  76729. type XRTargetRayMode = "gaze" | "tracked-pointer" | "screen";
  76730. type XREye = "none" | "left" | "right";
  76731. type XREventType = "devicechange" | "visibilitychange" | "end" | "inputsourceschange" | "select" | "selectstart" | "selectend" | "squeeze" | "squeezestart" | "squeezeend" | "reset";
  76732. interface XRSpace extends EventTarget {}
  76733. interface XRRenderState {
  76734. depthNear?: number;
  76735. depthFar?: number;
  76736. inlineVerticalFieldOfView?: number;
  76737. baseLayer?: XRWebGLLayer;
  76738. }
  76739. interface XRInputSource {
  76740. handedness: XRHandedness;
  76741. targetRayMode: XRTargetRayMode;
  76742. targetRaySpace: XRSpace;
  76743. gripSpace: XRSpace | undefined;
  76744. gamepad: Gamepad | undefined;
  76745. profiles: Array<string>;
  76746. hand: XRHand | undefined;
  76747. }
  76748. interface XRSessionInit {
  76749. optionalFeatures?: string[];
  76750. requiredFeatures?: string[];
  76751. }
  76752. interface XRSession {
  76753. addEventListener: Function;
  76754. removeEventListener: Function;
  76755. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  76756. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  76757. requestAnimationFrame: Function;
  76758. end(): Promise<void>;
  76759. renderState: XRRenderState;
  76760. inputSources: Array<XRInputSource>;
  76761. // hit test
  76762. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  76763. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  76764. // legacy AR hit test
  76765. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  76766. // legacy plane detection
  76767. updateWorldTrackingState(options: { planeDetectionState?: { enabled: boolean } }): void;
  76768. }
  76769. interface XRReferenceSpace extends XRSpace {
  76770. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  76771. onreset: any;
  76772. }
  76773. type XRPlaneSet = Set<XRPlane>;
  76774. type XRAnchorSet = Set<XRAnchor>;
  76775. interface XRFrame {
  76776. session: XRSession;
  76777. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  76778. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  76779. // AR
  76780. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult>;
  76781. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  76782. // Anchors
  76783. trackedAnchors?: XRAnchorSet;
  76784. createAnchor(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  76785. // Planes
  76786. worldInformation: {
  76787. detectedPlanes?: XRPlaneSet;
  76788. };
  76789. // Hand tracking
  76790. getJointPose(joint: XRJointSpace, baseSpace: XRSpace): XRJointPose;
  76791. }
  76792. interface XRViewerPose extends XRPose {
  76793. views: Array<XRView>;
  76794. }
  76795. interface XRPose {
  76796. transform: XRRigidTransform;
  76797. emulatedPosition: boolean;
  76798. }
  76799. interface XRWebGLLayerOptions {
  76800. antialias?: boolean;
  76801. depth?: boolean;
  76802. stencil?: boolean;
  76803. alpha?: boolean;
  76804. multiview?: boolean;
  76805. framebufferScaleFactor?: number;
  76806. }
  76807. declare var XRWebGLLayer: {
  76808. prototype: XRWebGLLayer;
  76809. new (session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  76810. };
  76811. interface XRWebGLLayer {
  76812. framebuffer: WebGLFramebuffer;
  76813. framebufferWidth: number;
  76814. framebufferHeight: number;
  76815. getViewport: Function;
  76816. }
  76817. declare class XRRigidTransform {
  76818. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  76819. position: DOMPointReadOnly;
  76820. orientation: DOMPointReadOnly;
  76821. matrix: Float32Array;
  76822. inverse: XRRigidTransform;
  76823. }
  76824. interface XRView {
  76825. eye: XREye;
  76826. projectionMatrix: Float32Array;
  76827. transform: XRRigidTransform;
  76828. }
  76829. interface XRInputSourceChangeEvent {
  76830. session: XRSession;
  76831. removed: Array<XRInputSource>;
  76832. added: Array<XRInputSource>;
  76833. }
  76834. interface XRInputSourceEvent extends Event {
  76835. readonly frame: XRFrame;
  76836. readonly inputSource: XRInputSource;
  76837. }
  76838. // Experimental(er) features
  76839. declare class XRRay {
  76840. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  76841. origin: DOMPointReadOnly;
  76842. direction: DOMPointReadOnly;
  76843. matrix: Float32Array;
  76844. }
  76845. declare enum XRHitTestTrackableType {
  76846. "point",
  76847. "plane",
  76848. "mesh",
  76849. }
  76850. interface XRHitResult {
  76851. hitMatrix: Float32Array;
  76852. }
  76853. interface XRTransientInputHitTestResult {
  76854. readonly inputSource: XRInputSource;
  76855. readonly results: Array<XRHitTestResult>;
  76856. }
  76857. interface XRHitTestResult {
  76858. getPose(baseSpace: XRSpace): XRPose | undefined;
  76859. // When anchor system is enabled
  76860. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  76861. }
  76862. interface XRHitTestSource {
  76863. cancel(): void;
  76864. }
  76865. interface XRTransientInputHitTestSource {
  76866. cancel(): void;
  76867. }
  76868. interface XRHitTestOptionsInit {
  76869. space: XRSpace;
  76870. entityTypes?: Array<XRHitTestTrackableType>;
  76871. offsetRay?: XRRay;
  76872. }
  76873. interface XRTransientInputHitTestOptionsInit {
  76874. profile: string;
  76875. entityTypes?: Array<XRHitTestTrackableType>;
  76876. offsetRay?: XRRay;
  76877. }
  76878. interface XRAnchor {
  76879. anchorSpace: XRSpace;
  76880. delete(): void;
  76881. }
  76882. interface XRPlane {
  76883. orientation: "Horizontal" | "Vertical";
  76884. planeSpace: XRSpace;
  76885. polygon: Array<DOMPointReadOnly>;
  76886. lastChangedTime: number;
  76887. }
  76888. interface XRJointSpace extends XRSpace {}
  76889. interface XRJointPose extends XRPose {
  76890. radius: number | undefined;
  76891. }
  76892. interface XRHand /*extends Iterablele<XRJointSpace>*/ {
  76893. readonly length: number;
  76894. [index: number]: XRJointSpace;
  76895. // Specs have the function 'joint(idx: number)', but chrome doesn't support it yet.
  76896. readonly WRIST: number;
  76897. readonly THUMB_METACARPAL: number;
  76898. readonly THUMB_PHALANX_PROXIMAL: number;
  76899. readonly THUMB_PHALANX_DISTAL: number;
  76900. readonly THUMB_PHALANX_TIP: number;
  76901. readonly INDEX_METACARPAL: number;
  76902. readonly INDEX_PHALANX_PROXIMAL: number;
  76903. readonly INDEX_PHALANX_INTERMEDIATE: number;
  76904. readonly INDEX_PHALANX_DISTAL: number;
  76905. readonly INDEX_PHALANX_TIP: number;
  76906. readonly MIDDLE_METACARPAL: number;
  76907. readonly MIDDLE_PHALANX_PROXIMAL: number;
  76908. readonly MIDDLE_PHALANX_INTERMEDIATE: number;
  76909. readonly MIDDLE_PHALANX_DISTAL: number;
  76910. readonly MIDDLE_PHALANX_TIP: number;
  76911. readonly RING_METACARPAL: number;
  76912. readonly RING_PHALANX_PROXIMAL: number;
  76913. readonly RING_PHALANX_INTERMEDIATE: number;
  76914. readonly RING_PHALANX_DISTAL: number;
  76915. readonly RING_PHALANX_TIP: number;
  76916. readonly LITTLE_METACARPAL: number;
  76917. readonly LITTLE_PHALANX_PROXIMAL: number;
  76918. readonly LITTLE_PHALANX_INTERMEDIATE: number;
  76919. readonly LITTLE_PHALANX_DISTAL: number;
  76920. readonly LITTLE_PHALANX_TIP: number;
  76921. }
  76922. // This file contains native only extensions for WebXR These APIs are not supported in the browser yet.
  76923. // They are intended for use with either Babylon Native https://github.com/BabylonJS/BabylonNative or
  76924. // Babylon React Native: https://github.com/BabylonJS/BabylonReactNative
  76925. interface XRSession {
  76926. trySetFeaturePointCloudEnabled(enabled: boolean): boolean;
  76927. }
  76928. interface XRFrame {
  76929. featurePointCloud? : Array<number>;
  76930. }
  76931. /**
  76932. * @ignore
  76933. */
  76934. declare module BABYLON.GLTF2.Exporter {
  76935. }
  76936. /**
  76937. * @ignore
  76938. */
  76939. declare module BABYLON.GLTF1 {
  76940. }
  76941. declare module BABYLON.GUI {
  76942. /**
  76943. * Class used to specific a value and its associated unit
  76944. */
  76945. export class ValueAndUnit {
  76946. /** defines the unit to store */
  76947. unit: number;
  76948. /** defines a boolean indicating if the value can be negative */
  76949. negativeValueAllowed: boolean;
  76950. private _value;
  76951. private _originalUnit;
  76952. /**
  76953. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  76954. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  76955. */
  76956. ignoreAdaptiveScaling: boolean;
  76957. /**
  76958. * Creates a new ValueAndUnit
  76959. * @param value defines the value to store
  76960. * @param unit defines the unit to store
  76961. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  76962. */
  76963. constructor(value: number,
  76964. /** defines the unit to store */
  76965. unit?: number,
  76966. /** defines a boolean indicating if the value can be negative */
  76967. negativeValueAllowed?: boolean);
  76968. /** Gets a boolean indicating if the value is a percentage */
  76969. get isPercentage(): boolean;
  76970. /** Gets a boolean indicating if the value is store as pixel */
  76971. get isPixel(): boolean;
  76972. /** Gets direct internal value */
  76973. get internalValue(): number;
  76974. /**
  76975. * Gets value as pixel
  76976. * @param host defines the root host
  76977. * @param refValue defines the reference value for percentages
  76978. * @returns the value as pixel
  76979. */
  76980. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  76981. /**
  76982. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  76983. * @param value defines the value to store
  76984. * @param unit defines the unit to store
  76985. * @returns the current ValueAndUnit
  76986. */
  76987. updateInPlace(value: number, unit?: number): ValueAndUnit;
  76988. /**
  76989. * Gets the value accordingly to its unit
  76990. * @param host defines the root host
  76991. * @returns the value
  76992. */
  76993. getValue(host: AdvancedDynamicTexture): number;
  76994. /**
  76995. * Gets a string representation of the value
  76996. * @param host defines the root host
  76997. * @param decimals defines an optional number of decimals to display
  76998. * @returns a string
  76999. */
  77000. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  77001. /**
  77002. * Store a value parsed from a string
  77003. * @param source defines the source string
  77004. * @returns true if the value was successfully parsed
  77005. */
  77006. fromString(source: string | number): boolean;
  77007. private static _Regex;
  77008. private static _UNITMODE_PERCENTAGE;
  77009. private static _UNITMODE_PIXEL;
  77010. /** UNITMODE_PERCENTAGE */
  77011. static get UNITMODE_PERCENTAGE(): number;
  77012. /** UNITMODE_PIXEL */
  77013. static get UNITMODE_PIXEL(): number;
  77014. }
  77015. }
  77016. declare module BABYLON.GUI {
  77017. /**
  77018. * Define a style used by control to automatically setup properties based on a template.
  77019. * Only support font related properties so far
  77020. */
  77021. export class Style implements BABYLON.IDisposable {
  77022. private _fontFamily;
  77023. private _fontStyle;
  77024. private _fontWeight;
  77025. /** @hidden */
  77026. _host: AdvancedDynamicTexture;
  77027. /** @hidden */
  77028. _fontSize: ValueAndUnit;
  77029. /**
  77030. * BABYLON.Observable raised when the style values are changed
  77031. */
  77032. onChangedObservable: BABYLON.Observable<Style>;
  77033. /**
  77034. * Creates a new style object
  77035. * @param host defines the AdvancedDynamicTexture which hosts this style
  77036. */
  77037. constructor(host: AdvancedDynamicTexture);
  77038. /**
  77039. * Gets or sets the font size
  77040. */
  77041. get fontSize(): string | number;
  77042. set fontSize(value: string | number);
  77043. /**
  77044. * Gets or sets the font family
  77045. */
  77046. get fontFamily(): string;
  77047. set fontFamily(value: string);
  77048. /**
  77049. * Gets or sets the font style
  77050. */
  77051. get fontStyle(): string;
  77052. set fontStyle(value: string);
  77053. /** Gets or sets font weight */
  77054. get fontWeight(): string;
  77055. set fontWeight(value: string);
  77056. /** Dispose all associated resources */
  77057. dispose(): void;
  77058. }
  77059. }
  77060. declare module BABYLON.GUI {
  77061. /**
  77062. * Class used to transport BABYLON.Vector2 information for pointer events
  77063. */
  77064. export class Vector2WithInfo extends BABYLON.Vector2 {
  77065. /** defines the current mouse button index */
  77066. buttonIndex: number;
  77067. /**
  77068. * Creates a new Vector2WithInfo
  77069. * @param source defines the vector2 data to transport
  77070. * @param buttonIndex defines the current mouse button index
  77071. */
  77072. constructor(source: BABYLON.Vector2,
  77073. /** defines the current mouse button index */
  77074. buttonIndex?: number);
  77075. }
  77076. /** Class used to provide 2D matrix features */
  77077. export class Matrix2D {
  77078. /** Gets the internal array of 6 floats used to store matrix data */
  77079. m: Float32Array;
  77080. /**
  77081. * Creates a new matrix
  77082. * @param m00 defines value for (0, 0)
  77083. * @param m01 defines value for (0, 1)
  77084. * @param m10 defines value for (1, 0)
  77085. * @param m11 defines value for (1, 1)
  77086. * @param m20 defines value for (2, 0)
  77087. * @param m21 defines value for (2, 1)
  77088. */
  77089. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  77090. /**
  77091. * Fills the matrix from direct values
  77092. * @param m00 defines value for (0, 0)
  77093. * @param m01 defines value for (0, 1)
  77094. * @param m10 defines value for (1, 0)
  77095. * @param m11 defines value for (1, 1)
  77096. * @param m20 defines value for (2, 0)
  77097. * @param m21 defines value for (2, 1)
  77098. * @returns the current modified matrix
  77099. */
  77100. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  77101. /**
  77102. * Gets matrix determinant
  77103. * @returns the determinant
  77104. */
  77105. determinant(): number;
  77106. /**
  77107. * Inverses the matrix and stores it in a target matrix
  77108. * @param result defines the target matrix
  77109. * @returns the current matrix
  77110. */
  77111. invertToRef(result: Matrix2D): Matrix2D;
  77112. /**
  77113. * Multiplies the current matrix with another one
  77114. * @param other defines the second operand
  77115. * @param result defines the target matrix
  77116. * @returns the current matrix
  77117. */
  77118. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  77119. /**
  77120. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  77121. * @param x defines the x coordinate to transform
  77122. * @param y defines the x coordinate to transform
  77123. * @param result defines the target vector2
  77124. * @returns the current matrix
  77125. */
  77126. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  77127. /**
  77128. * Creates an identity matrix
  77129. * @returns a new matrix
  77130. */
  77131. static Identity(): Matrix2D;
  77132. /**
  77133. * Creates a translation matrix and stores it in a target matrix
  77134. * @param x defines the x coordinate of the translation
  77135. * @param y defines the y coordinate of the translation
  77136. * @param result defines the target matrix
  77137. */
  77138. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  77139. /**
  77140. * Creates a scaling matrix and stores it in a target matrix
  77141. * @param x defines the x coordinate of the scaling
  77142. * @param y defines the y coordinate of the scaling
  77143. * @param result defines the target matrix
  77144. */
  77145. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  77146. /**
  77147. * Creates a rotation matrix and stores it in a target matrix
  77148. * @param angle defines the rotation angle
  77149. * @param result defines the target matrix
  77150. */
  77151. static RotationToRef(angle: number, result: Matrix2D): void;
  77152. private static _TempPreTranslationMatrix;
  77153. private static _TempPostTranslationMatrix;
  77154. private static _TempRotationMatrix;
  77155. private static _TempScalingMatrix;
  77156. private static _TempCompose0;
  77157. private static _TempCompose1;
  77158. private static _TempCompose2;
  77159. /**
  77160. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  77161. * @param tx defines the x coordinate of the translation
  77162. * @param ty defines the y coordinate of the translation
  77163. * @param angle defines the rotation angle
  77164. * @param scaleX defines the x coordinate of the scaling
  77165. * @param scaleY defines the y coordinate of the scaling
  77166. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  77167. * @param result defines the target matrix
  77168. */
  77169. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  77170. }
  77171. }
  77172. declare module BABYLON.GUI {
  77173. /**
  77174. * Class used to store 2D control sizes
  77175. */
  77176. export class Measure {
  77177. /** defines left coordinate */
  77178. left: number;
  77179. /** defines top coordinate */
  77180. top: number;
  77181. /** defines width dimension */
  77182. width: number;
  77183. /** defines height dimension */
  77184. height: number;
  77185. /**
  77186. * Creates a new measure
  77187. * @param left defines left coordinate
  77188. * @param top defines top coordinate
  77189. * @param width defines width dimension
  77190. * @param height defines height dimension
  77191. */
  77192. constructor(
  77193. /** defines left coordinate */
  77194. left: number,
  77195. /** defines top coordinate */
  77196. top: number,
  77197. /** defines width dimension */
  77198. width: number,
  77199. /** defines height dimension */
  77200. height: number);
  77201. /**
  77202. * Copy from another measure
  77203. * @param other defines the other measure to copy from
  77204. */
  77205. copyFrom(other: Measure): void;
  77206. /**
  77207. * Copy from a group of 4 floats
  77208. * @param left defines left coordinate
  77209. * @param top defines top coordinate
  77210. * @param width defines width dimension
  77211. * @param height defines height dimension
  77212. */
  77213. copyFromFloats(left: number, top: number, width: number, height: number): void;
  77214. /**
  77215. * Computes the axis aligned bounding box measure for two given measures
  77216. * @param a Input measure
  77217. * @param b Input measure
  77218. * @param result the resulting bounding measure
  77219. */
  77220. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  77221. /**
  77222. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  77223. * @param transform the matrix to transform the measure before computing the AABB
  77224. * @param addX number to add to left
  77225. * @param addY number to add to top
  77226. * @param addWidth number to add to width
  77227. * @param addHeight number to add to height
  77228. * @param result the resulting AABB
  77229. */
  77230. addAndTransformToRef(transform: Matrix2D, addX: number, addY: number, addWidth: number, addHeight: number, result: Measure): void;
  77231. /**
  77232. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  77233. * @param transform the matrix to transform the measure before computing the AABB
  77234. * @param result the resulting AABB
  77235. */
  77236. transformToRef(transform: Matrix2D, result: Measure): void;
  77237. /**
  77238. * Check equality between this measure and another one
  77239. * @param other defines the other measures
  77240. * @returns true if both measures are equals
  77241. */
  77242. isEqualsTo(other: Measure): boolean;
  77243. /**
  77244. * Creates an empty measure
  77245. * @returns a new measure
  77246. */
  77247. static Empty(): Measure;
  77248. }
  77249. }
  77250. declare module BABYLON.GUI {
  77251. /**
  77252. * Interface used to define a control that can receive focus
  77253. */
  77254. export interface IFocusableControl {
  77255. /**
  77256. * Function called when the control receives the focus
  77257. */
  77258. onFocus(): void;
  77259. /**
  77260. * Function called when the control loses the focus
  77261. */
  77262. onBlur(): void;
  77263. /**
  77264. * Function called to let the control handle keyboard events
  77265. * @param evt defines the current keyboard event
  77266. */
  77267. processKeyboard(evt: KeyboardEvent): void;
  77268. /**
  77269. * Function called to get the list of controls that should not steal the focus from this control
  77270. * @returns an array of controls
  77271. */
  77272. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  77273. }
  77274. /**
  77275. * Class used to create texture to support 2D GUI elements
  77276. * @see https://doc.babylonjs.com/how_to/gui
  77277. */
  77278. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  77279. private _isDirty;
  77280. private _renderObserver;
  77281. private _resizeObserver;
  77282. private _preKeyboardObserver;
  77283. private _pointerMoveObserver;
  77284. private _pointerObserver;
  77285. private _canvasPointerOutObserver;
  77286. private _canvasBlurObserver;
  77287. private _background;
  77288. /** @hidden */
  77289. _rootContainer: Container;
  77290. /** @hidden */
  77291. _lastPickedControl: Control;
  77292. /** @hidden */
  77293. _lastControlOver: {
  77294. [pointerId: number]: Control;
  77295. };
  77296. /** @hidden */
  77297. _lastControlDown: {
  77298. [pointerId: number]: Control;
  77299. };
  77300. /** @hidden */
  77301. _capturingControl: {
  77302. [pointerId: number]: Control;
  77303. };
  77304. /** @hidden */
  77305. _shouldBlockPointer: boolean;
  77306. /** @hidden */
  77307. _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  77308. /** @hidden */
  77309. _linkedControls: Control[];
  77310. private _isFullscreen;
  77311. private _fullscreenViewport;
  77312. private _idealWidth;
  77313. private _idealHeight;
  77314. private _useSmallestIdeal;
  77315. private _renderAtIdealSize;
  77316. private _focusedControl;
  77317. private _blockNextFocusCheck;
  77318. private _renderScale;
  77319. private _rootElement;
  77320. private _cursorChanged;
  77321. private _defaultMousePointerId;
  77322. /** @hidden */
  77323. _numLayoutCalls: number;
  77324. /** Gets the number of layout calls made the last time the ADT has been rendered */
  77325. get numLayoutCalls(): number;
  77326. /** @hidden */
  77327. _numRenderCalls: number;
  77328. /** Gets the number of render calls made the last time the ADT has been rendered */
  77329. get numRenderCalls(): number;
  77330. /**
  77331. * Define type to string to ensure compatibility across browsers
  77332. * Safari doesn't support DataTransfer constructor
  77333. */
  77334. private _clipboardData;
  77335. /**
  77336. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  77337. */
  77338. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  77339. /**
  77340. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  77341. */
  77342. onControlPickedObservable: BABYLON.Observable<Control>;
  77343. /**
  77344. * BABYLON.Observable event triggered before layout is evaluated
  77345. */
  77346. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  77347. /**
  77348. * BABYLON.Observable event triggered after the layout was evaluated
  77349. */
  77350. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  77351. /**
  77352. * BABYLON.Observable event triggered before the texture is rendered
  77353. */
  77354. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  77355. /**
  77356. * BABYLON.Observable event triggered after the texture was rendered
  77357. */
  77358. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  77359. /**
  77360. * Gets or sets a boolean defining if alpha is stored as premultiplied
  77361. */
  77362. premulAlpha: boolean;
  77363. /**
  77364. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  77365. * Useful when you want more antialiasing
  77366. */
  77367. get renderScale(): number;
  77368. set renderScale(value: number);
  77369. /** Gets or sets the background color */
  77370. get background(): string;
  77371. set background(value: string);
  77372. /**
  77373. * Gets or sets the ideal width used to design controls.
  77374. * The GUI will then rescale everything accordingly
  77375. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  77376. */
  77377. get idealWidth(): number;
  77378. set idealWidth(value: number);
  77379. /**
  77380. * Gets or sets the ideal height used to design controls.
  77381. * The GUI will then rescale everything accordingly
  77382. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  77383. */
  77384. get idealHeight(): number;
  77385. set idealHeight(value: number);
  77386. /**
  77387. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  77388. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  77389. */
  77390. get useSmallestIdeal(): boolean;
  77391. set useSmallestIdeal(value: boolean);
  77392. /**
  77393. * Gets or sets a boolean indicating if adaptive scaling must be used
  77394. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  77395. */
  77396. get renderAtIdealSize(): boolean;
  77397. set renderAtIdealSize(value: boolean);
  77398. /**
  77399. * Gets the ratio used when in "ideal mode"
  77400. * @see https://doc.babylonjs.com/how_to/gui#adaptive-scaling
  77401. * */
  77402. get idealRatio(): number;
  77403. /**
  77404. * Gets the underlying layer used to render the texture when in fullscreen mode
  77405. */
  77406. get layer(): BABYLON.Nullable<BABYLON.Layer>;
  77407. /**
  77408. * Gets the root container control
  77409. */
  77410. get rootContainer(): Container;
  77411. /**
  77412. * Returns an array containing the root container.
  77413. * This is mostly used to let the Inspector introspects the ADT
  77414. * @returns an array containing the rootContainer
  77415. */
  77416. getChildren(): Array<Container>;
  77417. /**
  77418. * Will return all controls that are inside this texture
  77419. * @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
  77420. * @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
  77421. * @return all child controls
  77422. */
  77423. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  77424. /**
  77425. * Gets or sets the current focused control
  77426. */
  77427. get focusedControl(): BABYLON.Nullable<IFocusableControl>;
  77428. set focusedControl(control: BABYLON.Nullable<IFocusableControl>);
  77429. /**
  77430. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  77431. */
  77432. get isForeground(): boolean;
  77433. set isForeground(value: boolean);
  77434. /**
  77435. * Gets or set information about clipboardData
  77436. */
  77437. get clipboardData(): string;
  77438. set clipboardData(value: string);
  77439. /**
  77440. * Creates a new AdvancedDynamicTexture
  77441. * @param name defines the name of the texture
  77442. * @param width defines the width of the texture
  77443. * @param height defines the height of the texture
  77444. * @param scene defines the hosting scene
  77445. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  77446. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  77447. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  77448. */
  77449. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number, invertY?: boolean);
  77450. /**
  77451. * Get the current class name of the texture useful for serialization or dynamic coding.
  77452. * @returns "AdvancedDynamicTexture"
  77453. */
  77454. getClassName(): string;
  77455. /**
  77456. * Function used to execute a function on all controls
  77457. * @param func defines the function to execute
  77458. * @param container defines the container where controls belong. If null the root container will be used
  77459. */
  77460. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  77461. private _useInvalidateRectOptimization;
  77462. /**
  77463. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  77464. */
  77465. get useInvalidateRectOptimization(): boolean;
  77466. set useInvalidateRectOptimization(value: boolean);
  77467. private _invalidatedRectangle;
  77468. /**
  77469. * Invalidates a rectangle area on the gui texture
  77470. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  77471. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  77472. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  77473. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  77474. */
  77475. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  77476. /**
  77477. * Marks the texture as dirty forcing a complete update
  77478. */
  77479. markAsDirty(): void;
  77480. /**
  77481. * Helper function used to create a new style
  77482. * @returns a new style
  77483. * @see https://doc.babylonjs.com/how_to/gui#styles
  77484. */
  77485. createStyle(): Style;
  77486. /**
  77487. * Adds a new control to the root container
  77488. * @param control defines the control to add
  77489. * @returns the current texture
  77490. */
  77491. addControl(control: Control): AdvancedDynamicTexture;
  77492. /**
  77493. * Removes a control from the root container
  77494. * @param control defines the control to remove
  77495. * @returns the current texture
  77496. */
  77497. removeControl(control: Control): AdvancedDynamicTexture;
  77498. /**
  77499. * Release all resources
  77500. */
  77501. dispose(): void;
  77502. private _onResize;
  77503. /** @hidden */
  77504. _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  77505. /**
  77506. * Get screen coordinates for a vector3
  77507. * @param position defines the position to project
  77508. * @param worldMatrix defines the world matrix to use
  77509. * @returns the projected position
  77510. */
  77511. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  77512. private _checkUpdate;
  77513. private _clearMeasure;
  77514. private _render;
  77515. /** @hidden */
  77516. _changeCursor(cursor: string): void;
  77517. /** @hidden */
  77518. _registerLastControlDown(control: Control, pointerId: number): void;
  77519. private _doPicking;
  77520. /** @hidden */
  77521. _cleanControlAfterRemovalFromList(list: {
  77522. [pointerId: number]: Control;
  77523. }, control: Control): void;
  77524. /** @hidden */
  77525. _cleanControlAfterRemoval(control: Control): void;
  77526. /** Attach to all scene events required to support pointer events */
  77527. attach(): void;
  77528. /** @hidden */
  77529. private onClipboardCopy;
  77530. /** @hidden */
  77531. private onClipboardCut;
  77532. /** @hidden */
  77533. private onClipboardPaste;
  77534. /**
  77535. * Register the clipboard Events onto the canvas
  77536. */
  77537. registerClipboardEvents(): void;
  77538. /**
  77539. * Unregister the clipboard Events from the canvas
  77540. */
  77541. unRegisterClipboardEvents(): void;
  77542. /**
  77543. * Connect the texture to a hosting mesh to enable interactions
  77544. * @param mesh defines the mesh to attach to
  77545. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  77546. */
  77547. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  77548. /**
  77549. * Move the focus to a specific control
  77550. * @param control defines the control which will receive the focus
  77551. */
  77552. moveFocusToControl(control: IFocusableControl): void;
  77553. private _manageFocus;
  77554. private _attachToOnPointerOut;
  77555. private _attachToOnBlur;
  77556. /**
  77557. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  77558. * @param mesh defines the mesh which will receive the texture
  77559. * @param width defines the texture width (1024 by default)
  77560. * @param height defines the texture height (1024 by default)
  77561. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  77562. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  77563. * @param invertY defines if the texture needs to be inverted on the y axis during loading (true by default)
  77564. * @returns a new AdvancedDynamicTexture
  77565. */
  77566. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean, invertY?: boolean): AdvancedDynamicTexture;
  77567. /**
  77568. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  77569. * In this mode the texture will rely on a layer for its rendering.
  77570. * This allows it to be treated like any other layer.
  77571. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  77572. * LayerMask is set through advancedTexture.layer.layerMask
  77573. * @param name defines name for the texture
  77574. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  77575. * @param scene defines the hsoting scene
  77576. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  77577. * @returns a new AdvancedDynamicTexture
  77578. */
  77579. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  77580. }
  77581. }
  77582. declare module BABYLON.GUI {
  77583. /**
  77584. * Root class used for all 2D controls
  77585. * @see https://doc.babylonjs.com/how_to/gui#controls
  77586. */
  77587. export class Control {
  77588. /** defines the name of the control */
  77589. name?: string | undefined;
  77590. /**
  77591. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  77592. */
  77593. static AllowAlphaInheritance: boolean;
  77594. private _alpha;
  77595. private _alphaSet;
  77596. private _zIndex;
  77597. /** @hidden */
  77598. _host: AdvancedDynamicTexture;
  77599. /** Gets or sets the control parent */
  77600. parent: BABYLON.Nullable<Container>;
  77601. /** @hidden */
  77602. _currentMeasure: Measure;
  77603. private _fontFamily;
  77604. private _fontStyle;
  77605. private _fontWeight;
  77606. private _fontSize;
  77607. private _font;
  77608. /** @hidden */
  77609. _width: ValueAndUnit;
  77610. /** @hidden */
  77611. _height: ValueAndUnit;
  77612. /** @hidden */
  77613. protected _fontOffset: {
  77614. ascent: number;
  77615. height: number;
  77616. descent: number;
  77617. };
  77618. private _color;
  77619. private _style;
  77620. private _styleObserver;
  77621. /** @hidden */
  77622. protected _horizontalAlignment: number;
  77623. /** @hidden */
  77624. protected _verticalAlignment: number;
  77625. /** @hidden */
  77626. protected _isDirty: boolean;
  77627. /** @hidden */
  77628. protected _wasDirty: boolean;
  77629. /** @hidden */
  77630. _tempParentMeasure: Measure;
  77631. /** @hidden */
  77632. _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  77633. /** @hidden */
  77634. protected _cachedParentMeasure: Measure;
  77635. private _paddingLeft;
  77636. private _paddingRight;
  77637. private _paddingTop;
  77638. private _paddingBottom;
  77639. /** @hidden */
  77640. _left: ValueAndUnit;
  77641. /** @hidden */
  77642. _top: ValueAndUnit;
  77643. private _scaleX;
  77644. private _scaleY;
  77645. private _rotation;
  77646. private _transformCenterX;
  77647. private _transformCenterY;
  77648. /** @hidden */
  77649. _transformMatrix: Matrix2D;
  77650. /** @hidden */
  77651. protected _invertTransformMatrix: Matrix2D;
  77652. /** @hidden */
  77653. protected _transformedPosition: BABYLON.Vector2;
  77654. private _isMatrixDirty;
  77655. private _cachedOffsetX;
  77656. private _cachedOffsetY;
  77657. private _isVisible;
  77658. private _isHighlighted;
  77659. /** @hidden */
  77660. _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  77661. private _fontSet;
  77662. private _dummyVector2;
  77663. private _downCount;
  77664. private _enterCount;
  77665. private _doNotRender;
  77666. private _downPointerIds;
  77667. protected _isEnabled: boolean;
  77668. protected _disabledColor: string;
  77669. protected _disabledColorItem: string;
  77670. /** @hidden */
  77671. protected _rebuildLayout: boolean;
  77672. /** @hidden */
  77673. _customData: any;
  77674. /** @hidden */
  77675. _isClipped: boolean;
  77676. /** @hidden */
  77677. _automaticSize: boolean;
  77678. /** @hidden */
  77679. _tag: any;
  77680. /**
  77681. * 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
  77682. */
  77683. uniqueId: number;
  77684. /**
  77685. * Gets or sets an object used to store user defined information for the node
  77686. */
  77687. metadata: any;
  77688. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  77689. isHitTestVisible: boolean;
  77690. /** Gets or sets a boolean indicating if the control can block pointer events */
  77691. isPointerBlocker: boolean;
  77692. /** Gets or sets a boolean indicating if the control can be focusable */
  77693. isFocusInvisible: boolean;
  77694. /**
  77695. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  77696. * 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
  77697. */
  77698. clipChildren: boolean;
  77699. /**
  77700. * Gets or sets a boolean indicating that control content must be clipped
  77701. * 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
  77702. */
  77703. clipContent: boolean;
  77704. /**
  77705. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  77706. */
  77707. useBitmapCache: boolean;
  77708. private _cacheData;
  77709. private _shadowOffsetX;
  77710. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  77711. get shadowOffsetX(): number;
  77712. set shadowOffsetX(value: number);
  77713. private _shadowOffsetY;
  77714. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  77715. get shadowOffsetY(): number;
  77716. set shadowOffsetY(value: number);
  77717. private _shadowBlur;
  77718. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  77719. get shadowBlur(): number;
  77720. set shadowBlur(value: number);
  77721. private _shadowColor;
  77722. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  77723. get shadowColor(): string;
  77724. set shadowColor(value: string);
  77725. /** Gets or sets the cursor to use when the control is hovered */
  77726. hoverCursor: string;
  77727. /** @hidden */
  77728. protected _linkOffsetX: ValueAndUnit;
  77729. /** @hidden */
  77730. protected _linkOffsetY: ValueAndUnit;
  77731. /** Gets the control type name */
  77732. get typeName(): string;
  77733. /**
  77734. * Get the current class name of the control.
  77735. * @returns current class name
  77736. */
  77737. getClassName(): string;
  77738. /**
  77739. * An event triggered when pointer wheel is scrolled
  77740. */
  77741. onWheelObservable: BABYLON.Observable<BABYLON.Vector2>;
  77742. /**
  77743. * An event triggered when the pointer move over the control.
  77744. */
  77745. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  77746. /**
  77747. * An event triggered when the pointer move out of the control.
  77748. */
  77749. onPointerOutObservable: BABYLON.Observable<Control>;
  77750. /**
  77751. * An event triggered when the pointer taps the control
  77752. */
  77753. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  77754. /**
  77755. * An event triggered when pointer up
  77756. */
  77757. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  77758. /**
  77759. * An event triggered when a control is clicked on
  77760. */
  77761. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  77762. /**
  77763. * An event triggered when pointer enters the control
  77764. */
  77765. onPointerEnterObservable: BABYLON.Observable<Control>;
  77766. /**
  77767. * An event triggered when the control is marked as dirty
  77768. */
  77769. onDirtyObservable: BABYLON.Observable<Control>;
  77770. /**
  77771. * An event triggered before drawing the control
  77772. */
  77773. onBeforeDrawObservable: BABYLON.Observable<Control>;
  77774. /**
  77775. * An event triggered after the control was drawn
  77776. */
  77777. onAfterDrawObservable: BABYLON.Observable<Control>;
  77778. /**
  77779. * An event triggered when the control has been disposed
  77780. */
  77781. onDisposeObservable: BABYLON.Observable<Control>;
  77782. /**
  77783. * Get the hosting AdvancedDynamicTexture
  77784. */
  77785. get host(): AdvancedDynamicTexture;
  77786. /** Gets or set information about font offsets (used to render and align text) */
  77787. get fontOffset(): {
  77788. ascent: number;
  77789. height: number;
  77790. descent: number;
  77791. };
  77792. set fontOffset(offset: {
  77793. ascent: number;
  77794. height: number;
  77795. descent: number;
  77796. });
  77797. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  77798. get alpha(): number;
  77799. set alpha(value: number);
  77800. /**
  77801. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  77802. */
  77803. get isHighlighted(): boolean;
  77804. set isHighlighted(value: boolean);
  77805. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  77806. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  77807. */
  77808. get scaleX(): number;
  77809. set scaleX(value: number);
  77810. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  77811. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  77812. */
  77813. get scaleY(): number;
  77814. set scaleY(value: number);
  77815. /** Gets or sets the rotation angle (0 by default)
  77816. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  77817. */
  77818. get rotation(): number;
  77819. set rotation(value: number);
  77820. /** Gets or sets the transformation center on Y axis (0 by default)
  77821. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  77822. */
  77823. get transformCenterY(): number;
  77824. set transformCenterY(value: number);
  77825. /** Gets or sets the transformation center on X axis (0 by default)
  77826. * @see https://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  77827. */
  77828. get transformCenterX(): number;
  77829. set transformCenterX(value: number);
  77830. /**
  77831. * Gets or sets the horizontal alignment
  77832. * @see https://doc.babylonjs.com/how_to/gui#alignments
  77833. */
  77834. get horizontalAlignment(): number;
  77835. set horizontalAlignment(value: number);
  77836. /**
  77837. * Gets or sets the vertical alignment
  77838. * @see https://doc.babylonjs.com/how_to/gui#alignments
  77839. */
  77840. get verticalAlignment(): number;
  77841. set verticalAlignment(value: number);
  77842. /**
  77843. * Gets or sets a fixed ratio for this control.
  77844. * When different from 0, the ratio is used to compute the "second" dimension.
  77845. * The first dimension used in the computation is the last one set (by setting width / widthInPixels or height / heightInPixels), and the
  77846. * second dimension is computed as first dimension * fixedRatio
  77847. */
  77848. fixedRatio: number;
  77849. private _fixedRatioMasterIsWidth;
  77850. /**
  77851. * Gets or sets control width
  77852. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77853. */
  77854. get width(): string | number;
  77855. set width(value: string | number);
  77856. /**
  77857. * Gets or sets the control width in pixel
  77858. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77859. */
  77860. get widthInPixels(): number;
  77861. set widthInPixels(value: number);
  77862. /**
  77863. * Gets or sets control height
  77864. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77865. */
  77866. get height(): string | number;
  77867. set height(value: string | number);
  77868. /**
  77869. * Gets or sets control height in pixel
  77870. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77871. */
  77872. get heightInPixels(): number;
  77873. set heightInPixels(value: number);
  77874. /** Gets or set font family */
  77875. get fontFamily(): string;
  77876. set fontFamily(value: string);
  77877. /** Gets or sets font style */
  77878. get fontStyle(): string;
  77879. set fontStyle(value: string);
  77880. /** Gets or sets font weight */
  77881. get fontWeight(): string;
  77882. set fontWeight(value: string);
  77883. /**
  77884. * Gets or sets style
  77885. * @see https://doc.babylonjs.com/how_to/gui#styles
  77886. */
  77887. get style(): BABYLON.Nullable<Style>;
  77888. set style(value: BABYLON.Nullable<Style>);
  77889. /** @hidden */
  77890. get _isFontSizeInPercentage(): boolean;
  77891. /** Gets or sets font size in pixels */
  77892. get fontSizeInPixels(): number;
  77893. set fontSizeInPixels(value: number);
  77894. /** Gets or sets font size */
  77895. get fontSize(): string | number;
  77896. set fontSize(value: string | number);
  77897. /** Gets or sets foreground color */
  77898. get color(): string;
  77899. set color(value: string);
  77900. /** Gets or sets z index which is used to reorder controls on the z axis */
  77901. get zIndex(): number;
  77902. set zIndex(value: number);
  77903. /** Gets or sets a boolean indicating if the control can be rendered */
  77904. get notRenderable(): boolean;
  77905. set notRenderable(value: boolean);
  77906. /** Gets or sets a boolean indicating if the control is visible */
  77907. get isVisible(): boolean;
  77908. set isVisible(value: boolean);
  77909. /** Gets a boolean indicating that the control needs to update its rendering */
  77910. get isDirty(): boolean;
  77911. /**
  77912. * Gets the current linked mesh (or null if none)
  77913. */
  77914. get linkedMesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  77915. /**
  77916. * Gets or sets a value indicating the padding to use on the left of the control
  77917. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77918. */
  77919. get paddingLeft(): string | number;
  77920. set paddingLeft(value: string | number);
  77921. /**
  77922. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  77923. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77924. */
  77925. get paddingLeftInPixels(): number;
  77926. set paddingLeftInPixels(value: number);
  77927. /**
  77928. * Gets or sets a value indicating the padding to use on the right of the control
  77929. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77930. */
  77931. get paddingRight(): string | number;
  77932. set paddingRight(value: string | number);
  77933. /**
  77934. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  77935. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77936. */
  77937. get paddingRightInPixels(): number;
  77938. set paddingRightInPixels(value: number);
  77939. /**
  77940. * Gets or sets a value indicating the padding to use on the top of the control
  77941. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77942. */
  77943. get paddingTop(): string | number;
  77944. set paddingTop(value: string | number);
  77945. /**
  77946. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  77947. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77948. */
  77949. get paddingTopInPixels(): number;
  77950. set paddingTopInPixels(value: number);
  77951. /**
  77952. * Gets or sets a value indicating the padding to use on the bottom of the control
  77953. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77954. */
  77955. get paddingBottom(): string | number;
  77956. set paddingBottom(value: string | number);
  77957. /**
  77958. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  77959. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77960. */
  77961. get paddingBottomInPixels(): number;
  77962. set paddingBottomInPixels(value: number);
  77963. /**
  77964. * Gets or sets a value indicating the left coordinate of the control
  77965. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77966. */
  77967. get left(): string | number;
  77968. set left(value: string | number);
  77969. /**
  77970. * Gets or sets a value indicating the left coordinate in pixels of the control
  77971. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77972. */
  77973. get leftInPixels(): number;
  77974. set leftInPixels(value: number);
  77975. /**
  77976. * Gets or sets a value indicating the top coordinate of the control
  77977. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77978. */
  77979. get top(): string | number;
  77980. set top(value: string | number);
  77981. /**
  77982. * Gets or sets a value indicating the top coordinate in pixels of the control
  77983. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  77984. */
  77985. get topInPixels(): number;
  77986. set topInPixels(value: number);
  77987. /**
  77988. * Gets or sets a value indicating the offset on X axis to the linked mesh
  77989. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  77990. */
  77991. get linkOffsetX(): string | number;
  77992. set linkOffsetX(value: string | number);
  77993. /**
  77994. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  77995. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  77996. */
  77997. get linkOffsetXInPixels(): number;
  77998. set linkOffsetXInPixels(value: number);
  77999. /**
  78000. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  78001. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  78002. */
  78003. get linkOffsetY(): string | number;
  78004. set linkOffsetY(value: string | number);
  78005. /**
  78006. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  78007. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  78008. */
  78009. get linkOffsetYInPixels(): number;
  78010. set linkOffsetYInPixels(value: number);
  78011. /** Gets the center coordinate on X axis */
  78012. get centerX(): number;
  78013. /** Gets the center coordinate on Y axis */
  78014. get centerY(): number;
  78015. /** Gets or sets if control is Enabled*/
  78016. get isEnabled(): boolean;
  78017. set isEnabled(value: boolean);
  78018. /** Gets or sets background color of control if it's disabled*/
  78019. get disabledColor(): string;
  78020. set disabledColor(value: string);
  78021. /** Gets or sets front color of control if it's disabled*/
  78022. get disabledColorItem(): string;
  78023. set disabledColorItem(value: string);
  78024. /**
  78025. * Creates a new control
  78026. * @param name defines the name of the control
  78027. */
  78028. constructor(
  78029. /** defines the name of the control */
  78030. name?: string | undefined);
  78031. /** @hidden */
  78032. protected _getTypeName(): string;
  78033. /**
  78034. * Gets the first ascendant in the hierarchy of the given type
  78035. * @param className defines the required type
  78036. * @returns the ascendant or null if not found
  78037. */
  78038. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  78039. /** @hidden */
  78040. _resetFontCache(): void;
  78041. /**
  78042. * Determines if a container is an ascendant of the current control
  78043. * @param container defines the container to look for
  78044. * @returns true if the container is one of the ascendant of the control
  78045. */
  78046. isAscendant(container: Control): boolean;
  78047. /**
  78048. * Gets coordinates in local control space
  78049. * @param globalCoordinates defines the coordinates to transform
  78050. * @returns the new coordinates in local space
  78051. */
  78052. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  78053. /**
  78054. * Gets coordinates in local control space
  78055. * @param globalCoordinates defines the coordinates to transform
  78056. * @param result defines the target vector2 where to store the result
  78057. * @returns the current control
  78058. */
  78059. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  78060. /**
  78061. * Gets coordinates in parent local control space
  78062. * @param globalCoordinates defines the coordinates to transform
  78063. * @returns the new coordinates in parent local space
  78064. */
  78065. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  78066. /**
  78067. * Move the current control to a vector3 position projected onto the screen.
  78068. * @param position defines the target position
  78069. * @param scene defines the hosting scene
  78070. */
  78071. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  78072. /**
  78073. * Will store all controls that have this control as ascendant in a given array
  78074. * @param results defines the array where to store the descendants
  78075. * @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
  78076. * @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
  78077. */
  78078. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  78079. /**
  78080. * Will return all controls that have this control as ascendant
  78081. * @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
  78082. * @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
  78083. * @return all child controls
  78084. */
  78085. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  78086. /**
  78087. * Link current control with a target mesh
  78088. * @param mesh defines the mesh to link with
  78089. * @see https://doc.babylonjs.com/how_to/gui#tracking-positions
  78090. */
  78091. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  78092. /** @hidden */
  78093. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  78094. /** @hidden */
  78095. _offsetLeft(offset: number): void;
  78096. /** @hidden */
  78097. _offsetTop(offset: number): void;
  78098. /** @hidden */
  78099. _markMatrixAsDirty(): void;
  78100. /** @hidden */
  78101. _flagDescendantsAsMatrixDirty(): void;
  78102. /** @hidden */
  78103. _intersectsRect(rect: Measure): boolean;
  78104. /** @hidden */
  78105. protected invalidateRect(): void;
  78106. /** @hidden */
  78107. _markAsDirty(force?: boolean): void;
  78108. /** @hidden */
  78109. _markAllAsDirty(): void;
  78110. /** @hidden */
  78111. _link(host: AdvancedDynamicTexture): void;
  78112. /** @hidden */
  78113. protected _transform(context?: CanvasRenderingContext2D): void;
  78114. /** @hidden */
  78115. _renderHighlight(context: CanvasRenderingContext2D): void;
  78116. /** @hidden */
  78117. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  78118. /** @hidden */
  78119. protected _applyStates(context: CanvasRenderingContext2D): void;
  78120. /** @hidden */
  78121. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  78122. /** @hidden */
  78123. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78124. protected _evaluateClippingState(parentMeasure: Measure): void;
  78125. /** @hidden */
  78126. _measure(): void;
  78127. /** @hidden */
  78128. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78129. /** @hidden */
  78130. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78131. /** @hidden */
  78132. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78133. /** @hidden */
  78134. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  78135. private static _ClipMeasure;
  78136. private _tmpMeasureA;
  78137. private _clip;
  78138. /** @hidden */
  78139. _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  78140. /** @hidden */
  78141. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  78142. /**
  78143. * Tests if a given coordinates belong to the current control
  78144. * @param x defines x coordinate to test
  78145. * @param y defines y coordinate to test
  78146. * @returns true if the coordinates are inside the control
  78147. */
  78148. contains(x: number, y: number): boolean;
  78149. /** @hidden */
  78150. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  78151. /** @hidden */
  78152. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  78153. /** @hidden */
  78154. _onPointerEnter(target: Control, pi: BABYLON.PointerInfoBase): boolean;
  78155. /** @hidden */
  78156. _onPointerOut(target: Control, pi: BABYLON.Nullable<BABYLON.PointerInfoBase>, force?: boolean): void;
  78157. /** @hidden */
  78158. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  78159. /** @hidden */
  78160. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi?: BABYLON.PointerInfoBase): void;
  78161. /** @hidden */
  78162. _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  78163. /** @hidden */
  78164. _onWheelScroll(deltaX?: number, deltaY?: number): void;
  78165. /** @hidden */
  78166. _onCanvasBlur(): void;
  78167. /** @hidden */
  78168. _processObservables(type: number, x: number, y: number, pi: BABYLON.PointerInfoBase, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  78169. private _prepareFont;
  78170. /** Releases associated resources */
  78171. dispose(): void;
  78172. private static _HORIZONTAL_ALIGNMENT_LEFT;
  78173. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  78174. private static _HORIZONTAL_ALIGNMENT_CENTER;
  78175. private static _VERTICAL_ALIGNMENT_TOP;
  78176. private static _VERTICAL_ALIGNMENT_BOTTOM;
  78177. private static _VERTICAL_ALIGNMENT_CENTER;
  78178. /** HORIZONTAL_ALIGNMENT_LEFT */
  78179. static get HORIZONTAL_ALIGNMENT_LEFT(): number;
  78180. /** HORIZONTAL_ALIGNMENT_RIGHT */
  78181. static get HORIZONTAL_ALIGNMENT_RIGHT(): number;
  78182. /** HORIZONTAL_ALIGNMENT_CENTER */
  78183. static get HORIZONTAL_ALIGNMENT_CENTER(): number;
  78184. /** VERTICAL_ALIGNMENT_TOP */
  78185. static get VERTICAL_ALIGNMENT_TOP(): number;
  78186. /** VERTICAL_ALIGNMENT_BOTTOM */
  78187. static get VERTICAL_ALIGNMENT_BOTTOM(): number;
  78188. /** VERTICAL_ALIGNMENT_CENTER */
  78189. static get VERTICAL_ALIGNMENT_CENTER(): number;
  78190. private static _FontHeightSizes;
  78191. /** @hidden */
  78192. static _GetFontOffset(font: string): {
  78193. ascent: number;
  78194. height: number;
  78195. descent: number;
  78196. };
  78197. /**
  78198. * Creates a stack panel that can be used to render headers
  78199. * @param control defines the control to associate with the header
  78200. * @param text defines the text of the header
  78201. * @param size defines the size of the header
  78202. * @param options defines options used to configure the header
  78203. * @returns a new StackPanel
  78204. * @ignore
  78205. * @hidden
  78206. */
  78207. static AddHeader: (control: Control, text: string, size: string | number, options: {
  78208. isHorizontal: boolean;
  78209. controlFirst: boolean;
  78210. }) => any;
  78211. /** @hidden */
  78212. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  78213. }
  78214. }
  78215. declare module BABYLON.GUI {
  78216. /**
  78217. * Root class for 2D containers
  78218. * @see https://doc.babylonjs.com/how_to/gui#containers
  78219. */
  78220. export class Container extends Control {
  78221. name?: string | undefined;
  78222. /** @hidden */
  78223. _children: Control[];
  78224. /** @hidden */
  78225. protected _measureForChildren: Measure;
  78226. /** @hidden */
  78227. protected _background: string;
  78228. /** @hidden */
  78229. protected _adaptWidthToChildren: boolean;
  78230. /** @hidden */
  78231. protected _adaptHeightToChildren: boolean;
  78232. /**
  78233. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  78234. */
  78235. logLayoutCycleErrors: boolean;
  78236. /**
  78237. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  78238. */
  78239. maxLayoutCycle: number;
  78240. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  78241. get adaptHeightToChildren(): boolean;
  78242. set adaptHeightToChildren(value: boolean);
  78243. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  78244. get adaptWidthToChildren(): boolean;
  78245. set adaptWidthToChildren(value: boolean);
  78246. /** Gets or sets background color */
  78247. get background(): string;
  78248. set background(value: string);
  78249. /** Gets the list of children */
  78250. get children(): Control[];
  78251. /**
  78252. * Creates a new Container
  78253. * @param name defines the name of the container
  78254. */
  78255. constructor(name?: string | undefined);
  78256. protected _getTypeName(): string;
  78257. _flagDescendantsAsMatrixDirty(): void;
  78258. /**
  78259. * Gets a child using its name
  78260. * @param name defines the child name to look for
  78261. * @returns the child control if found
  78262. */
  78263. getChildByName(name: string): BABYLON.Nullable<Control>;
  78264. /**
  78265. * Gets a child using its type and its name
  78266. * @param name defines the child name to look for
  78267. * @param type defines the child type to look for
  78268. * @returns the child control if found
  78269. */
  78270. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  78271. /**
  78272. * Search for a specific control in children
  78273. * @param control defines the control to look for
  78274. * @returns true if the control is in child list
  78275. */
  78276. containsControl(control: Control): boolean;
  78277. /**
  78278. * Adds a new control to the current container
  78279. * @param control defines the control to add
  78280. * @returns the current container
  78281. */
  78282. addControl(control: BABYLON.Nullable<Control>): Container;
  78283. /**
  78284. * Removes all controls from the current container
  78285. * @returns the current container
  78286. */
  78287. clearControls(): Container;
  78288. /**
  78289. * Removes a control from the current container
  78290. * @param control defines the control to remove
  78291. * @returns the current container
  78292. */
  78293. removeControl(control: Control): Container;
  78294. /** @hidden */
  78295. _reOrderControl(control: Control): void;
  78296. /** @hidden */
  78297. _offsetLeft(offset: number): void;
  78298. /** @hidden */
  78299. _offsetTop(offset: number): void;
  78300. /** @hidden */
  78301. _markAllAsDirty(): void;
  78302. /** @hidden */
  78303. protected _localDraw(context: CanvasRenderingContext2D): void;
  78304. /** @hidden */
  78305. _link(host: AdvancedDynamicTexture): void;
  78306. /** @hidden */
  78307. protected _beforeLayout(): void;
  78308. /** @hidden */
  78309. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78310. /** @hidden */
  78311. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  78312. protected _postMeasure(): void;
  78313. /** @hidden */
  78314. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  78315. getDescendantsToRef(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  78316. /** @hidden */
  78317. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  78318. /** @hidden */
  78319. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78320. /** Releases associated resources */
  78321. dispose(): void;
  78322. }
  78323. }
  78324. declare module BABYLON.GUI {
  78325. /** Class used to create rectangle container */
  78326. export class Rectangle extends Container {
  78327. name?: string | undefined;
  78328. private _thickness;
  78329. private _cornerRadius;
  78330. /** Gets or sets border thickness */
  78331. get thickness(): number;
  78332. set thickness(value: number);
  78333. /** Gets or sets the corner radius angle */
  78334. get cornerRadius(): number;
  78335. set cornerRadius(value: number);
  78336. /**
  78337. * Creates a new Rectangle
  78338. * @param name defines the control name
  78339. */
  78340. constructor(name?: string | undefined);
  78341. protected _getTypeName(): string;
  78342. protected _localDraw(context: CanvasRenderingContext2D): void;
  78343. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78344. private _drawRoundedRect;
  78345. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  78346. }
  78347. }
  78348. declare module BABYLON.GUI {
  78349. /**
  78350. * Enum that determines the text-wrapping mode to use.
  78351. */
  78352. export enum TextWrapping {
  78353. /**
  78354. * Clip the text when it's larger than Control.width; this is the default mode.
  78355. */
  78356. Clip = 0,
  78357. /**
  78358. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  78359. */
  78360. WordWrap = 1,
  78361. /**
  78362. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  78363. */
  78364. Ellipsis = 2
  78365. }
  78366. /**
  78367. * Class used to create text block control
  78368. */
  78369. export class TextBlock extends Control {
  78370. /**
  78371. * Defines the name of the control
  78372. */
  78373. name?: string | undefined;
  78374. private _text;
  78375. private _textWrapping;
  78376. private _textHorizontalAlignment;
  78377. private _textVerticalAlignment;
  78378. private _lines;
  78379. private _resizeToFit;
  78380. private _lineSpacing;
  78381. private _outlineWidth;
  78382. private _outlineColor;
  78383. private _underline;
  78384. private _lineThrough;
  78385. /**
  78386. * An event triggered after the text is changed
  78387. */
  78388. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  78389. /**
  78390. * An event triggered after the text was broken up into lines
  78391. */
  78392. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  78393. /**
  78394. * Function used to split a string into words. By default, a string is split at each space character found
  78395. */
  78396. wordSplittingFunction: BABYLON.Nullable<(line: string) => string[]>;
  78397. /**
  78398. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  78399. */
  78400. get lines(): any[];
  78401. /**
  78402. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  78403. */
  78404. get resizeToFit(): boolean;
  78405. /**
  78406. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  78407. */
  78408. set resizeToFit(value: boolean);
  78409. /**
  78410. * Gets or sets a boolean indicating if text must be wrapped
  78411. */
  78412. get textWrapping(): TextWrapping | boolean;
  78413. /**
  78414. * Gets or sets a boolean indicating if text must be wrapped
  78415. */
  78416. set textWrapping(value: TextWrapping | boolean);
  78417. /**
  78418. * Gets or sets text to display
  78419. */
  78420. get text(): string;
  78421. /**
  78422. * Gets or sets text to display
  78423. */
  78424. set text(value: string);
  78425. /**
  78426. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  78427. */
  78428. get textHorizontalAlignment(): number;
  78429. /**
  78430. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  78431. */
  78432. set textHorizontalAlignment(value: number);
  78433. /**
  78434. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  78435. */
  78436. get textVerticalAlignment(): number;
  78437. /**
  78438. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  78439. */
  78440. set textVerticalAlignment(value: number);
  78441. /**
  78442. * Gets or sets line spacing value
  78443. */
  78444. set lineSpacing(value: string | number);
  78445. /**
  78446. * Gets or sets line spacing value
  78447. */
  78448. get lineSpacing(): string | number;
  78449. /**
  78450. * Gets or sets outlineWidth of the text to display
  78451. */
  78452. get outlineWidth(): number;
  78453. /**
  78454. * Gets or sets outlineWidth of the text to display
  78455. */
  78456. set outlineWidth(value: number);
  78457. /**
  78458. * Gets or sets a boolean indicating that text must have underline
  78459. */
  78460. get underline(): boolean;
  78461. /**
  78462. * Gets or sets a boolean indicating that text must have underline
  78463. */
  78464. set underline(value: boolean);
  78465. /**
  78466. * Gets or sets an boolean indicating that text must be crossed out
  78467. */
  78468. get lineThrough(): boolean;
  78469. /**
  78470. * Gets or sets an boolean indicating that text must be crossed out
  78471. */
  78472. set lineThrough(value: boolean);
  78473. /**
  78474. * Gets or sets outlineColor of the text to display
  78475. */
  78476. get outlineColor(): string;
  78477. /**
  78478. * Gets or sets outlineColor of the text to display
  78479. */
  78480. set outlineColor(value: string);
  78481. /**
  78482. * Creates a new TextBlock object
  78483. * @param name defines the name of the control
  78484. * @param text defines the text to display (emptry string by default)
  78485. */
  78486. constructor(
  78487. /**
  78488. * Defines the name of the control
  78489. */
  78490. name?: string | undefined, text?: string);
  78491. protected _getTypeName(): string;
  78492. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78493. private _drawText;
  78494. /** @hidden */
  78495. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  78496. protected _applyStates(context: CanvasRenderingContext2D): void;
  78497. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  78498. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  78499. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  78500. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  78501. protected _renderLines(context: CanvasRenderingContext2D): void;
  78502. /**
  78503. * Given a width constraint applied on the text block, find the expected height
  78504. * @returns expected height
  78505. */
  78506. computeExpectedHeight(): number;
  78507. dispose(): void;
  78508. }
  78509. }
  78510. declare module BABYLON.GUI {
  78511. /**
  78512. * Class used to create 2D images
  78513. */
  78514. export class Image extends Control {
  78515. name?: string | undefined;
  78516. private _workingCanvas;
  78517. private _domImage;
  78518. private _imageWidth;
  78519. private _imageHeight;
  78520. private _loaded;
  78521. private _stretch;
  78522. private _source;
  78523. private _autoScale;
  78524. private _sourceLeft;
  78525. private _sourceTop;
  78526. private _sourceWidth;
  78527. private _sourceHeight;
  78528. private _svgAttributesComputationCompleted;
  78529. private _isSVG;
  78530. private _cellWidth;
  78531. private _cellHeight;
  78532. private _cellId;
  78533. private _populateNinePatchSlicesFromImage;
  78534. private _sliceLeft;
  78535. private _sliceRight;
  78536. private _sliceTop;
  78537. private _sliceBottom;
  78538. private _detectPointerOnOpaqueOnly;
  78539. private _imageDataCache;
  78540. /**
  78541. * BABYLON.Observable notified when the content is loaded
  78542. */
  78543. onImageLoadedObservable: BABYLON.Observable<Image>;
  78544. /**
  78545. * BABYLON.Observable notified when _sourceLeft, _sourceTop, _sourceWidth and _sourceHeight are computed
  78546. */
  78547. onSVGAttributesComputedObservable: BABYLON.Observable<Image>;
  78548. /**
  78549. * Gets a boolean indicating that the content is loaded
  78550. */
  78551. get isLoaded(): boolean;
  78552. /**
  78553. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  78554. */
  78555. get populateNinePatchSlicesFromImage(): boolean;
  78556. set populateNinePatchSlicesFromImage(value: boolean);
  78557. /**
  78558. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  78559. * Beware using this as this will comsume more memory as the image has to be stored twice
  78560. */
  78561. get detectPointerOnOpaqueOnly(): boolean;
  78562. set detectPointerOnOpaqueOnly(value: boolean);
  78563. /**
  78564. * Gets or sets the left value for slicing (9-patch)
  78565. */
  78566. get sliceLeft(): number;
  78567. set sliceLeft(value: number);
  78568. /**
  78569. * Gets or sets the right value for slicing (9-patch)
  78570. */
  78571. get sliceRight(): number;
  78572. set sliceRight(value: number);
  78573. /**
  78574. * Gets or sets the top value for slicing (9-patch)
  78575. */
  78576. get sliceTop(): number;
  78577. set sliceTop(value: number);
  78578. /**
  78579. * Gets or sets the bottom value for slicing (9-patch)
  78580. */
  78581. get sliceBottom(): number;
  78582. set sliceBottom(value: number);
  78583. /**
  78584. * Gets or sets the left coordinate in the source image
  78585. */
  78586. get sourceLeft(): number;
  78587. set sourceLeft(value: number);
  78588. /**
  78589. * Gets or sets the top coordinate in the source image
  78590. */
  78591. get sourceTop(): number;
  78592. set sourceTop(value: number);
  78593. /**
  78594. * Gets or sets the width to capture in the source image
  78595. */
  78596. get sourceWidth(): number;
  78597. set sourceWidth(value: number);
  78598. /**
  78599. * Gets or sets the height to capture in the source image
  78600. */
  78601. get sourceHeight(): number;
  78602. set sourceHeight(value: number);
  78603. /** Indicates if the format of the image is SVG */
  78604. get isSVG(): boolean;
  78605. /** Gets the status of the SVG attributes computation (sourceLeft, sourceTop, sourceWidth, sourceHeight) */
  78606. get svgAttributesComputationCompleted(): boolean;
  78607. /**
  78608. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  78609. * @see https://doc.babylonjs.com/how_to/gui#image
  78610. */
  78611. get autoScale(): boolean;
  78612. set autoScale(value: boolean);
  78613. /** Gets or sets the streching mode used by the image */
  78614. get stretch(): number;
  78615. set stretch(value: number);
  78616. /** @hidden */
  78617. _rotate90(n: number, preserveProperties?: boolean): Image;
  78618. private _handleRotationForSVGImage;
  78619. private _rotate90SourceProperties;
  78620. /**
  78621. * Gets or sets the internal DOM image used to render the control
  78622. */
  78623. set domImage(value: HTMLImageElement);
  78624. get domImage(): HTMLImageElement;
  78625. private _onImageLoaded;
  78626. private _extractNinePatchSliceDataFromImage;
  78627. /**
  78628. * Gets or sets image source url
  78629. */
  78630. set source(value: BABYLON.Nullable<string>);
  78631. /**
  78632. * Checks for svg document with icon id present
  78633. */
  78634. private _svgCheck;
  78635. /**
  78636. * Sets sourceLeft, sourceTop, sourceWidth, sourceHeight automatically
  78637. * given external svg file and icon id
  78638. */
  78639. private _getSVGAttribs;
  78640. /**
  78641. * Gets or sets the cell width to use when animation sheet is enabled
  78642. * @see https://doc.babylonjs.com/how_to/gui#image
  78643. */
  78644. get cellWidth(): number;
  78645. set cellWidth(value: number);
  78646. /**
  78647. * Gets or sets the cell height to use when animation sheet is enabled
  78648. * @see https://doc.babylonjs.com/how_to/gui#image
  78649. */
  78650. get cellHeight(): number;
  78651. set cellHeight(value: number);
  78652. /**
  78653. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  78654. * @see https://doc.babylonjs.com/how_to/gui#image
  78655. */
  78656. get cellId(): number;
  78657. set cellId(value: number);
  78658. /**
  78659. * Creates a new Image
  78660. * @param name defines the control name
  78661. * @param url defines the image url
  78662. */
  78663. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  78664. /**
  78665. * Tests if a given coordinates belong to the current control
  78666. * @param x defines x coordinate to test
  78667. * @param y defines y coordinate to test
  78668. * @returns true if the coordinates are inside the control
  78669. */
  78670. contains(x: number, y: number): boolean;
  78671. protected _getTypeName(): string;
  78672. /** Force the control to synchronize with its content */
  78673. synchronizeSizeWithContent(): void;
  78674. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78675. private _prepareWorkingCanvasForOpaqueDetection;
  78676. private _drawImage;
  78677. _draw(context: CanvasRenderingContext2D): void;
  78678. private _renderCornerPatch;
  78679. private _renderNinePatch;
  78680. dispose(): void;
  78681. /** STRETCH_NONE */
  78682. static readonly STRETCH_NONE: number;
  78683. /** STRETCH_FILL */
  78684. static readonly STRETCH_FILL: number;
  78685. /** STRETCH_UNIFORM */
  78686. static readonly STRETCH_UNIFORM: number;
  78687. /** STRETCH_EXTEND */
  78688. static readonly STRETCH_EXTEND: number;
  78689. /** NINE_PATCH */
  78690. static readonly STRETCH_NINE_PATCH: number;
  78691. }
  78692. }
  78693. declare module BABYLON.GUI {
  78694. /**
  78695. * Class used to create 2D buttons
  78696. */
  78697. export class Button extends Rectangle {
  78698. name?: string | undefined;
  78699. /**
  78700. * Function called to generate a pointer enter animation
  78701. */
  78702. pointerEnterAnimation: () => void;
  78703. /**
  78704. * Function called to generate a pointer out animation
  78705. */
  78706. pointerOutAnimation: () => void;
  78707. /**
  78708. * Function called to generate a pointer down animation
  78709. */
  78710. pointerDownAnimation: () => void;
  78711. /**
  78712. * Function called to generate a pointer up animation
  78713. */
  78714. pointerUpAnimation: () => void;
  78715. /**
  78716. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  78717. */
  78718. delegatePickingToChildren: boolean;
  78719. private _image;
  78720. /**
  78721. * Returns the image part of the button (if any)
  78722. */
  78723. get image(): BABYLON.Nullable<Image>;
  78724. private _textBlock;
  78725. /**
  78726. * Returns the image part of the button (if any)
  78727. */
  78728. get textBlock(): BABYLON.Nullable<TextBlock>;
  78729. /**
  78730. * Creates a new Button
  78731. * @param name defines the name of the button
  78732. */
  78733. constructor(name?: string | undefined);
  78734. protected _getTypeName(): string;
  78735. /** @hidden */
  78736. _processPicking(x: number, y: number, pi: BABYLON.PointerInfoBase, type: number, pointerId: number, buttonIndex: number, deltaX?: number, deltaY?: number): boolean;
  78737. /** @hidden */
  78738. _onPointerEnter(target: Control, pi: BABYLON.PointerInfoBase): boolean;
  78739. /** @hidden */
  78740. _onPointerOut(target: Control, pi: BABYLON.PointerInfoBase, force?: boolean): void;
  78741. /** @hidden */
  78742. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  78743. /** @hidden */
  78744. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi: BABYLON.PointerInfoBase): void;
  78745. /**
  78746. * Creates a new button made with an image and a text
  78747. * @param name defines the name of the button
  78748. * @param text defines the text of the button
  78749. * @param imageUrl defines the url of the image
  78750. * @returns a new Button
  78751. */
  78752. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  78753. /**
  78754. * Creates a new button made with an image
  78755. * @param name defines the name of the button
  78756. * @param imageUrl defines the url of the image
  78757. * @returns a new Button
  78758. */
  78759. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  78760. /**
  78761. * Creates a new button made with a text
  78762. * @param name defines the name of the button
  78763. * @param text defines the text of the button
  78764. * @returns a new Button
  78765. */
  78766. static CreateSimpleButton(name: string, text: string): Button;
  78767. /**
  78768. * Creates a new button made with an image and a centered text
  78769. * @param name defines the name of the button
  78770. * @param text defines the text of the button
  78771. * @param imageUrl defines the url of the image
  78772. * @returns a new Button
  78773. */
  78774. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  78775. }
  78776. }
  78777. declare module BABYLON.GUI {
  78778. /**
  78779. * Class used to create a 2D stack panel container
  78780. */
  78781. export class StackPanel extends Container {
  78782. name?: string | undefined;
  78783. private _isVertical;
  78784. private _manualWidth;
  78785. private _manualHeight;
  78786. private _doNotTrackManualChanges;
  78787. /**
  78788. * Gets or sets a boolean indicating that layou warnings should be ignored
  78789. */
  78790. ignoreLayoutWarnings: boolean;
  78791. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  78792. get isVertical(): boolean;
  78793. set isVertical(value: boolean);
  78794. /**
  78795. * Gets or sets panel width.
  78796. * This value should not be set when in horizontal mode as it will be computed automatically
  78797. */
  78798. set width(value: string | number);
  78799. get width(): string | number;
  78800. /**
  78801. * Gets or sets panel height.
  78802. * This value should not be set when in vertical mode as it will be computed automatically
  78803. */
  78804. set height(value: string | number);
  78805. get height(): string | number;
  78806. /**
  78807. * Creates a new StackPanel
  78808. * @param name defines control name
  78809. */
  78810. constructor(name?: string | undefined);
  78811. protected _getTypeName(): string;
  78812. /** @hidden */
  78813. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78814. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  78815. protected _postMeasure(): void;
  78816. }
  78817. }
  78818. declare module BABYLON.GUI {
  78819. /**
  78820. * Class used to represent a 2D checkbox
  78821. */
  78822. export class Checkbox extends Control {
  78823. name?: string | undefined;
  78824. private _isChecked;
  78825. private _background;
  78826. private _checkSizeRatio;
  78827. private _thickness;
  78828. /** Gets or sets border thickness */
  78829. get thickness(): number;
  78830. set thickness(value: number);
  78831. /**
  78832. * BABYLON.Observable raised when isChecked property changes
  78833. */
  78834. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  78835. /** Gets or sets a value indicating the ratio between overall size and check size */
  78836. get checkSizeRatio(): number;
  78837. set checkSizeRatio(value: number);
  78838. /** Gets or sets background color */
  78839. get background(): string;
  78840. set background(value: string);
  78841. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  78842. get isChecked(): boolean;
  78843. set isChecked(value: boolean);
  78844. /**
  78845. * Creates a new CheckBox
  78846. * @param name defines the control name
  78847. */
  78848. constructor(name?: string | undefined);
  78849. protected _getTypeName(): string;
  78850. /** @hidden */
  78851. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  78852. /** @hidden */
  78853. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  78854. /**
  78855. * Utility function to easily create a checkbox with a header
  78856. * @param title defines the label to use for the header
  78857. * @param onValueChanged defines the callback to call when value changes
  78858. * @returns a StackPanel containing the checkbox and a textBlock
  78859. */
  78860. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  78861. }
  78862. }
  78863. declare module BABYLON.GUI {
  78864. /**
  78865. * Class used to store key control properties
  78866. */
  78867. export class KeyPropertySet {
  78868. /** Width */
  78869. width?: string;
  78870. /** Height */
  78871. height?: string;
  78872. /** Left padding */
  78873. paddingLeft?: string;
  78874. /** Right padding */
  78875. paddingRight?: string;
  78876. /** Top padding */
  78877. paddingTop?: string;
  78878. /** Bottom padding */
  78879. paddingBottom?: string;
  78880. /** Foreground color */
  78881. color?: string;
  78882. /** Background color */
  78883. background?: string;
  78884. }
  78885. /**
  78886. * Class used to create virtual keyboard
  78887. */
  78888. export class VirtualKeyboard extends StackPanel {
  78889. /** BABYLON.Observable raised when a key is pressed */
  78890. onKeyPressObservable: BABYLON.Observable<string>;
  78891. /** Gets or sets default key button width */
  78892. defaultButtonWidth: string;
  78893. /** Gets or sets default key button height */
  78894. defaultButtonHeight: string;
  78895. /** Gets or sets default key button left padding */
  78896. defaultButtonPaddingLeft: string;
  78897. /** Gets or sets default key button right padding */
  78898. defaultButtonPaddingRight: string;
  78899. /** Gets or sets default key button top padding */
  78900. defaultButtonPaddingTop: string;
  78901. /** Gets or sets default key button bottom padding */
  78902. defaultButtonPaddingBottom: string;
  78903. /** Gets or sets default key button foreground color */
  78904. defaultButtonColor: string;
  78905. /** Gets or sets default key button background color */
  78906. defaultButtonBackground: string;
  78907. /** Gets or sets shift button foreground color */
  78908. shiftButtonColor: string;
  78909. /** Gets or sets shift button thickness*/
  78910. selectedShiftThickness: number;
  78911. /** Gets shift key state */
  78912. shiftState: number;
  78913. protected _getTypeName(): string;
  78914. private _createKey;
  78915. /**
  78916. * Adds a new row of keys
  78917. * @param keys defines the list of keys to add
  78918. * @param propertySets defines the associated property sets
  78919. */
  78920. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  78921. /**
  78922. * Set the shift key to a specific state
  78923. * @param shiftState defines the new shift state
  78924. */
  78925. applyShiftState(shiftState: number): void;
  78926. private _currentlyConnectedInputText;
  78927. private _connectedInputTexts;
  78928. private _onKeyPressObserver;
  78929. /** Gets the input text control currently attached to the keyboard */
  78930. get connectedInputText(): BABYLON.Nullable<InputText>;
  78931. /**
  78932. * Connects the keyboard with an input text control
  78933. *
  78934. * @param input defines the target control
  78935. */
  78936. connect(input: InputText): void;
  78937. /**
  78938. * Disconnects the keyboard from connected InputText controls
  78939. *
  78940. * @param input optionally defines a target control, otherwise all are disconnected
  78941. */
  78942. disconnect(input?: InputText): void;
  78943. private _removeConnectedInputObservables;
  78944. /**
  78945. * Release all resources
  78946. */
  78947. dispose(): void;
  78948. /**
  78949. * Creates a new keyboard using a default layout
  78950. *
  78951. * @param name defines control name
  78952. * @returns a new VirtualKeyboard
  78953. */
  78954. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  78955. }
  78956. }
  78957. declare module BABYLON.GUI {
  78958. /**
  78959. * Class used to create input text control
  78960. */
  78961. export class InputText extends Control implements IFocusableControl {
  78962. name?: string | undefined;
  78963. private _text;
  78964. private _placeholderText;
  78965. private _background;
  78966. private _focusedBackground;
  78967. private _focusedColor;
  78968. private _placeholderColor;
  78969. private _thickness;
  78970. private _margin;
  78971. private _autoStretchWidth;
  78972. private _maxWidth;
  78973. private _isFocused;
  78974. private _blinkTimeout;
  78975. private _blinkIsEven;
  78976. private _cursorOffset;
  78977. private _scrollLeft;
  78978. private _textWidth;
  78979. private _clickedCoordinate;
  78980. private _deadKey;
  78981. private _addKey;
  78982. private _currentKey;
  78983. private _isTextHighlightOn;
  78984. private _textHighlightColor;
  78985. private _highligherOpacity;
  78986. private _highlightedText;
  78987. private _startHighlightIndex;
  78988. private _endHighlightIndex;
  78989. private _cursorIndex;
  78990. private _onFocusSelectAll;
  78991. private _isPointerDown;
  78992. private _onClipboardObserver;
  78993. private _onPointerDblTapObserver;
  78994. /** @hidden */
  78995. _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  78996. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  78997. promptMessage: string;
  78998. /** Force disable prompt on mobile device */
  78999. disableMobilePrompt: boolean;
  79000. /** BABYLON.Observable raised when the text changes */
  79001. onTextChangedObservable: BABYLON.Observable<InputText>;
  79002. /** BABYLON.Observable raised just before an entered character is to be added */
  79003. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  79004. /** BABYLON.Observable raised when the control gets the focus */
  79005. onFocusObservable: BABYLON.Observable<InputText>;
  79006. /** BABYLON.Observable raised when the control loses the focus */
  79007. onBlurObservable: BABYLON.Observable<InputText>;
  79008. /**Observable raised when the text is highlighted */
  79009. onTextHighlightObservable: BABYLON.Observable<InputText>;
  79010. /**Observable raised when copy event is triggered */
  79011. onTextCopyObservable: BABYLON.Observable<InputText>;
  79012. /** BABYLON.Observable raised when cut event is triggered */
  79013. onTextCutObservable: BABYLON.Observable<InputText>;
  79014. /** BABYLON.Observable raised when paste event is triggered */
  79015. onTextPasteObservable: BABYLON.Observable<InputText>;
  79016. /** BABYLON.Observable raised when a key event was processed */
  79017. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  79018. /** Gets or sets the maximum width allowed by the control */
  79019. get maxWidth(): string | number;
  79020. /** Gets the maximum width allowed by the control in pixels */
  79021. get maxWidthInPixels(): number;
  79022. set maxWidth(value: string | number);
  79023. /** Gets or sets the text highlighter transparency; default: 0.4 */
  79024. get highligherOpacity(): number;
  79025. set highligherOpacity(value: number);
  79026. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  79027. get onFocusSelectAll(): boolean;
  79028. set onFocusSelectAll(value: boolean);
  79029. /** Gets or sets the text hightlight color */
  79030. get textHighlightColor(): string;
  79031. set textHighlightColor(value: string);
  79032. /** Gets or sets control margin */
  79033. get margin(): string;
  79034. /** Gets control margin in pixels */
  79035. get marginInPixels(): number;
  79036. set margin(value: string);
  79037. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  79038. get autoStretchWidth(): boolean;
  79039. set autoStretchWidth(value: boolean);
  79040. /** Gets or sets border thickness */
  79041. get thickness(): number;
  79042. set thickness(value: number);
  79043. /** Gets or sets the background color when focused */
  79044. get focusedBackground(): string;
  79045. set focusedBackground(value: string);
  79046. /** Gets or sets the background color when focused */
  79047. get focusedColor(): string;
  79048. set focusedColor(value: string);
  79049. /** Gets or sets the background color */
  79050. get background(): string;
  79051. set background(value: string);
  79052. /** Gets or sets the placeholder color */
  79053. get placeholderColor(): string;
  79054. set placeholderColor(value: string);
  79055. /** Gets or sets the text displayed when the control is empty */
  79056. get placeholderText(): string;
  79057. set placeholderText(value: string);
  79058. /** Gets or sets the dead key flag */
  79059. get deadKey(): boolean;
  79060. set deadKey(flag: boolean);
  79061. /** Gets or sets the highlight text */
  79062. get highlightedText(): string;
  79063. set highlightedText(text: string);
  79064. /** Gets or sets if the current key should be added */
  79065. get addKey(): boolean;
  79066. set addKey(flag: boolean);
  79067. /** Gets or sets the value of the current key being entered */
  79068. get currentKey(): string;
  79069. set currentKey(key: string);
  79070. /** Gets or sets the text displayed in the control */
  79071. get text(): string;
  79072. set text(value: string);
  79073. /** Gets or sets control width */
  79074. get width(): string | number;
  79075. set width(value: string | number);
  79076. /**
  79077. * Creates a new InputText
  79078. * @param name defines the control name
  79079. * @param text defines the text of the control
  79080. */
  79081. constructor(name?: string | undefined, text?: string);
  79082. /** @hidden */
  79083. onBlur(): void;
  79084. /** @hidden */
  79085. onFocus(): void;
  79086. protected _getTypeName(): string;
  79087. /**
  79088. * Function called to get the list of controls that should not steal the focus from this control
  79089. * @returns an array of controls
  79090. */
  79091. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  79092. /** @hidden */
  79093. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  79094. /** @hidden */
  79095. private _updateValueFromCursorIndex;
  79096. /** @hidden */
  79097. private _processDblClick;
  79098. /** @hidden */
  79099. private _selectAllText;
  79100. /**
  79101. * Handles the keyboard event
  79102. * @param evt Defines the KeyboardEvent
  79103. */
  79104. processKeyboard(evt: KeyboardEvent): void;
  79105. /** @hidden */
  79106. private _onCopyText;
  79107. /** @hidden */
  79108. private _onCutText;
  79109. /** @hidden */
  79110. private _onPasteText;
  79111. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  79112. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  79113. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  79114. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  79115. protected _beforeRenderText(text: string): string;
  79116. dispose(): void;
  79117. }
  79118. }
  79119. declare module BABYLON.GUI {
  79120. /**
  79121. * Class used to create a 2D grid container
  79122. */
  79123. export class Grid extends Container {
  79124. name?: string | undefined;
  79125. private _rowDefinitions;
  79126. private _columnDefinitions;
  79127. private _cells;
  79128. private _childControls;
  79129. /**
  79130. * Gets the number of columns
  79131. */
  79132. get columnCount(): number;
  79133. /**
  79134. * Gets the number of rows
  79135. */
  79136. get rowCount(): number;
  79137. /** Gets the list of children */
  79138. get children(): Control[];
  79139. /** Gets the list of cells (e.g. the containers) */
  79140. get cells(): {
  79141. [key: string]: Container;
  79142. };
  79143. /**
  79144. * Gets the definition of a specific row
  79145. * @param index defines the index of the row
  79146. * @returns the row definition
  79147. */
  79148. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  79149. /**
  79150. * Gets the definition of a specific column
  79151. * @param index defines the index of the column
  79152. * @returns the column definition
  79153. */
  79154. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  79155. /**
  79156. * Adds a new row to the grid
  79157. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  79158. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  79159. * @returns the current grid
  79160. */
  79161. addRowDefinition(height: number, isPixel?: boolean): Grid;
  79162. /**
  79163. * Adds a new column to the grid
  79164. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  79165. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  79166. * @returns the current grid
  79167. */
  79168. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  79169. /**
  79170. * Update a row definition
  79171. * @param index defines the index of the row to update
  79172. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  79173. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  79174. * @returns the current grid
  79175. */
  79176. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  79177. /**
  79178. * Update a column definition
  79179. * @param index defines the index of the column to update
  79180. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  79181. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  79182. * @returns the current grid
  79183. */
  79184. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  79185. /**
  79186. * Gets the list of children stored in a specific cell
  79187. * @param row defines the row to check
  79188. * @param column defines the column to check
  79189. * @returns the list of controls
  79190. */
  79191. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  79192. /**
  79193. * Gets a string representing the child cell info (row x column)
  79194. * @param child defines the control to get info from
  79195. * @returns a string containing the child cell info (row x column)
  79196. */
  79197. getChildCellInfo(child: Control): string;
  79198. private _removeCell;
  79199. private _offsetCell;
  79200. /**
  79201. * Remove a column definition at specified index
  79202. * @param index defines the index of the column to remove
  79203. * @returns the current grid
  79204. */
  79205. removeColumnDefinition(index: number): Grid;
  79206. /**
  79207. * Remove a row definition at specified index
  79208. * @param index defines the index of the row to remove
  79209. * @returns the current grid
  79210. */
  79211. removeRowDefinition(index: number): Grid;
  79212. /**
  79213. * Adds a new control to the current grid
  79214. * @param control defines the control to add
  79215. * @param row defines the row where to add the control (0 by default)
  79216. * @param column defines the column where to add the control (0 by default)
  79217. * @returns the current grid
  79218. */
  79219. addControl(control: Control, row?: number, column?: number): Grid;
  79220. /**
  79221. * Removes a control from the current container
  79222. * @param control defines the control to remove
  79223. * @returns the current container
  79224. */
  79225. removeControl(control: Control): Container;
  79226. /**
  79227. * Creates a new Grid
  79228. * @param name defines control name
  79229. */
  79230. constructor(name?: string | undefined);
  79231. protected _getTypeName(): string;
  79232. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  79233. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79234. _flagDescendantsAsMatrixDirty(): void;
  79235. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  79236. /** Releases associated resources */
  79237. dispose(): void;
  79238. }
  79239. }
  79240. declare module BABYLON.GUI {
  79241. /** Class used to create color pickers */
  79242. export class ColorPicker extends Control {
  79243. name?: string | undefined;
  79244. private static _Epsilon;
  79245. private _colorWheelCanvas;
  79246. private _value;
  79247. private _tmpColor;
  79248. private _pointerStartedOnSquare;
  79249. private _pointerStartedOnWheel;
  79250. private _squareLeft;
  79251. private _squareTop;
  79252. private _squareSize;
  79253. private _h;
  79254. private _s;
  79255. private _v;
  79256. private _lastPointerDownID;
  79257. /**
  79258. * BABYLON.Observable raised when the value changes
  79259. */
  79260. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  79261. /** Gets or sets the color of the color picker */
  79262. get value(): BABYLON.Color3;
  79263. set value(value: BABYLON.Color3);
  79264. /**
  79265. * Gets or sets control width
  79266. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  79267. */
  79268. get width(): string | number;
  79269. set width(value: string | number);
  79270. /**
  79271. * Gets or sets control height
  79272. * @see https://doc.babylonjs.com/how_to/gui#position-and-size
  79273. */
  79274. get height(): string | number;
  79275. /** Gets or sets control height */
  79276. set height(value: string | number);
  79277. /** Gets or sets control size */
  79278. get size(): string | number;
  79279. set size(value: string | number);
  79280. /**
  79281. * Creates a new ColorPicker
  79282. * @param name defines the control name
  79283. */
  79284. constructor(name?: string | undefined);
  79285. protected _getTypeName(): string;
  79286. /** @hidden */
  79287. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79288. private _updateSquareProps;
  79289. private _drawGradientSquare;
  79290. private _drawCircle;
  79291. private _createColorWheelCanvas;
  79292. /** @hidden */
  79293. _draw(context: CanvasRenderingContext2D): void;
  79294. private _pointerIsDown;
  79295. private _updateValueFromPointer;
  79296. private _isPointOnSquare;
  79297. private _isPointOnWheel;
  79298. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  79299. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  79300. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean, pi: BABYLON.PointerInfoBase): void;
  79301. _onCanvasBlur(): void;
  79302. /**
  79303. * This function expands the color picker by creating a color picker dialog with manual
  79304. * color value input and the ability to save colors into an array to be used later in
  79305. * subsequent launches of the dialogue.
  79306. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  79307. * @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.
  79308. * @returns picked color as a hex string and the saved colors array as hex strings.
  79309. */
  79310. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  79311. pickerWidth?: string;
  79312. pickerHeight?: string;
  79313. headerHeight?: string;
  79314. lastColor?: string;
  79315. swatchLimit?: number;
  79316. numSwatchesPerLine?: number;
  79317. savedColors?: Array<string>;
  79318. }): Promise<{
  79319. savedColors?: string[];
  79320. pickedColor: string;
  79321. }>;
  79322. }
  79323. }
  79324. declare module BABYLON.GUI {
  79325. /** Class used to create 2D ellipse containers */
  79326. export class Ellipse extends Container {
  79327. name?: string | undefined;
  79328. private _thickness;
  79329. /** Gets or sets border thickness */
  79330. get thickness(): number;
  79331. set thickness(value: number);
  79332. /**
  79333. * Creates a new Ellipse
  79334. * @param name defines the control name
  79335. */
  79336. constructor(name?: string | undefined);
  79337. protected _getTypeName(): string;
  79338. protected _localDraw(context: CanvasRenderingContext2D): void;
  79339. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79340. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  79341. }
  79342. }
  79343. declare module BABYLON.GUI {
  79344. /**
  79345. * Class used to create a password control
  79346. */
  79347. export class InputPassword extends InputText {
  79348. protected _beforeRenderText(text: string): string;
  79349. }
  79350. }
  79351. declare module BABYLON.GUI {
  79352. /** Class used to render 2D lines */
  79353. export class Line extends Control {
  79354. name?: string | undefined;
  79355. private _lineWidth;
  79356. private _x1;
  79357. private _y1;
  79358. private _x2;
  79359. private _y2;
  79360. private _dash;
  79361. private _connectedControl;
  79362. private _connectedControlDirtyObserver;
  79363. /** Gets or sets the dash pattern */
  79364. get dash(): Array<number>;
  79365. set dash(value: Array<number>);
  79366. /** Gets or sets the control connected with the line end */
  79367. get connectedControl(): Control;
  79368. set connectedControl(value: Control);
  79369. /** Gets or sets start coordinates on X axis */
  79370. get x1(): string | number;
  79371. set x1(value: string | number);
  79372. /** Gets or sets start coordinates on Y axis */
  79373. get y1(): string | number;
  79374. set y1(value: string | number);
  79375. /** Gets or sets end coordinates on X axis */
  79376. get x2(): string | number;
  79377. set x2(value: string | number);
  79378. /** Gets or sets end coordinates on Y axis */
  79379. get y2(): string | number;
  79380. set y2(value: string | number);
  79381. /** Gets or sets line width */
  79382. get lineWidth(): number;
  79383. set lineWidth(value: number);
  79384. /** Gets or sets horizontal alignment */
  79385. set horizontalAlignment(value: number);
  79386. /** Gets or sets vertical alignment */
  79387. set verticalAlignment(value: number);
  79388. private get _effectiveX2();
  79389. private get _effectiveY2();
  79390. /**
  79391. * Creates a new Line
  79392. * @param name defines the control name
  79393. */
  79394. constructor(name?: string | undefined);
  79395. protected _getTypeName(): string;
  79396. _draw(context: CanvasRenderingContext2D): void;
  79397. _measure(): void;
  79398. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79399. /**
  79400. * Move one end of the line given 3D cartesian coordinates.
  79401. * @param position Targeted world position
  79402. * @param scene BABYLON.Scene
  79403. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  79404. */
  79405. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  79406. /**
  79407. * Move one end of the line to a position in screen absolute space.
  79408. * @param projectedPosition Position in screen absolute space (X, Y)
  79409. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  79410. */
  79411. _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  79412. }
  79413. }
  79414. declare module BABYLON.GUI {
  79415. /**
  79416. * Class used to store a point for a MultiLine object.
  79417. * The point can be pure 2D coordinates, a mesh or a control
  79418. */
  79419. export class MultiLinePoint {
  79420. private _multiLine;
  79421. private _x;
  79422. private _y;
  79423. private _control;
  79424. private _mesh;
  79425. private _controlObserver;
  79426. private _meshObserver;
  79427. /** @hidden */
  79428. _point: BABYLON.Vector2;
  79429. /**
  79430. * Creates a new MultiLinePoint
  79431. * @param multiLine defines the source MultiLine object
  79432. */
  79433. constructor(multiLine: MultiLine);
  79434. /** Gets or sets x coordinate */
  79435. get x(): string | number;
  79436. set x(value: string | number);
  79437. /** Gets or sets y coordinate */
  79438. get y(): string | number;
  79439. set y(value: string | number);
  79440. /** Gets or sets the control associated with this point */
  79441. get control(): BABYLON.Nullable<Control>;
  79442. set control(value: BABYLON.Nullable<Control>);
  79443. /** Gets or sets the mesh associated with this point */
  79444. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  79445. set mesh(value: BABYLON.Nullable<BABYLON.AbstractMesh>);
  79446. /** Resets links */
  79447. resetLinks(): void;
  79448. /**
  79449. * Gets a translation vector
  79450. * @returns the translation vector
  79451. */
  79452. translate(): BABYLON.Vector2;
  79453. private _translatePoint;
  79454. /** Release associated resources */
  79455. dispose(): void;
  79456. }
  79457. }
  79458. declare module BABYLON.GUI {
  79459. /**
  79460. * Class used to create multi line control
  79461. */
  79462. export class MultiLine extends Control {
  79463. name?: string | undefined;
  79464. private _lineWidth;
  79465. private _dash;
  79466. private _points;
  79467. private _minX;
  79468. private _minY;
  79469. private _maxX;
  79470. private _maxY;
  79471. /**
  79472. * Creates a new MultiLine
  79473. * @param name defines the control name
  79474. */
  79475. constructor(name?: string | undefined);
  79476. /** Gets or sets dash pattern */
  79477. get dash(): Array<number>;
  79478. set dash(value: Array<number>);
  79479. /**
  79480. * Gets point stored at specified index
  79481. * @param index defines the index to look for
  79482. * @returns the requested point if found
  79483. */
  79484. getAt(index: number): MultiLinePoint;
  79485. /** Function called when a point is updated */
  79486. onPointUpdate: () => void;
  79487. /**
  79488. * Adds new points to the point collection
  79489. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  79490. * @returns the list of created MultiLinePoint
  79491. */
  79492. add(...items: (AbstractMesh | Control | {
  79493. x: string | number;
  79494. y: string | number;
  79495. })[]): MultiLinePoint[];
  79496. /**
  79497. * Adds a new point to the point collection
  79498. * @param item defines the item (mesh, control or 2d coordiantes) to add
  79499. * @returns the created MultiLinePoint
  79500. */
  79501. push(item?: (AbstractMesh | Control | {
  79502. x: string | number;
  79503. y: string | number;
  79504. })): MultiLinePoint;
  79505. /**
  79506. * Remove a specific value or point from the active point collection
  79507. * @param value defines the value or point to remove
  79508. */
  79509. remove(value: number | MultiLinePoint): void;
  79510. /**
  79511. * Resets this object to initial state (no point)
  79512. */
  79513. reset(): void;
  79514. /**
  79515. * Resets all links
  79516. */
  79517. resetLinks(): void;
  79518. /** Gets or sets line width */
  79519. get lineWidth(): number;
  79520. set lineWidth(value: number);
  79521. set horizontalAlignment(value: number);
  79522. set verticalAlignment(value: number);
  79523. protected _getTypeName(): string;
  79524. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  79525. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79526. _measure(): void;
  79527. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79528. dispose(): void;
  79529. }
  79530. }
  79531. declare module BABYLON.GUI {
  79532. /**
  79533. * Class used to create radio button controls
  79534. */
  79535. export class RadioButton extends Control {
  79536. name?: string | undefined;
  79537. private _isChecked;
  79538. private _background;
  79539. private _checkSizeRatio;
  79540. private _thickness;
  79541. /** Gets or sets border thickness */
  79542. get thickness(): number;
  79543. set thickness(value: number);
  79544. /** Gets or sets group name */
  79545. group: string;
  79546. /** BABYLON.Observable raised when isChecked is changed */
  79547. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  79548. /** Gets or sets a value indicating the ratio between overall size and check size */
  79549. get checkSizeRatio(): number;
  79550. set checkSizeRatio(value: number);
  79551. /** Gets or sets background color */
  79552. get background(): string;
  79553. set background(value: string);
  79554. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  79555. get isChecked(): boolean;
  79556. set isChecked(value: boolean);
  79557. /**
  79558. * Creates a new RadioButton
  79559. * @param name defines the control name
  79560. */
  79561. constructor(name?: string | undefined);
  79562. protected _getTypeName(): string;
  79563. _draw(context: CanvasRenderingContext2D): void;
  79564. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  79565. /**
  79566. * Utility function to easily create a radio button with a header
  79567. * @param title defines the label to use for the header
  79568. * @param group defines the group to use for the radio button
  79569. * @param isChecked defines the initial state of the radio button
  79570. * @param onValueChanged defines the callback to call when value changes
  79571. * @returns a StackPanel containing the radio button and a textBlock
  79572. */
  79573. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  79574. }
  79575. }
  79576. declare module BABYLON.GUI {
  79577. /**
  79578. * Class used to create slider controls
  79579. */
  79580. export class BaseSlider extends Control {
  79581. name?: string | undefined;
  79582. protected _thumbWidth: ValueAndUnit;
  79583. private _minimum;
  79584. private _maximum;
  79585. private _value;
  79586. private _isVertical;
  79587. protected _barOffset: ValueAndUnit;
  79588. private _isThumbClamped;
  79589. protected _displayThumb: boolean;
  79590. private _step;
  79591. private _lastPointerDownID;
  79592. protected _effectiveBarOffset: number;
  79593. protected _renderLeft: number;
  79594. protected _renderTop: number;
  79595. protected _renderWidth: number;
  79596. protected _renderHeight: number;
  79597. protected _backgroundBoxLength: number;
  79598. protected _backgroundBoxThickness: number;
  79599. protected _effectiveThumbThickness: number;
  79600. /** BABYLON.Observable raised when the sldier value changes */
  79601. onValueChangedObservable: BABYLON.Observable<number>;
  79602. /** Gets or sets a boolean indicating if the thumb must be rendered */
  79603. get displayThumb(): boolean;
  79604. set displayThumb(value: boolean);
  79605. /** Gets or sets a step to apply to values (0 by default) */
  79606. get step(): number;
  79607. set step(value: number);
  79608. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  79609. get barOffset(): string | number;
  79610. /** Gets main bar offset in pixels*/
  79611. get barOffsetInPixels(): number;
  79612. set barOffset(value: string | number);
  79613. /** Gets or sets thumb width */
  79614. get thumbWidth(): string | number;
  79615. /** Gets thumb width in pixels */
  79616. get thumbWidthInPixels(): number;
  79617. set thumbWidth(value: string | number);
  79618. /** Gets or sets minimum value */
  79619. get minimum(): number;
  79620. set minimum(value: number);
  79621. /** Gets or sets maximum value */
  79622. get maximum(): number;
  79623. set maximum(value: number);
  79624. /** Gets or sets current value */
  79625. get value(): number;
  79626. set value(value: number);
  79627. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  79628. get isVertical(): boolean;
  79629. set isVertical(value: boolean);
  79630. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  79631. get isThumbClamped(): boolean;
  79632. set isThumbClamped(value: boolean);
  79633. /**
  79634. * Creates a new BaseSlider
  79635. * @param name defines the control name
  79636. */
  79637. constructor(name?: string | undefined);
  79638. protected _getTypeName(): string;
  79639. protected _getThumbPosition(): number;
  79640. protected _getThumbThickness(type: string): number;
  79641. protected _prepareRenderingData(type: string): void;
  79642. private _pointerIsDown;
  79643. /** @hidden */
  79644. protected _updateValueFromPointer(x: number, y: number): void;
  79645. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  79646. _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number, pi: BABYLON.PointerInfoBase): void;
  79647. _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  79648. _onCanvasBlur(): void;
  79649. }
  79650. }
  79651. declare module BABYLON.GUI {
  79652. /**
  79653. * Class used to create slider controls
  79654. */
  79655. export class Slider extends BaseSlider {
  79656. name?: string | undefined;
  79657. private _background;
  79658. private _borderColor;
  79659. private _thumbColor;
  79660. private _isThumbCircle;
  79661. protected _displayValueBar: boolean;
  79662. /** Gets or sets a boolean indicating if the value bar must be rendered */
  79663. get displayValueBar(): boolean;
  79664. set displayValueBar(value: boolean);
  79665. /** Gets or sets border color */
  79666. get borderColor(): string;
  79667. set borderColor(value: string);
  79668. /** Gets or sets background color */
  79669. get background(): string;
  79670. set background(value: string);
  79671. /** Gets or sets thumb's color */
  79672. get thumbColor(): string;
  79673. set thumbColor(value: string);
  79674. /** Gets or sets a boolean indicating if the thumb should be round or square */
  79675. get isThumbCircle(): boolean;
  79676. set isThumbCircle(value: boolean);
  79677. /**
  79678. * Creates a new Slider
  79679. * @param name defines the control name
  79680. */
  79681. constructor(name?: string | undefined);
  79682. protected _getTypeName(): string;
  79683. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  79684. }
  79685. }
  79686. declare module BABYLON.GUI {
  79687. /** Class used to create a RadioGroup
  79688. * which contains groups of radio buttons
  79689. */
  79690. export class SelectorGroup {
  79691. /** name of SelectorGroup */
  79692. name: string;
  79693. private _groupPanel;
  79694. private _selectors;
  79695. private _groupHeader;
  79696. /**
  79697. * Creates a new SelectorGroup
  79698. * @param name of group, used as a group heading
  79699. */
  79700. constructor(
  79701. /** name of SelectorGroup */
  79702. name: string);
  79703. /** Gets the groupPanel of the SelectorGroup */
  79704. get groupPanel(): StackPanel;
  79705. /** Gets the selectors array */
  79706. get selectors(): StackPanel[];
  79707. /** Gets and sets the group header */
  79708. get header(): string;
  79709. set header(label: string);
  79710. /** @hidden */
  79711. private _addGroupHeader;
  79712. /** @hidden*/
  79713. _getSelector(selectorNb: number): StackPanel | undefined;
  79714. /** Removes the selector at the given position
  79715. * @param selectorNb the position of the selector within the group
  79716. */
  79717. removeSelector(selectorNb: number): void;
  79718. }
  79719. /** Class used to create a CheckboxGroup
  79720. * which contains groups of checkbox buttons
  79721. */
  79722. export class CheckboxGroup extends SelectorGroup {
  79723. /** Adds a checkbox as a control
  79724. * @param text is the label for the selector
  79725. * @param func is the function called when the Selector is checked
  79726. * @param checked is true when Selector is checked
  79727. */
  79728. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  79729. /** @hidden */
  79730. _setSelectorLabel(selectorNb: number, label: string): void;
  79731. /** @hidden */
  79732. _setSelectorLabelColor(selectorNb: number, color: string): void;
  79733. /** @hidden */
  79734. _setSelectorButtonColor(selectorNb: number, color: string): void;
  79735. /** @hidden */
  79736. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  79737. }
  79738. /** Class used to create a RadioGroup
  79739. * which contains groups of radio buttons
  79740. */
  79741. export class RadioGroup extends SelectorGroup {
  79742. private _selectNb;
  79743. /** Adds a radio button as a control
  79744. * @param label is the label for the selector
  79745. * @param func is the function called when the Selector is checked
  79746. * @param checked is true when Selector is checked
  79747. */
  79748. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  79749. /** @hidden */
  79750. _setSelectorLabel(selectorNb: number, label: string): void;
  79751. /** @hidden */
  79752. _setSelectorLabelColor(selectorNb: number, color: string): void;
  79753. /** @hidden */
  79754. _setSelectorButtonColor(selectorNb: number, color: string): void;
  79755. /** @hidden */
  79756. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  79757. }
  79758. /** Class used to create a SliderGroup
  79759. * which contains groups of slider buttons
  79760. */
  79761. export class SliderGroup extends SelectorGroup {
  79762. /**
  79763. * Adds a slider to the SelectorGroup
  79764. * @param label is the label for the SliderBar
  79765. * @param func is the function called when the Slider moves
  79766. * @param unit is a string describing the units used, eg degrees or metres
  79767. * @param min is the minimum value for the Slider
  79768. * @param max is the maximum value for the Slider
  79769. * @param value is the start value for the Slider between min and max
  79770. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  79771. */
  79772. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  79773. /** @hidden */
  79774. _setSelectorLabel(selectorNb: number, label: string): void;
  79775. /** @hidden */
  79776. _setSelectorLabelColor(selectorNb: number, color: string): void;
  79777. /** @hidden */
  79778. _setSelectorButtonColor(selectorNb: number, color: string): void;
  79779. /** @hidden */
  79780. _setSelectorButtonBackground(selectorNb: number, color: string): void;
  79781. }
  79782. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  79783. * @see https://doc.babylonjs.com/how_to/selector
  79784. */
  79785. export class SelectionPanel extends Rectangle {
  79786. /** name of SelectionPanel */
  79787. name: string;
  79788. /** an array of SelectionGroups */
  79789. groups: SelectorGroup[];
  79790. private _panel;
  79791. private _buttonColor;
  79792. private _buttonBackground;
  79793. private _headerColor;
  79794. private _barColor;
  79795. private _barHeight;
  79796. private _spacerHeight;
  79797. private _labelColor;
  79798. private _groups;
  79799. private _bars;
  79800. /**
  79801. * Creates a new SelectionPanel
  79802. * @param name of SelectionPanel
  79803. * @param groups is an array of SelectionGroups
  79804. */
  79805. constructor(
  79806. /** name of SelectionPanel */
  79807. name: string,
  79808. /** an array of SelectionGroups */
  79809. groups?: SelectorGroup[]);
  79810. protected _getTypeName(): string;
  79811. /** Gets the (stack) panel of the SelectionPanel */
  79812. get panel(): StackPanel;
  79813. /** Gets or sets the headerColor */
  79814. get headerColor(): string;
  79815. set headerColor(color: string);
  79816. private _setHeaderColor;
  79817. /** Gets or sets the button color */
  79818. get buttonColor(): string;
  79819. set buttonColor(color: string);
  79820. private _setbuttonColor;
  79821. /** Gets or sets the label color */
  79822. get labelColor(): string;
  79823. set labelColor(color: string);
  79824. private _setLabelColor;
  79825. /** Gets or sets the button background */
  79826. get buttonBackground(): string;
  79827. set buttonBackground(color: string);
  79828. private _setButtonBackground;
  79829. /** Gets or sets the color of separator bar */
  79830. get barColor(): string;
  79831. set barColor(color: string);
  79832. private _setBarColor;
  79833. /** Gets or sets the height of separator bar */
  79834. get barHeight(): string;
  79835. set barHeight(value: string);
  79836. private _setBarHeight;
  79837. /** Gets or sets the height of spacers*/
  79838. get spacerHeight(): string;
  79839. set spacerHeight(value: string);
  79840. private _setSpacerHeight;
  79841. /** Adds a bar between groups */
  79842. private _addSpacer;
  79843. /** Add a group to the selection panel
  79844. * @param group is the selector group to add
  79845. */
  79846. addGroup(group: SelectorGroup): void;
  79847. /** Remove the group from the given position
  79848. * @param groupNb is the position of the group in the list
  79849. */
  79850. removeGroup(groupNb: number): void;
  79851. /** Change a group header label
  79852. * @param label is the new group header label
  79853. * @param groupNb is the number of the group to relabel
  79854. * */
  79855. setHeaderName(label: string, groupNb: number): void;
  79856. /** Change selector label to the one given
  79857. * @param label is the new selector label
  79858. * @param groupNb is the number of the groupcontaining the selector
  79859. * @param selectorNb is the number of the selector within a group to relabel
  79860. * */
  79861. relabel(label: string, groupNb: number, selectorNb: number): void;
  79862. /** For a given group position remove the selector at the given position
  79863. * @param groupNb is the number of the group to remove the selector from
  79864. * @param selectorNb is the number of the selector within the group
  79865. */
  79866. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  79867. /** For a given group position of correct type add a checkbox button
  79868. * @param groupNb is the number of the group to remove the selector from
  79869. * @param label is the label for the selector
  79870. * @param func is the function called when the Selector is checked
  79871. * @param checked is true when Selector is checked
  79872. */
  79873. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  79874. /** For a given group position of correct type add a radio button
  79875. * @param groupNb is the number of the group to remove the selector from
  79876. * @param label is the label for the selector
  79877. * @param func is the function called when the Selector is checked
  79878. * @param checked is true when Selector is checked
  79879. */
  79880. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  79881. /**
  79882. * For a given slider group add a slider
  79883. * @param groupNb is the number of the group to add the slider to
  79884. * @param label is the label for the Slider
  79885. * @param func is the function called when the Slider moves
  79886. * @param unit is a string describing the units used, eg degrees or metres
  79887. * @param min is the minimum value for the Slider
  79888. * @param max is the maximum value for the Slider
  79889. * @param value is the start value for the Slider between min and max
  79890. * @param onVal is the function used to format the value displayed, eg radians to degrees
  79891. */
  79892. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  79893. }
  79894. }
  79895. declare module BABYLON.GUI {
  79896. /**
  79897. * Class used to hold a the container for ScrollViewer
  79898. * @hidden
  79899. */
  79900. export class _ScrollViewerWindow extends Container {
  79901. parentClientWidth: number;
  79902. parentClientHeight: number;
  79903. private _freezeControls;
  79904. private _parentMeasure;
  79905. private _oldLeft;
  79906. private _oldTop;
  79907. get freezeControls(): boolean;
  79908. set freezeControls(value: boolean);
  79909. private _bucketWidth;
  79910. private _bucketHeight;
  79911. private _buckets;
  79912. private _bucketLen;
  79913. get bucketWidth(): number;
  79914. get bucketHeight(): number;
  79915. setBucketSizes(width: number, height: number): void;
  79916. private _useBuckets;
  79917. private _makeBuckets;
  79918. private _dispatchInBuckets;
  79919. private _updateMeasures;
  79920. private _updateChildrenMeasures;
  79921. private _restoreMeasures;
  79922. /**
  79923. * Creates a new ScrollViewerWindow
  79924. * @param name of ScrollViewerWindow
  79925. */
  79926. constructor(name?: string);
  79927. protected _getTypeName(): string;
  79928. /** @hidden */
  79929. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  79930. /** @hidden */
  79931. _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  79932. private _scrollChildren;
  79933. private _scrollChildrenWithBuckets;
  79934. /** @hidden */
  79935. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  79936. protected _postMeasure(): void;
  79937. }
  79938. }
  79939. declare module BABYLON.GUI {
  79940. /**
  79941. * Class used to create slider controls
  79942. */
  79943. export class ScrollBar extends BaseSlider {
  79944. name?: string | undefined;
  79945. private _background;
  79946. private _borderColor;
  79947. private _tempMeasure;
  79948. /** Gets or sets border color */
  79949. get borderColor(): string;
  79950. set borderColor(value: string);
  79951. /** Gets or sets background color */
  79952. get background(): string;
  79953. set background(value: string);
  79954. /**
  79955. * Creates a new Slider
  79956. * @param name defines the control name
  79957. */
  79958. constructor(name?: string | undefined);
  79959. protected _getTypeName(): string;
  79960. protected _getThumbThickness(): number;
  79961. _draw(context: CanvasRenderingContext2D): void;
  79962. private _first;
  79963. private _originX;
  79964. private _originY;
  79965. /** @hidden */
  79966. protected _updateValueFromPointer(x: number, y: number): void;
  79967. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  79968. }
  79969. }
  79970. declare module BABYLON.GUI {
  79971. /**
  79972. * Class used to create slider controls
  79973. */
  79974. export class ImageScrollBar extends BaseSlider {
  79975. name?: string | undefined;
  79976. private _backgroundBaseImage;
  79977. private _backgroundImage;
  79978. private _thumbImage;
  79979. private _thumbBaseImage;
  79980. private _thumbLength;
  79981. private _thumbHeight;
  79982. private _barImageHeight;
  79983. private _tempMeasure;
  79984. /** Number of 90° rotation to apply on the images when in vertical mode */
  79985. num90RotationInVerticalMode: number;
  79986. /**
  79987. * Gets or sets the image used to render the background for horizontal bar
  79988. */
  79989. get backgroundImage(): Image;
  79990. set backgroundImage(value: Image);
  79991. /**
  79992. * Gets or sets the image used to render the thumb
  79993. */
  79994. get thumbImage(): Image;
  79995. set thumbImage(value: Image);
  79996. /**
  79997. * Gets or sets the length of the thumb
  79998. */
  79999. get thumbLength(): number;
  80000. set thumbLength(value: number);
  80001. /**
  80002. * Gets or sets the height of the thumb
  80003. */
  80004. get thumbHeight(): number;
  80005. set thumbHeight(value: number);
  80006. /**
  80007. * Gets or sets the height of the bar image
  80008. */
  80009. get barImageHeight(): number;
  80010. set barImageHeight(value: number);
  80011. /**
  80012. * Creates a new ImageScrollBar
  80013. * @param name defines the control name
  80014. */
  80015. constructor(name?: string | undefined);
  80016. protected _getTypeName(): string;
  80017. protected _getThumbThickness(): number;
  80018. _draw(context: CanvasRenderingContext2D): void;
  80019. private _first;
  80020. private _originX;
  80021. private _originY;
  80022. /** @hidden */
  80023. protected _updateValueFromPointer(x: number, y: number): void;
  80024. _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, pi: BABYLON.PointerInfoBase): boolean;
  80025. }
  80026. }
  80027. declare module BABYLON.GUI {
  80028. /**
  80029. * Class used to hold a viewer window and sliders in a grid
  80030. */
  80031. export class ScrollViewer extends Rectangle {
  80032. private _grid;
  80033. private _horizontalBarSpace;
  80034. private _verticalBarSpace;
  80035. private _dragSpace;
  80036. private _horizontalBar;
  80037. private _verticalBar;
  80038. private _barColor;
  80039. private _barBackground;
  80040. private _barImage;
  80041. private _horizontalBarImage;
  80042. private _verticalBarImage;
  80043. private _barBackgroundImage;
  80044. private _horizontalBarBackgroundImage;
  80045. private _verticalBarBackgroundImage;
  80046. private _barSize;
  80047. private _window;
  80048. private _pointerIsOver;
  80049. private _wheelPrecision;
  80050. private _onWheelObserver;
  80051. private _clientWidth;
  80052. private _clientHeight;
  80053. private _useImageBar;
  80054. private _thumbLength;
  80055. private _thumbHeight;
  80056. private _barImageHeight;
  80057. private _horizontalBarImageHeight;
  80058. private _verticalBarImageHeight;
  80059. private _oldWindowContentsWidth;
  80060. private _oldWindowContentsHeight;
  80061. /**
  80062. * Gets the horizontal scrollbar
  80063. */
  80064. get horizontalBar(): ScrollBar | ImageScrollBar;
  80065. /**
  80066. * Gets the vertical scrollbar
  80067. */
  80068. get verticalBar(): ScrollBar | ImageScrollBar;
  80069. /**
  80070. * Adds a new control to the current container
  80071. * @param control defines the control to add
  80072. * @returns the current container
  80073. */
  80074. addControl(control: BABYLON.Nullable<Control>): Container;
  80075. /**
  80076. * Removes a control from the current container
  80077. * @param control defines the control to remove
  80078. * @returns the current container
  80079. */
  80080. removeControl(control: Control): Container;
  80081. /** Gets the list of children */
  80082. get children(): Control[];
  80083. _flagDescendantsAsMatrixDirty(): void;
  80084. /**
  80085. * Freezes or unfreezes the controls in the window.
  80086. * When controls are frozen, the scroll viewer can render a lot more quickly but updates to positions/sizes of controls
  80087. * are not taken into account. If you want to change positions/sizes, unfreeze, perform the changes then freeze again
  80088. */
  80089. get freezeControls(): boolean;
  80090. set freezeControls(value: boolean);
  80091. /** Gets the bucket width */
  80092. get bucketWidth(): number;
  80093. /** Gets the bucket height */
  80094. get bucketHeight(): number;
  80095. /**
  80096. * Sets the bucket sizes.
  80097. * When freezeControls is true, setting a non-zero bucket size will improve performances by updating only
  80098. * controls that are visible. The bucket sizes is used to subdivide (internally) the window area to smaller areas into which
  80099. * controls are dispatched. So, the size should be roughly equals to the mean size of all the controls of
  80100. * the window. To disable the usage of buckets, sets either width or height (or both) to 0.
  80101. * Please note that using this option will raise the memory usage (the higher the bucket sizes, the less memory
  80102. * used), that's why it is not enabled by default.
  80103. * @param width width of the bucket
  80104. * @param height height of the bucket
  80105. */
  80106. setBucketSizes(width: number, height: number): void;
  80107. private _forceHorizontalBar;
  80108. private _forceVerticalBar;
  80109. /**
  80110. * Forces the horizontal scroll bar to be displayed
  80111. */
  80112. get forceHorizontalBar(): boolean;
  80113. set forceHorizontalBar(value: boolean);
  80114. /**
  80115. * Forces the vertical scroll bar to be displayed
  80116. */
  80117. get forceVerticalBar(): boolean;
  80118. set forceVerticalBar(value: boolean);
  80119. /**
  80120. * Creates a new ScrollViewer
  80121. * @param name of ScrollViewer
  80122. */
  80123. constructor(name?: string, isImageBased?: boolean);
  80124. /** Reset the scroll viewer window to initial size */
  80125. resetWindow(): void;
  80126. protected _getTypeName(): string;
  80127. private _buildClientSizes;
  80128. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  80129. protected _postMeasure(): void;
  80130. /**
  80131. * Gets or sets the mouse wheel precision
  80132. * from 0 to 1 with a default value of 0.05
  80133. * */
  80134. get wheelPrecision(): number;
  80135. set wheelPrecision(value: number);
  80136. /** Gets or sets the scroll bar container background color */
  80137. get scrollBackground(): string;
  80138. set scrollBackground(color: string);
  80139. /** Gets or sets the bar color */
  80140. get barColor(): string;
  80141. set barColor(color: string);
  80142. /** Gets or sets the bar image */
  80143. get thumbImage(): Image;
  80144. set thumbImage(value: Image);
  80145. /** Gets or sets the horizontal bar image */
  80146. get horizontalThumbImage(): Image;
  80147. set horizontalThumbImage(value: Image);
  80148. /** Gets or sets the vertical bar image */
  80149. get verticalThumbImage(): Image;
  80150. set verticalThumbImage(value: Image);
  80151. /** Gets or sets the size of the bar */
  80152. get barSize(): number;
  80153. set barSize(value: number);
  80154. /** Gets or sets the length of the thumb */
  80155. get thumbLength(): number;
  80156. set thumbLength(value: number);
  80157. /** Gets or sets the height of the thumb */
  80158. get thumbHeight(): number;
  80159. set thumbHeight(value: number);
  80160. /** Gets or sets the height of the bar image */
  80161. get barImageHeight(): number;
  80162. set barImageHeight(value: number);
  80163. /** Gets or sets the height of the horizontal bar image */
  80164. get horizontalBarImageHeight(): number;
  80165. set horizontalBarImageHeight(value: number);
  80166. /** Gets or sets the height of the vertical bar image */
  80167. get verticalBarImageHeight(): number;
  80168. set verticalBarImageHeight(value: number);
  80169. /** Gets or sets the bar background */
  80170. get barBackground(): string;
  80171. set barBackground(color: string);
  80172. /** Gets or sets the bar background image */
  80173. get barImage(): Image;
  80174. set barImage(value: Image);
  80175. /** Gets or sets the horizontal bar background image */
  80176. get horizontalBarImage(): Image;
  80177. set horizontalBarImage(value: Image);
  80178. /** Gets or sets the vertical bar background image */
  80179. get verticalBarImage(): Image;
  80180. set verticalBarImage(value: Image);
  80181. private _setWindowPosition;
  80182. /** @hidden */
  80183. private _updateScroller;
  80184. _link(host: AdvancedDynamicTexture): void;
  80185. /** @hidden */
  80186. private _addBar;
  80187. /** @hidden */
  80188. private _attachWheel;
  80189. _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  80190. /** Releases associated resources */
  80191. dispose(): void;
  80192. }
  80193. }
  80194. declare module BABYLON.GUI {
  80195. /** Class used to render a grid */
  80196. export class DisplayGrid extends Control {
  80197. name?: string | undefined;
  80198. private _cellWidth;
  80199. private _cellHeight;
  80200. private _minorLineTickness;
  80201. private _minorLineColor;
  80202. private _majorLineTickness;
  80203. private _majorLineColor;
  80204. private _majorLineFrequency;
  80205. private _background;
  80206. private _displayMajorLines;
  80207. private _displayMinorLines;
  80208. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  80209. get displayMinorLines(): boolean;
  80210. set displayMinorLines(value: boolean);
  80211. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  80212. get displayMajorLines(): boolean;
  80213. set displayMajorLines(value: boolean);
  80214. /** Gets or sets background color (Black by default) */
  80215. get background(): string;
  80216. set background(value: string);
  80217. /** Gets or sets the width of each cell (20 by default) */
  80218. get cellWidth(): number;
  80219. set cellWidth(value: number);
  80220. /** Gets or sets the height of each cell (20 by default) */
  80221. get cellHeight(): number;
  80222. set cellHeight(value: number);
  80223. /** Gets or sets the tickness of minor lines (1 by default) */
  80224. get minorLineTickness(): number;
  80225. set minorLineTickness(value: number);
  80226. /** Gets or sets the color of minor lines (DarkGray by default) */
  80227. get minorLineColor(): string;
  80228. set minorLineColor(value: string);
  80229. /** Gets or sets the tickness of major lines (2 by default) */
  80230. get majorLineTickness(): number;
  80231. set majorLineTickness(value: number);
  80232. /** Gets or sets the color of major lines (White by default) */
  80233. get majorLineColor(): string;
  80234. set majorLineColor(value: string);
  80235. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  80236. get majorLineFrequency(): number;
  80237. set majorLineFrequency(value: number);
  80238. /**
  80239. * Creates a new GridDisplayRectangle
  80240. * @param name defines the control name
  80241. */
  80242. constructor(name?: string | undefined);
  80243. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  80244. protected _getTypeName(): string;
  80245. }
  80246. }
  80247. declare module BABYLON.GUI {
  80248. /**
  80249. * Class used to create slider controls based on images
  80250. */
  80251. export class ImageBasedSlider extends BaseSlider {
  80252. name?: string | undefined;
  80253. private _backgroundImage;
  80254. private _thumbImage;
  80255. private _valueBarImage;
  80256. private _tempMeasure;
  80257. get displayThumb(): boolean;
  80258. set displayThumb(value: boolean);
  80259. /**
  80260. * Gets or sets the image used to render the background
  80261. */
  80262. get backgroundImage(): Image;
  80263. set backgroundImage(value: Image);
  80264. /**
  80265. * Gets or sets the image used to render the value bar
  80266. */
  80267. get valueBarImage(): Image;
  80268. set valueBarImage(value: Image);
  80269. /**
  80270. * Gets or sets the image used to render the thumb
  80271. */
  80272. get thumbImage(): Image;
  80273. set thumbImage(value: Image);
  80274. /**
  80275. * Creates a new ImageBasedSlider
  80276. * @param name defines the control name
  80277. */
  80278. constructor(name?: string | undefined);
  80279. protected _getTypeName(): string;
  80280. _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  80281. }
  80282. }
  80283. declare module BABYLON.GUI {
  80284. /**
  80285. * Forcing an export so that this code will execute
  80286. * @hidden
  80287. */
  80288. const name = "Statics";
  80289. }
  80290. declare module BABYLON.GUI {
  80291. /**
  80292. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  80293. */
  80294. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  80295. /**
  80296. * Define the instrumented AdvancedDynamicTexture.
  80297. */
  80298. texture: AdvancedDynamicTexture;
  80299. private _captureRenderTime;
  80300. private _renderTime;
  80301. private _captureLayoutTime;
  80302. private _layoutTime;
  80303. private _onBeginRenderObserver;
  80304. private _onEndRenderObserver;
  80305. private _onBeginLayoutObserver;
  80306. private _onEndLayoutObserver;
  80307. /**
  80308. * Gets the perf counter used to capture render time
  80309. */
  80310. get renderTimeCounter(): BABYLON.PerfCounter;
  80311. /**
  80312. * Gets the perf counter used to capture layout time
  80313. */
  80314. get layoutTimeCounter(): BABYLON.PerfCounter;
  80315. /**
  80316. * Enable or disable the render time capture
  80317. */
  80318. get captureRenderTime(): boolean;
  80319. set captureRenderTime(value: boolean);
  80320. /**
  80321. * Enable or disable the layout time capture
  80322. */
  80323. get captureLayoutTime(): boolean;
  80324. set captureLayoutTime(value: boolean);
  80325. /**
  80326. * Instantiates a new advanced dynamic texture instrumentation.
  80327. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  80328. * @param texture Defines the AdvancedDynamicTexture to instrument
  80329. */
  80330. constructor(
  80331. /**
  80332. * Define the instrumented AdvancedDynamicTexture.
  80333. */
  80334. texture: AdvancedDynamicTexture);
  80335. /**
  80336. * Dispose and release associated resources.
  80337. */
  80338. dispose(): void;
  80339. }
  80340. }
  80341. declare module BABYLON.GUI {
  80342. /**
  80343. * Class used to load GUI via XML.
  80344. */
  80345. export class XmlLoader {
  80346. private _nodes;
  80347. private _nodeTypes;
  80348. private _isLoaded;
  80349. private _objectAttributes;
  80350. private _parentClass;
  80351. /**
  80352. * Create a new xml loader
  80353. * @param parentClass Sets the class context. Used when the loader is instanced inside a class and not in a global context
  80354. */
  80355. constructor(parentClass?: null);
  80356. private _getChainElement;
  80357. private _getClassAttribute;
  80358. private _createGuiElement;
  80359. private _parseGrid;
  80360. private _parseElement;
  80361. private _prepareSourceElement;
  80362. private _parseElementsFromSource;
  80363. private _parseXml;
  80364. /**
  80365. * Gets if the loading has finished.
  80366. * @returns whether the loading has finished or not
  80367. */
  80368. isLoaded(): boolean;
  80369. /**
  80370. * Gets a loaded node / control by id.
  80371. * @param id the Controls id set in the xml
  80372. * @returns element of type Control
  80373. */
  80374. getNodeById(id: string): any;
  80375. /**
  80376. * Gets all loaded nodes / controls
  80377. * @returns Array of controls
  80378. */
  80379. getNodes(): any;
  80380. /**
  80381. * Initiates the xml layout loading
  80382. * @param xmlFile defines the xml layout to load
  80383. * @param rootNode defines the node / control to use as a parent for the loaded layout controls.
  80384. * @param callback defines the callback called on layout load.
  80385. */
  80386. loadLayout(xmlFile: any, rootNode: any, callback: any): void;
  80387. }
  80388. }
  80389. declare module BABYLON.GUI {
  80390. /**
  80391. * Class used to create containers for controls
  80392. */
  80393. export class Container3D extends Control3D {
  80394. private _blockLayout;
  80395. /**
  80396. * Gets the list of child controls
  80397. */
  80398. protected _children: Control3D[];
  80399. /**
  80400. * Gets the list of child controls
  80401. */
  80402. get children(): Array<Control3D>;
  80403. /**
  80404. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  80405. * This is helpful to optimize layout operation when adding multiple children in a row
  80406. */
  80407. get blockLayout(): boolean;
  80408. set blockLayout(value: boolean);
  80409. /**
  80410. * Creates a new container
  80411. * @param name defines the container name
  80412. */
  80413. constructor(name?: string);
  80414. /**
  80415. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  80416. * @returns the current container
  80417. */
  80418. updateLayout(): Container3D;
  80419. /**
  80420. * Gets a boolean indicating if the given control is in the children of this control
  80421. * @param control defines the control to check
  80422. * @returns true if the control is in the child list
  80423. */
  80424. containsControl(control: Control3D): boolean;
  80425. /**
  80426. * Adds a control to the children of this control
  80427. * @param control defines the control to add
  80428. * @returns the current container
  80429. */
  80430. addControl(control: Control3D): Container3D;
  80431. /**
  80432. * This function will be called everytime a new control is added
  80433. */
  80434. protected _arrangeChildren(): void;
  80435. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  80436. /**
  80437. * Removes a control from the children of this control
  80438. * @param control defines the control to remove
  80439. * @returns the current container
  80440. */
  80441. removeControl(control: Control3D): Container3D;
  80442. protected _getTypeName(): string;
  80443. /**
  80444. * Releases all associated resources
  80445. */
  80446. dispose(): void;
  80447. /** Control rotation will remain unchanged */
  80448. static readonly UNSET_ORIENTATION: number;
  80449. /** Control will rotate to make it look at sphere central axis */
  80450. static readonly FACEORIGIN_ORIENTATION: number;
  80451. /** Control will rotate to make it look back at sphere central axis */
  80452. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  80453. /** Control will rotate to look at z axis (0, 0, 1) */
  80454. static readonly FACEFORWARD_ORIENTATION: number;
  80455. /** Control will rotate to look at negative z axis (0, 0, -1) */
  80456. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  80457. }
  80458. }
  80459. declare module BABYLON.GUI {
  80460. /**
  80461. * Class used to manage 3D user interface
  80462. * @see https://doc.babylonjs.com/how_to/gui3d
  80463. */
  80464. export class GUI3DManager implements BABYLON.IDisposable {
  80465. private _scene;
  80466. private _sceneDisposeObserver;
  80467. private _utilityLayer;
  80468. private _rootContainer;
  80469. private _pointerObserver;
  80470. private _pointerOutObserver;
  80471. /** @hidden */
  80472. _lastPickedControl: Control3D;
  80473. /** @hidden */
  80474. _lastControlOver: {
  80475. [pointerId: number]: Control3D;
  80476. };
  80477. /** @hidden */
  80478. _lastControlDown: {
  80479. [pointerId: number]: Control3D;
  80480. };
  80481. /**
  80482. * BABYLON.Observable raised when the point picked by the pointer events changed
  80483. */
  80484. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  80485. /** @hidden */
  80486. _sharedMaterials: {
  80487. [key: string]: BABYLON.Material;
  80488. };
  80489. /** Gets the hosting scene */
  80490. get scene(): BABYLON.Scene;
  80491. /** Gets associated utility layer */
  80492. get utilityLayer(): BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  80493. /**
  80494. * Creates a new GUI3DManager
  80495. * @param scene
  80496. */
  80497. constructor(scene?: BABYLON.Scene);
  80498. private _handlePointerOut;
  80499. private _doPicking;
  80500. /**
  80501. * Gets the root container
  80502. */
  80503. get rootContainer(): Container3D;
  80504. /**
  80505. * Gets a boolean indicating if the given control is in the root child list
  80506. * @param control defines the control to check
  80507. * @returns true if the control is in the root child list
  80508. */
  80509. containsControl(control: Control3D): boolean;
  80510. /**
  80511. * Adds a control to the root child list
  80512. * @param control defines the control to add
  80513. * @returns the current manager
  80514. */
  80515. addControl(control: Control3D): GUI3DManager;
  80516. /**
  80517. * Removes a control from the root child list
  80518. * @param control defines the control to remove
  80519. * @returns the current container
  80520. */
  80521. removeControl(control: Control3D): GUI3DManager;
  80522. /**
  80523. * Releases all associated resources
  80524. */
  80525. dispose(): void;
  80526. }
  80527. }
  80528. declare module BABYLON.GUI {
  80529. /**
  80530. * Class used to transport BABYLON.Vector3 information for pointer events
  80531. */
  80532. export class Vector3WithInfo extends BABYLON.Vector3 {
  80533. /** defines the current mouse button index */
  80534. buttonIndex: number;
  80535. /**
  80536. * Creates a new Vector3WithInfo
  80537. * @param source defines the vector3 data to transport
  80538. * @param buttonIndex defines the current mouse button index
  80539. */
  80540. constructor(source: BABYLON.Vector3,
  80541. /** defines the current mouse button index */
  80542. buttonIndex?: number);
  80543. }
  80544. }
  80545. declare module BABYLON.GUI {
  80546. /**
  80547. * Class used as base class for controls
  80548. */
  80549. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  80550. /** Defines the control name */
  80551. name?: string | undefined;
  80552. /** @hidden */
  80553. _host: GUI3DManager;
  80554. private _node;
  80555. private _downCount;
  80556. private _enterCount;
  80557. private _downPointerIds;
  80558. private _isVisible;
  80559. /** Gets or sets the control position in world space */
  80560. get position(): BABYLON.Vector3;
  80561. set position(value: BABYLON.Vector3);
  80562. /** Gets or sets the control scaling in world space */
  80563. get scaling(): BABYLON.Vector3;
  80564. set scaling(value: BABYLON.Vector3);
  80565. /** Callback used to start pointer enter animation */
  80566. pointerEnterAnimation: () => void;
  80567. /** Callback used to start pointer out animation */
  80568. pointerOutAnimation: () => void;
  80569. /** Callback used to start pointer down animation */
  80570. pointerDownAnimation: () => void;
  80571. /** Callback used to start pointer up animation */
  80572. pointerUpAnimation: () => void;
  80573. /**
  80574. * An event triggered when the pointer move over the control
  80575. */
  80576. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  80577. /**
  80578. * An event triggered when the pointer move out of the control
  80579. */
  80580. onPointerOutObservable: BABYLON.Observable<Control3D>;
  80581. /**
  80582. * An event triggered when the pointer taps the control
  80583. */
  80584. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  80585. /**
  80586. * An event triggered when pointer is up
  80587. */
  80588. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  80589. /**
  80590. * An event triggered when a control is clicked on (with a mouse)
  80591. */
  80592. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  80593. /**
  80594. * An event triggered when pointer enters the control
  80595. */
  80596. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  80597. /**
  80598. * Gets or sets the parent container
  80599. */
  80600. parent: BABYLON.Nullable<Container3D>;
  80601. private _behaviors;
  80602. /**
  80603. * Gets the list of attached behaviors
  80604. * @see https://doc.babylonjs.com/features/behaviour
  80605. */
  80606. get behaviors(): BABYLON.Behavior<Control3D>[];
  80607. /**
  80608. * Attach a behavior to the control
  80609. * @see https://doc.babylonjs.com/features/behaviour
  80610. * @param behavior defines the behavior to attach
  80611. * @returns the current control
  80612. */
  80613. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  80614. /**
  80615. * Remove an attached behavior
  80616. * @see https://doc.babylonjs.com/features/behaviour
  80617. * @param behavior defines the behavior to attach
  80618. * @returns the current control
  80619. */
  80620. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  80621. /**
  80622. * Gets an attached behavior by name
  80623. * @param name defines the name of the behavior to look for
  80624. * @see https://doc.babylonjs.com/features/behaviour
  80625. * @returns null if behavior was not found else the requested behavior
  80626. */
  80627. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  80628. /** Gets or sets a boolean indicating if the control is visible */
  80629. get isVisible(): boolean;
  80630. set isVisible(value: boolean);
  80631. /**
  80632. * Creates a new control
  80633. * @param name defines the control name
  80634. */
  80635. constructor(
  80636. /** Defines the control name */
  80637. name?: string | undefined);
  80638. /**
  80639. * Gets a string representing the class name
  80640. */
  80641. get typeName(): string;
  80642. /**
  80643. * Get the current class name of the control.
  80644. * @returns current class name
  80645. */
  80646. getClassName(): string;
  80647. protected _getTypeName(): string;
  80648. /**
  80649. * Gets the transform node used by this control
  80650. */
  80651. get node(): BABYLON.Nullable<BABYLON.TransformNode>;
  80652. /**
  80653. * Gets the mesh used to render this control
  80654. */
  80655. get mesh(): BABYLON.Nullable<BABYLON.AbstractMesh>;
  80656. /**
  80657. * Link the control as child of the given node
  80658. * @param node defines the node to link to. Use null to unlink the control
  80659. * @returns the current control
  80660. */
  80661. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  80662. /** @hidden **/
  80663. _prepareNode(scene: BABYLON.Scene): void;
  80664. /**
  80665. * Node creation.
  80666. * Can be overriden by children
  80667. * @param scene defines the scene where the node must be attached
  80668. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  80669. */
  80670. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  80671. /**
  80672. * Affect a material to the given mesh
  80673. * @param mesh defines the mesh which will represent the control
  80674. */
  80675. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  80676. /** @hidden */
  80677. _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  80678. /** @hidden */
  80679. _onPointerEnter(target: Control3D): boolean;
  80680. /** @hidden */
  80681. _onPointerOut(target: Control3D): void;
  80682. /** @hidden */
  80683. _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  80684. /** @hidden */
  80685. _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  80686. /** @hidden */
  80687. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  80688. /** @hidden */
  80689. _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  80690. /** @hidden */
  80691. _disposeNode(): void;
  80692. /**
  80693. * Releases all associated resources
  80694. */
  80695. dispose(): void;
  80696. }
  80697. }
  80698. declare module BABYLON.GUI {
  80699. /**
  80700. * Class used as a root to all buttons
  80701. */
  80702. export class AbstractButton3D extends Control3D {
  80703. /**
  80704. * Creates a new button
  80705. * @param name defines the control name
  80706. */
  80707. constructor(name?: string);
  80708. protected _getTypeName(): string;
  80709. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  80710. }
  80711. }
  80712. declare module BABYLON.GUI {
  80713. /**
  80714. * Class used to create a button in 3D
  80715. */
  80716. export class Button3D extends AbstractButton3D {
  80717. /** @hidden */
  80718. protected _currentMaterial: BABYLON.Material;
  80719. private _facadeTexture;
  80720. private _content;
  80721. private _contentResolution;
  80722. private _contentScaleRatio;
  80723. /**
  80724. * Gets or sets the texture resolution used to render content (512 by default)
  80725. */
  80726. get contentResolution(): BABYLON.int;
  80727. set contentResolution(value: BABYLON.int);
  80728. /**
  80729. * Gets or sets the texture scale ratio used to render content (2 by default)
  80730. */
  80731. get contentScaleRatio(): number;
  80732. set contentScaleRatio(value: number);
  80733. protected _disposeFacadeTexture(): void;
  80734. protected _resetContent(): void;
  80735. /**
  80736. * Creates a new button
  80737. * @param name defines the control name
  80738. */
  80739. constructor(name?: string);
  80740. /**
  80741. * Gets or sets the GUI 2D content used to display the button's facade
  80742. */
  80743. get content(): Control;
  80744. set content(value: Control);
  80745. /**
  80746. * Apply the facade texture (created from the content property).
  80747. * This function can be overloaded by child classes
  80748. * @param facadeTexture defines the AdvancedDynamicTexture to use
  80749. */
  80750. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  80751. protected _getTypeName(): string;
  80752. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  80753. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  80754. /**
  80755. * Releases all associated resources
  80756. */
  80757. dispose(): void;
  80758. }
  80759. }
  80760. declare module BABYLON.GUI {
  80761. /**
  80762. * Abstract class used to create a container panel deployed on the surface of a volume
  80763. */
  80764. export abstract class VolumeBasedPanel extends Container3D {
  80765. private _columns;
  80766. private _rows;
  80767. private _rowThenColum;
  80768. private _orientation;
  80769. protected _cellWidth: number;
  80770. protected _cellHeight: number;
  80771. /**
  80772. * Gets or sets the distance between elements
  80773. */
  80774. margin: number;
  80775. /**
  80776. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  80777. * | Value | Type | Description |
  80778. * | ----- | ----------------------------------- | ----------- |
  80779. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  80780. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  80781. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  80782. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  80783. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  80784. */
  80785. get orientation(): number;
  80786. set orientation(value: number);
  80787. /**
  80788. * Gets or sets the number of columns requested (10 by default).
  80789. * The panel will automatically compute the number of rows based on number of child controls.
  80790. */
  80791. get columns(): BABYLON.int;
  80792. set columns(value: BABYLON.int);
  80793. /**
  80794. * Gets or sets a the number of rows requested.
  80795. * The panel will automatically compute the number of columns based on number of child controls.
  80796. */
  80797. get rows(): BABYLON.int;
  80798. set rows(value: BABYLON.int);
  80799. /**
  80800. * Creates new VolumeBasedPanel
  80801. */
  80802. constructor();
  80803. protected _arrangeChildren(): void;
  80804. /** Child classes must implement this function to provide correct control positioning */
  80805. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  80806. /** Child classes can implement this function to provide additional processing */
  80807. protected _finalProcessing(): void;
  80808. }
  80809. }
  80810. declare module BABYLON.GUI {
  80811. /**
  80812. * Class used to create a container panel deployed on the surface of a cylinder
  80813. */
  80814. export class CylinderPanel extends VolumeBasedPanel {
  80815. private _radius;
  80816. /**
  80817. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  80818. */
  80819. get radius(): BABYLON.float;
  80820. set radius(value: BABYLON.float);
  80821. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  80822. private _cylindricalMapping;
  80823. }
  80824. }
  80825. declare module BABYLON.GUI {
  80826. /** @hidden */
  80827. export var fluentVertexShader: {
  80828. name: string;
  80829. shader: string;
  80830. };
  80831. }
  80832. declare module BABYLON.GUI {
  80833. /** @hidden */
  80834. export var fluentPixelShader: {
  80835. name: string;
  80836. shader: string;
  80837. };
  80838. }
  80839. declare module BABYLON.GUI {
  80840. /** @hidden */
  80841. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  80842. INNERGLOW: boolean;
  80843. BORDER: boolean;
  80844. HOVERLIGHT: boolean;
  80845. TEXTURE: boolean;
  80846. constructor();
  80847. }
  80848. /**
  80849. * Class used to render controls with fluent desgin
  80850. */
  80851. export class FluentMaterial extends BABYLON.PushMaterial {
  80852. /**
  80853. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  80854. */
  80855. innerGlowColorIntensity: number;
  80856. /**
  80857. * Gets or sets the inner glow color (white by default)
  80858. */
  80859. innerGlowColor: BABYLON.Color3;
  80860. /**
  80861. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  80862. */
  80863. albedoColor: BABYLON.Color3;
  80864. /**
  80865. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  80866. */
  80867. renderBorders: boolean;
  80868. /**
  80869. * Gets or sets border width (default is 0.5)
  80870. */
  80871. borderWidth: number;
  80872. /**
  80873. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  80874. */
  80875. edgeSmoothingValue: number;
  80876. /**
  80877. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  80878. */
  80879. borderMinValue: number;
  80880. /**
  80881. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  80882. */
  80883. renderHoverLight: boolean;
  80884. /**
  80885. * Gets or sets the radius used to render the hover light (default is 1.0)
  80886. */
  80887. hoverRadius: number;
  80888. /**
  80889. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  80890. */
  80891. hoverColor: BABYLON.Color4;
  80892. /**
  80893. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  80894. */
  80895. hoverPosition: BABYLON.Vector3;
  80896. private _albedoTexture;
  80897. /** Gets or sets the texture to use for albedo color */
  80898. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  80899. /**
  80900. * Creates a new Fluent material
  80901. * @param name defines the name of the material
  80902. * @param scene defines the hosting scene
  80903. */
  80904. constructor(name: string, scene: BABYLON.Scene);
  80905. needAlphaBlending(): boolean;
  80906. needAlphaTesting(): boolean;
  80907. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  80908. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  80909. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  80910. getActiveTextures(): BABYLON.BaseTexture[];
  80911. hasTexture(texture: BABYLON.BaseTexture): boolean;
  80912. dispose(forceDisposeEffect?: boolean): void;
  80913. clone(name: string): FluentMaterial;
  80914. serialize(): any;
  80915. getClassName(): string;
  80916. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  80917. }
  80918. }
  80919. declare module BABYLON.GUI {
  80920. /**
  80921. * Class used to create a holographic button in 3D
  80922. */
  80923. export class HolographicButton extends Button3D {
  80924. private _backPlate;
  80925. private _textPlate;
  80926. private _frontPlate;
  80927. private _text;
  80928. private _imageUrl;
  80929. private _shareMaterials;
  80930. private _frontMaterial;
  80931. private _backMaterial;
  80932. private _plateMaterial;
  80933. private _pickedPointObserver;
  80934. private _tooltipFade;
  80935. private _tooltipTextBlock;
  80936. private _tooltipTexture;
  80937. private _tooltipMesh;
  80938. private _tooltipHoverObserver;
  80939. private _tooltipOutObserver;
  80940. private _disposeTooltip;
  80941. /**
  80942. * Rendering ground id of all the mesh in the button
  80943. */
  80944. set renderingGroupId(id: number);
  80945. get renderingGroupId(): number;
  80946. /**
  80947. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  80948. */
  80949. set tooltipText(text: BABYLON.Nullable<string>);
  80950. get tooltipText(): BABYLON.Nullable<string>;
  80951. /**
  80952. * Gets or sets text for the button
  80953. */
  80954. get text(): string;
  80955. set text(value: string);
  80956. /**
  80957. * Gets or sets the image url for the button
  80958. */
  80959. get imageUrl(): string;
  80960. set imageUrl(value: string);
  80961. /**
  80962. * Gets the back material used by this button
  80963. */
  80964. get backMaterial(): FluentMaterial;
  80965. /**
  80966. * Gets the front material used by this button
  80967. */
  80968. get frontMaterial(): FluentMaterial;
  80969. /**
  80970. * Gets the plate material used by this button
  80971. */
  80972. get plateMaterial(): BABYLON.StandardMaterial;
  80973. /**
  80974. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  80975. */
  80976. get shareMaterials(): boolean;
  80977. /**
  80978. * Creates a new button
  80979. * @param name defines the control name
  80980. */
  80981. constructor(name?: string, shareMaterials?: boolean);
  80982. protected _getTypeName(): string;
  80983. private _rebuildContent;
  80984. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  80985. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  80986. private _createBackMaterial;
  80987. private _createFrontMaterial;
  80988. private _createPlateMaterial;
  80989. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  80990. /**
  80991. * Releases all associated resources
  80992. */
  80993. dispose(): void;
  80994. }
  80995. }
  80996. declare module BABYLON.GUI {
  80997. /**
  80998. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  80999. */
  81000. export class MeshButton3D extends Button3D {
  81001. /** @hidden */
  81002. protected _currentMesh: BABYLON.Mesh;
  81003. /**
  81004. * Creates a new 3D button based on a mesh
  81005. * @param mesh mesh to become a 3D button
  81006. * @param name defines the control name
  81007. */
  81008. constructor(mesh: BABYLON.Mesh, name?: string);
  81009. protected _getTypeName(): string;
  81010. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  81011. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  81012. }
  81013. }
  81014. declare module BABYLON.GUI {
  81015. /**
  81016. * Class used to create a container panel deployed on the surface of a plane
  81017. */
  81018. export class PlanePanel extends VolumeBasedPanel {
  81019. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  81020. }
  81021. }
  81022. declare module BABYLON.GUI {
  81023. /**
  81024. * Class used to create a container panel where items get randomized planar mapping
  81025. */
  81026. export class ScatterPanel extends VolumeBasedPanel {
  81027. private _iteration;
  81028. /**
  81029. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  81030. */
  81031. get iteration(): BABYLON.float;
  81032. set iteration(value: BABYLON.float);
  81033. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  81034. private _scatterMapping;
  81035. protected _finalProcessing(): void;
  81036. }
  81037. }
  81038. declare module BABYLON.GUI {
  81039. /**
  81040. * Class used to create a container panel deployed on the surface of a sphere
  81041. */
  81042. export class SpherePanel extends VolumeBasedPanel {
  81043. private _radius;
  81044. /**
  81045. * Gets or sets the radius of the sphere where to project controls (5 by default)
  81046. */
  81047. get radius(): BABYLON.float;
  81048. set radius(value: BABYLON.float);
  81049. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  81050. private _sphericalMapping;
  81051. }
  81052. }
  81053. declare module BABYLON.GUI {
  81054. /**
  81055. * Class used to create a stack panel in 3D on XY plane
  81056. */
  81057. export class StackPanel3D extends Container3D {
  81058. private _isVertical;
  81059. /**
  81060. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  81061. */
  81062. get isVertical(): boolean;
  81063. set isVertical(value: boolean);
  81064. /**
  81065. * Gets or sets the distance between elements
  81066. */
  81067. margin: number;
  81068. /**
  81069. * Creates new StackPanel
  81070. * @param isVertical
  81071. */
  81072. constructor(isVertical?: boolean);
  81073. protected _arrangeChildren(): void;
  81074. }
  81075. }
  81076. declare module BABYLON {
  81077. /**
  81078. * Configuration for glTF validation
  81079. */
  81080. export interface IGLTFValidationConfiguration {
  81081. /**
  81082. * The url of the glTF validator.
  81083. */
  81084. url: string;
  81085. }
  81086. /**
  81087. * glTF validation
  81088. */
  81089. export class GLTFValidation {
  81090. /**
  81091. * The configuration. Defaults to `{ url: "https://preview.babylonjs.com/gltf_validator.js" }`.
  81092. */
  81093. static Configuration: IGLTFValidationConfiguration;
  81094. private static _LoadScriptPromise;
  81095. /**
  81096. * Validate a glTF asset using the glTF-Validator.
  81097. * @param data The JSON of a glTF or the array buffer of a binary glTF
  81098. * @param rootUrl The root url for the glTF
  81099. * @param fileName The file name for the glTF
  81100. * @param getExternalResource The callback to get external resources for the glTF validator
  81101. * @returns A promise that resolves with the glTF validation results once complete
  81102. */
  81103. static ValidateAsync(data: string | ArrayBuffer, rootUrl: string, fileName: string, getExternalResource: (uri: string) => Promise<ArrayBuffer>): Promise<BABYLON.GLTF2.IGLTFValidationResults>;
  81104. }
  81105. }
  81106. declare module BABYLON {
  81107. /**
  81108. * Mode that determines the coordinate system to use.
  81109. */
  81110. export enum GLTFLoaderCoordinateSystemMode {
  81111. /**
  81112. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  81113. */
  81114. AUTO = 0,
  81115. /**
  81116. * Sets the useRightHandedSystem flag on the scene.
  81117. */
  81118. FORCE_RIGHT_HANDED = 1
  81119. }
  81120. /**
  81121. * Mode that determines what animations will start.
  81122. */
  81123. export enum GLTFLoaderAnimationStartMode {
  81124. /**
  81125. * No animation will start.
  81126. */
  81127. NONE = 0,
  81128. /**
  81129. * The first animation will start.
  81130. */
  81131. FIRST = 1,
  81132. /**
  81133. * All animations will start.
  81134. */
  81135. ALL = 2
  81136. }
  81137. /**
  81138. * Interface that contains the data for the glTF asset.
  81139. */
  81140. export interface IGLTFLoaderData {
  81141. /**
  81142. * The object that represents the glTF JSON.
  81143. */
  81144. json: Object;
  81145. /**
  81146. * The BIN chunk of a binary glTF.
  81147. */
  81148. bin: Nullable<IDataBuffer>;
  81149. }
  81150. /**
  81151. * Interface for extending the loader.
  81152. */
  81153. export interface IGLTFLoaderExtension {
  81154. /**
  81155. * The name of this extension.
  81156. */
  81157. readonly name: string;
  81158. /**
  81159. * Defines whether this extension is enabled.
  81160. */
  81161. enabled: boolean;
  81162. /**
  81163. * Defines the order of this extension.
  81164. * The loader sorts the extensions using these values when loading.
  81165. */
  81166. order?: number;
  81167. }
  81168. /**
  81169. * Loader state.
  81170. */
  81171. export enum GLTFLoaderState {
  81172. /**
  81173. * The asset is loading.
  81174. */
  81175. LOADING = 0,
  81176. /**
  81177. * The asset is ready for rendering.
  81178. */
  81179. READY = 1,
  81180. /**
  81181. * The asset is completely loaded.
  81182. */
  81183. COMPLETE = 2
  81184. }
  81185. /** @hidden */
  81186. export interface IImportMeshAsyncOutput {
  81187. meshes: AbstractMesh[];
  81188. particleSystems: IParticleSystem[];
  81189. skeletons: Skeleton[];
  81190. animationGroups: AnimationGroup[];
  81191. lights: Light[];
  81192. transformNodes: TransformNode[];
  81193. }
  81194. /** @hidden */
  81195. export interface IGLTFLoader extends IDisposable {
  81196. readonly state: Nullable<GLTFLoaderState>;
  81197. importMeshAsync: (meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<IImportMeshAsyncOutput>;
  81198. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  81199. }
  81200. /**
  81201. * File loader for loading glTF files into a scene.
  81202. */
  81203. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  81204. /** @hidden */
  81205. static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  81206. /** @hidden */
  81207. static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  81208. /**
  81209. * Raised when the asset has been parsed
  81210. */
  81211. onParsedObservable: Observable<IGLTFLoaderData>;
  81212. private _onParsedObserver;
  81213. /**
  81214. * Raised when the asset has been parsed
  81215. */
  81216. set onParsed(callback: (loaderData: IGLTFLoaderData) => void);
  81217. /**
  81218. * 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.
  81219. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  81220. * Defaults to true.
  81221. * @hidden
  81222. */
  81223. static IncrementalLoading: boolean;
  81224. /**
  81225. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  81226. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  81227. * @hidden
  81228. */
  81229. static HomogeneousCoordinates: boolean;
  81230. /**
  81231. * The coordinate system mode. Defaults to AUTO.
  81232. */
  81233. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  81234. /**
  81235. * The animation start mode. Defaults to FIRST.
  81236. */
  81237. animationStartMode: GLTFLoaderAnimationStartMode;
  81238. /**
  81239. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  81240. */
  81241. compileMaterials: boolean;
  81242. /**
  81243. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  81244. */
  81245. useClipPlane: boolean;
  81246. /**
  81247. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  81248. */
  81249. compileShadowGenerators: boolean;
  81250. /**
  81251. * Defines if the Alpha blended materials are only applied as coverage.
  81252. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  81253. * If true, no extra effects are applied to transparent pixels.
  81254. */
  81255. transparencyAsCoverage: boolean;
  81256. /**
  81257. * Defines if the loader should use range requests when load binary glTF files from HTTP.
  81258. * Enabling will disable offline support and glTF validator.
  81259. * Defaults to false.
  81260. */
  81261. useRangeRequests: boolean;
  81262. /**
  81263. * Defines if the loader should create instances when multiple glTF nodes point to the same glTF mesh. Defaults to true.
  81264. */
  81265. createInstances: boolean;
  81266. /**
  81267. * 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.
  81268. */
  81269. alwaysComputeBoundingBox: boolean;
  81270. /**
  81271. * If true, load all materials defined in the file, even if not used by any mesh. Defaults to false.
  81272. */
  81273. loadAllMaterials: boolean;
  81274. /**
  81275. * Function called before loading a url referenced by the asset.
  81276. */
  81277. preprocessUrlAsync: (url: string) => Promise<string>;
  81278. /**
  81279. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  81280. * 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, ...)
  81281. */
  81282. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  81283. private _onMeshLoadedObserver;
  81284. /**
  81285. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  81286. * 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, ...)
  81287. */
  81288. set onMeshLoaded(callback: (mesh: AbstractMesh) => void);
  81289. /**
  81290. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  81291. */
  81292. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  81293. private _onTextureLoadedObserver;
  81294. /**
  81295. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  81296. */
  81297. set onTextureLoaded(callback: (texture: BaseTexture) => void);
  81298. /**
  81299. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  81300. */
  81301. readonly onMaterialLoadedObservable: Observable<Material>;
  81302. private _onMaterialLoadedObserver;
  81303. /**
  81304. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  81305. */
  81306. set onMaterialLoaded(callback: (material: Material) => void);
  81307. /**
  81308. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  81309. */
  81310. readonly onCameraLoadedObservable: Observable<Camera>;
  81311. private _onCameraLoadedObserver;
  81312. /**
  81313. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  81314. */
  81315. set onCameraLoaded(callback: (camera: Camera) => void);
  81316. /**
  81317. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  81318. * For assets with LODs, raised when all of the LODs are complete.
  81319. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  81320. */
  81321. readonly onCompleteObservable: Observable<void>;
  81322. private _onCompleteObserver;
  81323. /**
  81324. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  81325. * For assets with LODs, raised when all of the LODs are complete.
  81326. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  81327. */
  81328. set onComplete(callback: () => void);
  81329. /**
  81330. * Observable raised when an error occurs.
  81331. */
  81332. readonly onErrorObservable: Observable<any>;
  81333. private _onErrorObserver;
  81334. /**
  81335. * Callback raised when an error occurs.
  81336. */
  81337. set onError(callback: (reason: any) => void);
  81338. /**
  81339. * Observable raised after the loader is disposed.
  81340. */
  81341. readonly onDisposeObservable: Observable<void>;
  81342. private _onDisposeObserver;
  81343. /**
  81344. * Callback raised after the loader is disposed.
  81345. */
  81346. set onDispose(callback: () => void);
  81347. /**
  81348. * Observable raised after a loader extension is created.
  81349. * Set additional options for a loader extension in this event.
  81350. */
  81351. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  81352. private _onExtensionLoadedObserver;
  81353. /**
  81354. * Callback raised after a loader extension is created.
  81355. */
  81356. set onExtensionLoaded(callback: (extension: IGLTFLoaderExtension) => void);
  81357. /**
  81358. * Defines if the loader logging is enabled.
  81359. */
  81360. get loggingEnabled(): boolean;
  81361. set loggingEnabled(value: boolean);
  81362. /**
  81363. * Defines if the loader should capture performance counters.
  81364. */
  81365. get capturePerformanceCounters(): boolean;
  81366. set capturePerformanceCounters(value: boolean);
  81367. /**
  81368. * Defines if the loader should validate the asset.
  81369. */
  81370. validate: boolean;
  81371. /**
  81372. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  81373. */
  81374. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  81375. private _onValidatedObserver;
  81376. /**
  81377. * Callback raised after a loader extension is created.
  81378. */
  81379. set onValidated(callback: (results: BABYLON.GLTF2.IGLTFValidationResults) => void);
  81380. private _loader;
  81381. private _progressCallback?;
  81382. private _requests;
  81383. private static magicBase64Encoded;
  81384. /**
  81385. * Name of the loader ("gltf")
  81386. */
  81387. name: string;
  81388. /** @hidden */
  81389. extensions: ISceneLoaderPluginExtensions;
  81390. /**
  81391. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  81392. */
  81393. dispose(): void;
  81394. /** @hidden */
  81395. requestFile(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  81396. /** @hidden */
  81397. readFile(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  81398. /** @hidden */
  81399. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  81400. meshes: AbstractMesh[];
  81401. particleSystems: IParticleSystem[];
  81402. skeletons: Skeleton[];
  81403. animationGroups: AnimationGroup[];
  81404. }>;
  81405. /** @hidden */
  81406. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  81407. /** @hidden */
  81408. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  81409. /** @hidden */
  81410. canDirectLoad(data: string): boolean;
  81411. /** @hidden */
  81412. directLoad(scene: Scene, data: string): Promise<any>;
  81413. /**
  81414. * The callback that allows custom handling of the root url based on the response url.
  81415. * @param rootUrl the original root url
  81416. * @param responseURL the response url if available
  81417. * @returns the new root url
  81418. */
  81419. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  81420. /** @hidden */
  81421. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  81422. /**
  81423. * The loader state or null if the loader is not active.
  81424. */
  81425. get loaderState(): Nullable<GLTFLoaderState>;
  81426. /**
  81427. * Returns a promise that resolves when the asset is completely loaded.
  81428. * @returns a promise that resolves when the asset is completely loaded.
  81429. */
  81430. whenCompleteAsync(): Promise<void>;
  81431. /** @hidden */
  81432. _loadFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer) => void, useArrayBuffer?: boolean, onError?: (request?: WebRequest) => void): IFileRequest;
  81433. /** @hidden */
  81434. _requestFile(url: string, scene: Scene, onSuccess: (data: string | ArrayBuffer, request?: WebRequest) => void, useArrayBuffer?: boolean, onError?: (error: RequestFileError) => void, onOpened?: (request: WebRequest) => void): IFileRequest;
  81435. private _onProgress;
  81436. private _validate;
  81437. private _getLoader;
  81438. private _parseJson;
  81439. private _unpackBinaryAsync;
  81440. private _unpackBinaryV1Async;
  81441. private _unpackBinaryV2Async;
  81442. private static _parseVersion;
  81443. private static _compareVersion;
  81444. private static readonly _logSpaces;
  81445. private _logIndentLevel;
  81446. private _loggingEnabled;
  81447. /** @hidden */
  81448. _log: (message: string) => void;
  81449. /** @hidden */
  81450. _logOpen(message: string): void;
  81451. /** @hidden */
  81452. _logClose(): void;
  81453. private _logEnabled;
  81454. private _logDisabled;
  81455. private _capturePerformanceCounters;
  81456. /** @hidden */
  81457. _startPerformanceCounter: (counterName: string) => void;
  81458. /** @hidden */
  81459. _endPerformanceCounter: (counterName: string) => void;
  81460. private _startPerformanceCounterEnabled;
  81461. private _startPerformanceCounterDisabled;
  81462. private _endPerformanceCounterEnabled;
  81463. private _endPerformanceCounterDisabled;
  81464. }
  81465. }
  81466. declare module BABYLON.GLTF1 {
  81467. /**
  81468. * Enums
  81469. * @hidden
  81470. */
  81471. export enum EComponentType {
  81472. BYTE = 5120,
  81473. UNSIGNED_BYTE = 5121,
  81474. SHORT = 5122,
  81475. UNSIGNED_SHORT = 5123,
  81476. FLOAT = 5126
  81477. }
  81478. /** @hidden */
  81479. export enum EShaderType {
  81480. FRAGMENT = 35632,
  81481. VERTEX = 35633
  81482. }
  81483. /** @hidden */
  81484. export enum EParameterType {
  81485. BYTE = 5120,
  81486. UNSIGNED_BYTE = 5121,
  81487. SHORT = 5122,
  81488. UNSIGNED_SHORT = 5123,
  81489. INT = 5124,
  81490. UNSIGNED_INT = 5125,
  81491. FLOAT = 5126,
  81492. FLOAT_VEC2 = 35664,
  81493. FLOAT_VEC3 = 35665,
  81494. FLOAT_VEC4 = 35666,
  81495. INT_VEC2 = 35667,
  81496. INT_VEC3 = 35668,
  81497. INT_VEC4 = 35669,
  81498. BOOL = 35670,
  81499. BOOL_VEC2 = 35671,
  81500. BOOL_VEC3 = 35672,
  81501. BOOL_VEC4 = 35673,
  81502. FLOAT_MAT2 = 35674,
  81503. FLOAT_MAT3 = 35675,
  81504. FLOAT_MAT4 = 35676,
  81505. SAMPLER_2D = 35678
  81506. }
  81507. /** @hidden */
  81508. export enum ETextureWrapMode {
  81509. CLAMP_TO_EDGE = 33071,
  81510. MIRRORED_REPEAT = 33648,
  81511. REPEAT = 10497
  81512. }
  81513. /** @hidden */
  81514. export enum ETextureFilterType {
  81515. NEAREST = 9728,
  81516. LINEAR = 9728,
  81517. NEAREST_MIPMAP_NEAREST = 9984,
  81518. LINEAR_MIPMAP_NEAREST = 9985,
  81519. NEAREST_MIPMAP_LINEAR = 9986,
  81520. LINEAR_MIPMAP_LINEAR = 9987
  81521. }
  81522. /** @hidden */
  81523. export enum ETextureFormat {
  81524. ALPHA = 6406,
  81525. RGB = 6407,
  81526. RGBA = 6408,
  81527. LUMINANCE = 6409,
  81528. LUMINANCE_ALPHA = 6410
  81529. }
  81530. /** @hidden */
  81531. export enum ECullingType {
  81532. FRONT = 1028,
  81533. BACK = 1029,
  81534. FRONT_AND_BACK = 1032
  81535. }
  81536. /** @hidden */
  81537. export enum EBlendingFunction {
  81538. ZERO = 0,
  81539. ONE = 1,
  81540. SRC_COLOR = 768,
  81541. ONE_MINUS_SRC_COLOR = 769,
  81542. DST_COLOR = 774,
  81543. ONE_MINUS_DST_COLOR = 775,
  81544. SRC_ALPHA = 770,
  81545. ONE_MINUS_SRC_ALPHA = 771,
  81546. DST_ALPHA = 772,
  81547. ONE_MINUS_DST_ALPHA = 773,
  81548. CONSTANT_COLOR = 32769,
  81549. ONE_MINUS_CONSTANT_COLOR = 32770,
  81550. CONSTANT_ALPHA = 32771,
  81551. ONE_MINUS_CONSTANT_ALPHA = 32772,
  81552. SRC_ALPHA_SATURATE = 776
  81553. }
  81554. /** @hidden */
  81555. export interface IGLTFProperty {
  81556. extensions?: {
  81557. [key: string]: any;
  81558. };
  81559. extras?: Object;
  81560. }
  81561. /** @hidden */
  81562. export interface IGLTFChildRootProperty extends IGLTFProperty {
  81563. name?: string;
  81564. }
  81565. /** @hidden */
  81566. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  81567. bufferView: string;
  81568. byteOffset: number;
  81569. byteStride: number;
  81570. count: number;
  81571. type: string;
  81572. componentType: EComponentType;
  81573. max?: number[];
  81574. min?: number[];
  81575. name?: string;
  81576. }
  81577. /** @hidden */
  81578. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  81579. buffer: string;
  81580. byteOffset: number;
  81581. byteLength: number;
  81582. byteStride: number;
  81583. target?: number;
  81584. }
  81585. /** @hidden */
  81586. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  81587. uri: string;
  81588. byteLength?: number;
  81589. type?: string;
  81590. }
  81591. /** @hidden */
  81592. export interface IGLTFShader extends IGLTFChildRootProperty {
  81593. uri: string;
  81594. type: EShaderType;
  81595. }
  81596. /** @hidden */
  81597. export interface IGLTFProgram extends IGLTFChildRootProperty {
  81598. attributes: string[];
  81599. fragmentShader: string;
  81600. vertexShader: string;
  81601. }
  81602. /** @hidden */
  81603. export interface IGLTFTechniqueParameter {
  81604. type: number;
  81605. count?: number;
  81606. semantic?: string;
  81607. node?: string;
  81608. value?: number | boolean | string | Array<any>;
  81609. source?: string;
  81610. babylonValue?: any;
  81611. }
  81612. /** @hidden */
  81613. export interface IGLTFTechniqueCommonProfile {
  81614. lightingModel: string;
  81615. texcoordBindings: Object;
  81616. parameters?: Array<any>;
  81617. }
  81618. /** @hidden */
  81619. export interface IGLTFTechniqueStatesFunctions {
  81620. blendColor?: number[];
  81621. blendEquationSeparate?: number[];
  81622. blendFuncSeparate?: number[];
  81623. colorMask: boolean[];
  81624. cullFace: number[];
  81625. }
  81626. /** @hidden */
  81627. export interface IGLTFTechniqueStates {
  81628. enable: number[];
  81629. functions: IGLTFTechniqueStatesFunctions;
  81630. }
  81631. /** @hidden */
  81632. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  81633. parameters: {
  81634. [key: string]: IGLTFTechniqueParameter;
  81635. };
  81636. program: string;
  81637. attributes: {
  81638. [key: string]: string;
  81639. };
  81640. uniforms: {
  81641. [key: string]: string;
  81642. };
  81643. states: IGLTFTechniqueStates;
  81644. }
  81645. /** @hidden */
  81646. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  81647. technique?: string;
  81648. values: string[];
  81649. }
  81650. /** @hidden */
  81651. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  81652. attributes: {
  81653. [key: string]: string;
  81654. };
  81655. indices: string;
  81656. material: string;
  81657. mode?: number;
  81658. }
  81659. /** @hidden */
  81660. export interface IGLTFMesh extends IGLTFChildRootProperty {
  81661. primitives: IGLTFMeshPrimitive[];
  81662. }
  81663. /** @hidden */
  81664. export interface IGLTFImage extends IGLTFChildRootProperty {
  81665. uri: string;
  81666. }
  81667. /** @hidden */
  81668. export interface IGLTFSampler extends IGLTFChildRootProperty {
  81669. magFilter?: number;
  81670. minFilter?: number;
  81671. wrapS?: number;
  81672. wrapT?: number;
  81673. }
  81674. /** @hidden */
  81675. export interface IGLTFTexture extends IGLTFChildRootProperty {
  81676. sampler: string;
  81677. source: string;
  81678. format?: ETextureFormat;
  81679. internalFormat?: ETextureFormat;
  81680. target?: number;
  81681. type?: number;
  81682. babylonTexture?: Texture;
  81683. }
  81684. /** @hidden */
  81685. export interface IGLTFAmbienLight {
  81686. color?: number[];
  81687. }
  81688. /** @hidden */
  81689. export interface IGLTFDirectionalLight {
  81690. color?: number[];
  81691. }
  81692. /** @hidden */
  81693. export interface IGLTFPointLight {
  81694. color?: number[];
  81695. constantAttenuation?: number;
  81696. linearAttenuation?: number;
  81697. quadraticAttenuation?: number;
  81698. }
  81699. /** @hidden */
  81700. export interface IGLTFSpotLight {
  81701. color?: number[];
  81702. constantAttenuation?: number;
  81703. fallOfAngle?: number;
  81704. fallOffExponent?: number;
  81705. linearAttenuation?: number;
  81706. quadraticAttenuation?: number;
  81707. }
  81708. /** @hidden */
  81709. export interface IGLTFLight extends IGLTFChildRootProperty {
  81710. type: string;
  81711. }
  81712. /** @hidden */
  81713. export interface IGLTFCameraOrthographic {
  81714. xmag: number;
  81715. ymag: number;
  81716. zfar: number;
  81717. znear: number;
  81718. }
  81719. /** @hidden */
  81720. export interface IGLTFCameraPerspective {
  81721. aspectRatio: number;
  81722. yfov: number;
  81723. zfar: number;
  81724. znear: number;
  81725. }
  81726. /** @hidden */
  81727. export interface IGLTFCamera extends IGLTFChildRootProperty {
  81728. type: string;
  81729. }
  81730. /** @hidden */
  81731. export interface IGLTFAnimationChannelTarget {
  81732. id: string;
  81733. path: string;
  81734. }
  81735. /** @hidden */
  81736. export interface IGLTFAnimationChannel {
  81737. sampler: string;
  81738. target: IGLTFAnimationChannelTarget;
  81739. }
  81740. /** @hidden */
  81741. export interface IGLTFAnimationSampler {
  81742. input: string;
  81743. output: string;
  81744. interpolation?: string;
  81745. }
  81746. /** @hidden */
  81747. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  81748. channels?: IGLTFAnimationChannel[];
  81749. parameters?: {
  81750. [key: string]: string;
  81751. };
  81752. samplers?: {
  81753. [key: string]: IGLTFAnimationSampler;
  81754. };
  81755. }
  81756. /** @hidden */
  81757. export interface IGLTFNodeInstanceSkin {
  81758. skeletons: string[];
  81759. skin: string;
  81760. meshes: string[];
  81761. }
  81762. /** @hidden */
  81763. export interface IGLTFSkins extends IGLTFChildRootProperty {
  81764. bindShapeMatrix: number[];
  81765. inverseBindMatrices: string;
  81766. jointNames: string[];
  81767. babylonSkeleton?: Skeleton;
  81768. }
  81769. /** @hidden */
  81770. export interface IGLTFNode extends IGLTFChildRootProperty {
  81771. camera?: string;
  81772. children: string[];
  81773. skin?: string;
  81774. jointName?: string;
  81775. light?: string;
  81776. matrix: number[];
  81777. mesh?: string;
  81778. meshes?: string[];
  81779. rotation?: number[];
  81780. scale?: number[];
  81781. translation?: number[];
  81782. babylonNode?: Node;
  81783. }
  81784. /** @hidden */
  81785. export interface IGLTFScene extends IGLTFChildRootProperty {
  81786. nodes: string[];
  81787. }
  81788. /** @hidden */
  81789. export interface IGLTFRuntime {
  81790. extensions: {
  81791. [key: string]: any;
  81792. };
  81793. accessors: {
  81794. [key: string]: IGLTFAccessor;
  81795. };
  81796. buffers: {
  81797. [key: string]: IGLTFBuffer;
  81798. };
  81799. bufferViews: {
  81800. [key: string]: IGLTFBufferView;
  81801. };
  81802. meshes: {
  81803. [key: string]: IGLTFMesh;
  81804. };
  81805. lights: {
  81806. [key: string]: IGLTFLight;
  81807. };
  81808. cameras: {
  81809. [key: string]: IGLTFCamera;
  81810. };
  81811. nodes: {
  81812. [key: string]: IGLTFNode;
  81813. };
  81814. images: {
  81815. [key: string]: IGLTFImage;
  81816. };
  81817. textures: {
  81818. [key: string]: IGLTFTexture;
  81819. };
  81820. shaders: {
  81821. [key: string]: IGLTFShader;
  81822. };
  81823. programs: {
  81824. [key: string]: IGLTFProgram;
  81825. };
  81826. samplers: {
  81827. [key: string]: IGLTFSampler;
  81828. };
  81829. techniques: {
  81830. [key: string]: IGLTFTechnique;
  81831. };
  81832. materials: {
  81833. [key: string]: IGLTFMaterial;
  81834. };
  81835. animations: {
  81836. [key: string]: IGLTFAnimation;
  81837. };
  81838. skins: {
  81839. [key: string]: IGLTFSkins;
  81840. };
  81841. currentScene?: Object;
  81842. scenes: {
  81843. [key: string]: IGLTFScene;
  81844. };
  81845. extensionsUsed: string[];
  81846. extensionsRequired?: string[];
  81847. buffersCount: number;
  81848. shaderscount: number;
  81849. scene: Scene;
  81850. rootUrl: string;
  81851. loadedBufferCount: number;
  81852. loadedBufferViews: {
  81853. [name: string]: ArrayBufferView;
  81854. };
  81855. loadedShaderCount: number;
  81856. importOnlyMeshes: boolean;
  81857. importMeshesNames?: string[];
  81858. dummyNodes: Node[];
  81859. forAssetContainer: boolean;
  81860. }
  81861. /** @hidden */
  81862. export interface INodeToRoot {
  81863. bone: Bone;
  81864. node: IGLTFNode;
  81865. id: string;
  81866. }
  81867. /** @hidden */
  81868. export interface IJointNode {
  81869. node: IGLTFNode;
  81870. id: string;
  81871. }
  81872. }
  81873. declare module BABYLON.GLTF1 {
  81874. /**
  81875. * Utils functions for GLTF
  81876. * @hidden
  81877. */
  81878. export class GLTFUtils {
  81879. /**
  81880. * Sets the given "parameter" matrix
  81881. * @param scene: the Scene object
  81882. * @param source: the source node where to pick the matrix
  81883. * @param parameter: the GLTF technique parameter
  81884. * @param uniformName: the name of the shader's uniform
  81885. * @param shaderMaterial: the shader material
  81886. */
  81887. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  81888. /**
  81889. * Sets the given "parameter" matrix
  81890. * @param shaderMaterial: the shader material
  81891. * @param uniform: the name of the shader's uniform
  81892. * @param value: the value of the uniform
  81893. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  81894. */
  81895. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  81896. /**
  81897. * Returns the wrap mode of the texture
  81898. * @param mode: the mode value
  81899. */
  81900. static GetWrapMode(mode: number): number;
  81901. /**
  81902. * Returns the byte stride giving an accessor
  81903. * @param accessor: the GLTF accessor objet
  81904. */
  81905. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  81906. /**
  81907. * Returns the texture filter mode giving a mode value
  81908. * @param mode: the filter mode value
  81909. */
  81910. static GetTextureFilterMode(mode: number): ETextureFilterType;
  81911. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  81912. /**
  81913. * Returns a buffer from its accessor
  81914. * @param gltfRuntime: the GLTF runtime
  81915. * @param accessor: the GLTF accessor
  81916. */
  81917. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  81918. /**
  81919. * Decodes a buffer view into a string
  81920. * @param view: the buffer view
  81921. */
  81922. static DecodeBufferToText(view: ArrayBufferView): string;
  81923. /**
  81924. * Returns the default material of gltf. Related to
  81925. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  81926. * @param scene: the Babylon.js scene
  81927. */
  81928. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  81929. private static _DefaultMaterial;
  81930. }
  81931. }
  81932. declare module BABYLON.GLTF1 {
  81933. /**
  81934. * Implementation of the base glTF spec
  81935. * @hidden
  81936. */
  81937. export class GLTFLoaderBase {
  81938. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  81939. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  81940. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  81941. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  81942. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  81943. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  81944. }
  81945. /**
  81946. * glTF V1 Loader
  81947. * @hidden
  81948. */
  81949. export class GLTFLoader implements IGLTFLoader {
  81950. static Extensions: {
  81951. [name: string]: GLTFLoaderExtension;
  81952. };
  81953. static RegisterExtension(extension: GLTFLoaderExtension): void;
  81954. state: Nullable<GLTFLoaderState>;
  81955. dispose(): void;
  81956. private _importMeshAsync;
  81957. /**
  81958. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  81959. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  81960. * @param scene the scene the meshes should be added to
  81961. * @param forAssetContainer defines if the entities must be stored in the scene
  81962. * @param data gltf data containing information of the meshes in a loaded file
  81963. * @param rootUrl root url to load from
  81964. * @param onProgress event that fires when loading progress has occured
  81965. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  81966. */
  81967. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<IImportMeshAsyncOutput>;
  81968. private _loadAsync;
  81969. /**
  81970. * Imports all objects from a loaded gltf file and adds them to the scene
  81971. * @param scene the scene the objects should be added to
  81972. * @param data gltf data containing information of the meshes in a loaded file
  81973. * @param rootUrl root url to load from
  81974. * @param onProgress event that fires when loading progress has occured
  81975. * @returns a promise which completes when objects have been loaded to the scene
  81976. */
  81977. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void): Promise<void>;
  81978. private _loadShadersAsync;
  81979. private _loadBuffersAsync;
  81980. private _createNodes;
  81981. }
  81982. /** @hidden */
  81983. export abstract class GLTFLoaderExtension {
  81984. private _name;
  81985. constructor(name: string);
  81986. get name(): string;
  81987. /**
  81988. * Defines an override for loading the runtime
  81989. * Return true to stop further extensions from loading the runtime
  81990. */
  81991. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  81992. /**
  81993. * Defines an onverride for creating gltf runtime
  81994. * Return true to stop further extensions from creating the runtime
  81995. */
  81996. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  81997. /**
  81998. * Defines an override for loading buffers
  81999. * Return true to stop further extensions from loading this buffer
  82000. */
  82001. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  82002. /**
  82003. * Defines an override for loading texture buffers
  82004. * Return true to stop further extensions from loading this texture data
  82005. */
  82006. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  82007. /**
  82008. * Defines an override for creating textures
  82009. * Return true to stop further extensions from loading this texture
  82010. */
  82011. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  82012. /**
  82013. * Defines an override for loading shader strings
  82014. * Return true to stop further extensions from loading this shader data
  82015. */
  82016. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  82017. /**
  82018. * Defines an override for loading materials
  82019. * Return true to stop further extensions from loading this material
  82020. */
  82021. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  82022. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  82023. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  82024. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  82025. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  82026. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  82027. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  82028. private static LoadTextureBufferAsync;
  82029. private static CreateTextureAsync;
  82030. private static ApplyExtensions;
  82031. }
  82032. }
  82033. declare module BABYLON.GLTF1 {
  82034. /** @hidden */
  82035. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  82036. private _bin;
  82037. constructor();
  82038. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  82039. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  82040. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  82041. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  82042. }
  82043. }
  82044. declare module BABYLON.GLTF1 {
  82045. /** @hidden */
  82046. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  82047. constructor();
  82048. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  82049. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  82050. private _loadTexture;
  82051. }
  82052. }
  82053. declare module BABYLON.GLTF2.Loader {
  82054. /**
  82055. * Loader interface with an index field.
  82056. */
  82057. export interface IArrayItem {
  82058. /**
  82059. * The index of this item in the array.
  82060. */
  82061. index: number;
  82062. }
  82063. /**
  82064. * Loader interface with additional members.
  82065. */
  82066. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  82067. /** @hidden */
  82068. _data?: Promise<ArrayBufferView>;
  82069. /** @hidden */
  82070. _babylonVertexBuffer?: Promise<VertexBuffer>;
  82071. }
  82072. /**
  82073. * Loader interface with additional members.
  82074. */
  82075. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  82076. }
  82077. /** @hidden */
  82078. export interface _IAnimationSamplerData {
  82079. input: Float32Array;
  82080. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  82081. output: Float32Array;
  82082. }
  82083. /**
  82084. * Loader interface with additional members.
  82085. */
  82086. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  82087. /** @hidden */
  82088. _data?: Promise<_IAnimationSamplerData>;
  82089. }
  82090. /**
  82091. * Loader interface with additional members.
  82092. */
  82093. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  82094. channels: IAnimationChannel[];
  82095. samplers: IAnimationSampler[];
  82096. /** @hidden */
  82097. _babylonAnimationGroup?: AnimationGroup;
  82098. }
  82099. /**
  82100. * Loader interface with additional members.
  82101. */
  82102. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  82103. /** @hidden */
  82104. _data?: Promise<ArrayBufferView>;
  82105. }
  82106. /**
  82107. * Loader interface with additional members.
  82108. */
  82109. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  82110. /** @hidden */
  82111. _data?: Promise<ArrayBufferView>;
  82112. /** @hidden */
  82113. _babylonBuffer?: Promise<Buffer>;
  82114. }
  82115. /**
  82116. * Loader interface with additional members.
  82117. */
  82118. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  82119. }
  82120. /**
  82121. * Loader interface with additional members.
  82122. */
  82123. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  82124. /** @hidden */
  82125. _data?: Promise<ArrayBufferView>;
  82126. }
  82127. /**
  82128. * Loader interface with additional members.
  82129. */
  82130. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  82131. }
  82132. /**
  82133. * Loader interface with additional members.
  82134. */
  82135. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  82136. }
  82137. /**
  82138. * Loader interface with additional members.
  82139. */
  82140. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  82141. baseColorTexture?: ITextureInfo;
  82142. metallicRoughnessTexture?: ITextureInfo;
  82143. }
  82144. /**
  82145. * Loader interface with additional members.
  82146. */
  82147. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  82148. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  82149. normalTexture?: IMaterialNormalTextureInfo;
  82150. occlusionTexture?: IMaterialOcclusionTextureInfo;
  82151. emissiveTexture?: ITextureInfo;
  82152. /** @hidden */
  82153. _data?: {
  82154. [babylonDrawMode: number]: {
  82155. babylonMaterial: Material;
  82156. babylonMeshes: AbstractMesh[];
  82157. promise: Promise<void>;
  82158. };
  82159. };
  82160. }
  82161. /**
  82162. * Loader interface with additional members.
  82163. */
  82164. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  82165. primitives: IMeshPrimitive[];
  82166. }
  82167. /**
  82168. * Loader interface with additional members.
  82169. */
  82170. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  82171. /** @hidden */
  82172. _instanceData?: {
  82173. babylonSourceMesh: Mesh;
  82174. promise: Promise<any>;
  82175. };
  82176. }
  82177. /**
  82178. * Loader interface with additional members.
  82179. */
  82180. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  82181. /**
  82182. * The parent glTF node.
  82183. */
  82184. parent?: INode;
  82185. /** @hidden */
  82186. _babylonTransformNode?: TransformNode;
  82187. /** @hidden */
  82188. _primitiveBabylonMeshes?: AbstractMesh[];
  82189. /** @hidden */
  82190. _babylonBones?: Bone[];
  82191. /** @hidden */
  82192. _numMorphTargets?: number;
  82193. }
  82194. /** @hidden */
  82195. export interface _ISamplerData {
  82196. noMipMaps: boolean;
  82197. samplingMode: number;
  82198. wrapU: number;
  82199. wrapV: number;
  82200. }
  82201. /**
  82202. * Loader interface with additional members.
  82203. */
  82204. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  82205. /** @hidden */
  82206. _data?: _ISamplerData;
  82207. }
  82208. /**
  82209. * Loader interface with additional members.
  82210. */
  82211. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  82212. }
  82213. /**
  82214. * Loader interface with additional members.
  82215. */
  82216. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  82217. /** @hidden */
  82218. _data?: {
  82219. babylonSkeleton: Skeleton;
  82220. promise: Promise<void>;
  82221. };
  82222. }
  82223. /**
  82224. * Loader interface with additional members.
  82225. */
  82226. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  82227. }
  82228. /**
  82229. * Loader interface with additional members.
  82230. */
  82231. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  82232. }
  82233. /**
  82234. * Loader interface with additional members.
  82235. */
  82236. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  82237. accessors?: IAccessor[];
  82238. animations?: IAnimation[];
  82239. buffers?: IBuffer[];
  82240. bufferViews?: IBufferView[];
  82241. cameras?: ICamera[];
  82242. images?: IImage[];
  82243. materials?: IMaterial[];
  82244. meshes?: IMesh[];
  82245. nodes?: INode[];
  82246. samplers?: ISampler[];
  82247. scenes?: IScene[];
  82248. skins?: ISkin[];
  82249. textures?: ITexture[];
  82250. }
  82251. }
  82252. declare module BABYLON.GLTF2 {
  82253. /**
  82254. * Interface for a glTF loader extension.
  82255. */
  82256. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  82257. /**
  82258. * Called after the loader state changes to LOADING.
  82259. */
  82260. onLoading?(): void;
  82261. /**
  82262. * Called after the loader state changes to READY.
  82263. */
  82264. onReady?(): void;
  82265. /**
  82266. * Define this method to modify the default behavior when loading scenes.
  82267. * @param context The context when loading the asset
  82268. * @param scene The glTF scene property
  82269. * @returns A promise that resolves when the load is complete or null if not handled
  82270. */
  82271. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  82272. /**
  82273. * Define this method to modify the default behavior when loading nodes.
  82274. * @param context The context when loading the asset
  82275. * @param node The glTF node property
  82276. * @param assign A function called synchronously after parsing the glTF properties
  82277. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  82278. */
  82279. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  82280. /**
  82281. * Define this method to modify the default behavior when loading cameras.
  82282. * @param context The context when loading the asset
  82283. * @param camera The glTF camera property
  82284. * @param assign A function called synchronously after parsing the glTF properties
  82285. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  82286. */
  82287. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  82288. /**
  82289. * @hidden
  82290. * Define this method to modify the default behavior when loading vertex data for mesh primitives.
  82291. * @param context The context when loading the asset
  82292. * @param primitive The glTF mesh primitive property
  82293. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  82294. */
  82295. _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  82296. /**
  82297. * @hidden
  82298. * Define this method to modify the default behavior when loading data for mesh primitives.
  82299. * @param context The context when loading the asset
  82300. * @param name The mesh name when loading the asset
  82301. * @param node The glTF node when loading the asset
  82302. * @param mesh The glTF mesh when loading the asset
  82303. * @param primitive The glTF mesh primitive property
  82304. * @param assign A function called synchronously after parsing the glTF properties
  82305. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  82306. */
  82307. _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  82308. /**
  82309. * @hidden
  82310. * Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  82311. * @param context The context when loading the asset
  82312. * @param material The glTF material property
  82313. * @param assign A function called synchronously after parsing the glTF properties
  82314. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  82315. */
  82316. _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  82317. /**
  82318. * Define this method to modify the default behavior when creating materials.
  82319. * @param context The context when loading the asset
  82320. * @param material The glTF material property
  82321. * @param babylonDrawMode The draw mode for the Babylon material
  82322. * @returns The Babylon material or null if not handled
  82323. */
  82324. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  82325. /**
  82326. * Define this method to modify the default behavior when loading material properties.
  82327. * @param context The context when loading the asset
  82328. * @param material The glTF material property
  82329. * @param babylonMaterial The Babylon material
  82330. * @returns A promise that resolves when the load is complete or null if not handled
  82331. */
  82332. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82333. /**
  82334. * Define this method to modify the default behavior when loading texture infos.
  82335. * @param context The context when loading the asset
  82336. * @param textureInfo The glTF texture info property
  82337. * @param assign A function called synchronously after parsing the glTF properties
  82338. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  82339. */
  82340. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  82341. /**
  82342. * @hidden
  82343. * Define this method to modify the default behavior when loading textures.
  82344. * @param context The context when loading the asset
  82345. * @param texture The glTF texture property
  82346. * @param assign A function called synchronously after parsing the glTF properties
  82347. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  82348. */
  82349. _loadTextureAsync?(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  82350. /**
  82351. * Define this method to modify the default behavior when loading animations.
  82352. * @param context The context when loading the asset
  82353. * @param animation The glTF animation property
  82354. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  82355. */
  82356. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  82357. /**
  82358. * @hidden
  82359. * Define this method to modify the default behavior when loading skins.
  82360. * @param context The context when loading the asset
  82361. * @param node The glTF node property
  82362. * @param skin The glTF skin property
  82363. * @returns A promise that resolves when the load is complete or null if not handled
  82364. */
  82365. _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  82366. /**
  82367. * @hidden
  82368. * Define this method to modify the default behavior when loading uris.
  82369. * @param context The context when loading the asset
  82370. * @param property The glTF property associated with the uri
  82371. * @param uri The uri to load
  82372. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  82373. */
  82374. _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  82375. /**
  82376. * Define this method to modify the default behavior when loading buffer views.
  82377. * @param context The context when loading the asset
  82378. * @param bufferView The glTF buffer view property
  82379. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  82380. */
  82381. loadBufferViewAsync?(context: string, bufferView: IBufferView): Nullable<Promise<ArrayBufferView>>;
  82382. /**
  82383. * Define this method to modify the default behavior when loading buffers.
  82384. * @param context The context when loading the asset
  82385. * @param buffer The glTF buffer property
  82386. * @param byteOffset The byte offset to load
  82387. * @param byteLength The byte length to load
  82388. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  82389. */
  82390. loadBufferAsync?(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  82391. }
  82392. }
  82393. declare module BABYLON.GLTF2 {
  82394. /**
  82395. * Helper class for working with arrays when loading the glTF asset
  82396. */
  82397. export class ArrayItem {
  82398. /**
  82399. * Gets an item from the given array.
  82400. * @param context The context when loading the asset
  82401. * @param array The array to get the item from
  82402. * @param index The index to the array
  82403. * @returns The array item
  82404. */
  82405. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  82406. /**
  82407. * Assign an `index` field to each item of the given array.
  82408. * @param array The array of items
  82409. */
  82410. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  82411. }
  82412. /**
  82413. * The glTF 2.0 loader
  82414. */
  82415. export class GLTFLoader implements IGLTFLoader {
  82416. /** @hidden */
  82417. _completePromises: Promise<any>[];
  82418. /** @hidden */
  82419. _forAssetContainer: boolean;
  82420. /** Storage */
  82421. _babylonLights: Light[];
  82422. /** @hidden */
  82423. _disableInstancedMesh: number;
  82424. private _disposed;
  82425. private _parent;
  82426. private _state;
  82427. private _extensions;
  82428. private _rootUrl;
  82429. private _fileName;
  82430. private _uniqueRootUrl;
  82431. private _gltf;
  82432. private _bin;
  82433. private _babylonScene;
  82434. private _rootBabylonMesh;
  82435. private _defaultBabylonMaterialData;
  82436. private static _RegisteredExtensions;
  82437. /**
  82438. * The default glTF sampler.
  82439. */
  82440. static readonly DefaultSampler: ISampler;
  82441. /**
  82442. * Registers a loader extension.
  82443. * @param name The name of the loader extension.
  82444. * @param factory The factory function that creates the loader extension.
  82445. */
  82446. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  82447. /**
  82448. * Unregisters a loader extension.
  82449. * @param name The name of the loader extension.
  82450. * @returns A boolean indicating whether the extension has been unregistered
  82451. */
  82452. static UnregisterExtension(name: string): boolean;
  82453. /**
  82454. * The loader state.
  82455. */
  82456. get state(): Nullable<GLTFLoaderState>;
  82457. /**
  82458. * The object that represents the glTF JSON.
  82459. */
  82460. get gltf(): IGLTF;
  82461. /**
  82462. * The BIN chunk of a binary glTF.
  82463. */
  82464. get bin(): Nullable<IDataBuffer>;
  82465. /**
  82466. * The parent file loader.
  82467. */
  82468. get parent(): GLTFFileLoader;
  82469. /**
  82470. * The Babylon scene when loading the asset.
  82471. */
  82472. get babylonScene(): Scene;
  82473. /**
  82474. * The root Babylon mesh when loading the asset.
  82475. */
  82476. get rootBabylonMesh(): Mesh;
  82477. /** @hidden */
  82478. constructor(parent: GLTFFileLoader);
  82479. /** @hidden */
  82480. dispose(): void;
  82481. /** @hidden */
  82482. importMeshAsync(meshesNames: any, scene: Scene, forAssetContainer: boolean, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<IImportMeshAsyncOutput>;
  82483. /** @hidden */
  82484. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  82485. private _loadAsync;
  82486. private _loadData;
  82487. private _setupData;
  82488. private _loadExtensions;
  82489. private _checkExtensions;
  82490. private _setState;
  82491. private _createRootNode;
  82492. /**
  82493. * Loads a glTF scene.
  82494. * @param context The context when loading the asset
  82495. * @param scene The glTF scene property
  82496. * @returns A promise that resolves when the load is complete
  82497. */
  82498. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  82499. private _forEachPrimitive;
  82500. private _getMeshes;
  82501. private _getTransformNodes;
  82502. private _getSkeletons;
  82503. private _getAnimationGroups;
  82504. private _startAnimations;
  82505. /**
  82506. * Loads a glTF node.
  82507. * @param context The context when loading the asset
  82508. * @param node The glTF node property
  82509. * @param assign A function called synchronously after parsing the glTF properties
  82510. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  82511. */
  82512. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  82513. private _loadMeshAsync;
  82514. /**
  82515. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  82516. * @param context The context when loading the asset
  82517. * @param name The mesh name when loading the asset
  82518. * @param node The glTF node when loading the asset
  82519. * @param mesh The glTF mesh when loading the asset
  82520. * @param primitive The glTF mesh primitive property
  82521. * @param assign A function called synchronously after parsing the glTF properties
  82522. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  82523. */
  82524. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  82525. private _loadVertexDataAsync;
  82526. private _createMorphTargets;
  82527. private _loadMorphTargetsAsync;
  82528. private _loadMorphTargetVertexDataAsync;
  82529. private static _LoadTransform;
  82530. private _loadSkinAsync;
  82531. private _loadBones;
  82532. private _loadBone;
  82533. private _loadSkinInverseBindMatricesDataAsync;
  82534. private _updateBoneMatrices;
  82535. private _getNodeMatrix;
  82536. /**
  82537. * Loads a glTF camera.
  82538. * @param context The context when loading the asset
  82539. * @param camera The glTF camera property
  82540. * @param assign A function called synchronously after parsing the glTF properties
  82541. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  82542. */
  82543. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  82544. private _loadAnimationsAsync;
  82545. /**
  82546. * Loads a glTF animation.
  82547. * @param context The context when loading the asset
  82548. * @param animation The glTF animation property
  82549. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  82550. */
  82551. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  82552. /**
  82553. * @hidden Loads a glTF animation channel.
  82554. * @param context The context when loading the asset
  82555. * @param animationContext The context of the animation when loading the asset
  82556. * @param animation The glTF animation property
  82557. * @param channel The glTF animation channel property
  82558. * @param babylonAnimationGroup The babylon animation group property
  82559. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  82560. * @returns A void promise when the channel load is complete
  82561. */
  82562. _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  82563. private _loadAnimationSamplerAsync;
  82564. private _loadBufferAsync;
  82565. /**
  82566. * Loads a glTF buffer view.
  82567. * @param context The context when loading the asset
  82568. * @param bufferView The glTF buffer view property
  82569. * @returns A promise that resolves with the loaded data when the load is complete
  82570. */
  82571. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  82572. private _loadAccessorAsync;
  82573. /** @hidden */
  82574. _loadFloatAccessorAsync(context: string, accessor: IAccessor): Promise<Float32Array>;
  82575. private _loadIndicesAccessorAsync;
  82576. private _loadVertexBufferViewAsync;
  82577. private _loadVertexAccessorAsync;
  82578. private _loadMaterialMetallicRoughnessPropertiesAsync;
  82579. /** @hidden */
  82580. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  82581. private _createDefaultMaterial;
  82582. /**
  82583. * Creates a Babylon material from a glTF material.
  82584. * @param context The context when loading the asset
  82585. * @param material The glTF material property
  82586. * @param babylonDrawMode The draw mode for the Babylon material
  82587. * @returns The Babylon material
  82588. */
  82589. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  82590. /**
  82591. * Loads properties from a glTF material into a Babylon material.
  82592. * @param context The context when loading the asset
  82593. * @param material The glTF material property
  82594. * @param babylonMaterial The Babylon material
  82595. * @returns A promise that resolves when the load is complete
  82596. */
  82597. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  82598. /**
  82599. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  82600. * @param context The context when loading the asset
  82601. * @param material The glTF material property
  82602. * @param babylonMaterial The Babylon material
  82603. * @returns A promise that resolves when the load is complete
  82604. */
  82605. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  82606. /**
  82607. * Loads the alpha properties from a glTF material into a Babylon material.
  82608. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  82609. * @param context The context when loading the asset
  82610. * @param material The glTF material property
  82611. * @param babylonMaterial The Babylon material
  82612. */
  82613. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  82614. /**
  82615. * Loads a glTF texture info.
  82616. * @param context The context when loading the asset
  82617. * @param textureInfo The glTF texture info property
  82618. * @param assign A function called synchronously after parsing the glTF properties
  82619. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  82620. */
  82621. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  82622. /** @hidden */
  82623. _loadTextureAsync(context: string, texture: ITexture, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  82624. /** @hidden */
  82625. _createTextureAsync(context: string, sampler: ISampler, image: IImage, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  82626. private _loadSampler;
  82627. /**
  82628. * Loads a glTF image.
  82629. * @param context The context when loading the asset
  82630. * @param image The glTF image property
  82631. * @returns A promise that resolves with the loaded data when the load is complete
  82632. */
  82633. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  82634. /**
  82635. * Loads a glTF uri.
  82636. * @param context The context when loading the asset
  82637. * @param property The glTF property associated with the uri
  82638. * @param uri The base64 or relative uri
  82639. * @returns A promise that resolves with the loaded data when the load is complete
  82640. */
  82641. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  82642. /**
  82643. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  82644. * @param babylonObject the Babylon object with metadata
  82645. * @param pointer the JSON pointer
  82646. */
  82647. static AddPointerMetadata(babylonObject: {
  82648. metadata: any;
  82649. }, pointer: string): void;
  82650. private static _GetTextureWrapMode;
  82651. private static _GetTextureSamplingMode;
  82652. private static _GetTypedArrayConstructor;
  82653. private static _GetTypedArray;
  82654. private static _GetNumComponents;
  82655. private static _ValidateUri;
  82656. /** @hidden */
  82657. static _GetDrawMode(context: string, mode: number | undefined): number;
  82658. private _compileMaterialsAsync;
  82659. private _compileShadowGeneratorsAsync;
  82660. private _forEachExtensions;
  82661. private _applyExtensions;
  82662. private _extensionsOnLoading;
  82663. private _extensionsOnReady;
  82664. private _extensionsLoadSceneAsync;
  82665. private _extensionsLoadNodeAsync;
  82666. private _extensionsLoadCameraAsync;
  82667. private _extensionsLoadVertexDataAsync;
  82668. private _extensionsLoadMeshPrimitiveAsync;
  82669. private _extensionsLoadMaterialAsync;
  82670. private _extensionsCreateMaterial;
  82671. private _extensionsLoadMaterialPropertiesAsync;
  82672. private _extensionsLoadTextureInfoAsync;
  82673. private _extensionsLoadTextureAsync;
  82674. private _extensionsLoadAnimationAsync;
  82675. private _extensionsLoadSkinAsync;
  82676. private _extensionsLoadUriAsync;
  82677. private _extensionsLoadBufferViewAsync;
  82678. private _extensionsLoadBufferAsync;
  82679. /**
  82680. * Helper method called by a loader extension to load an glTF extension.
  82681. * @param context The context when loading the asset
  82682. * @param property The glTF property to load the extension from
  82683. * @param extensionName The name of the extension to load
  82684. * @param actionAsync The action to run
  82685. * @returns The promise returned by actionAsync or null if the extension does not exist
  82686. */
  82687. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  82688. /**
  82689. * Helper method called by a loader extension to load a glTF extra.
  82690. * @param context The context when loading the asset
  82691. * @param property The glTF property to load the extra from
  82692. * @param extensionName The name of the extension to load
  82693. * @param actionAsync The action to run
  82694. * @returns The promise returned by actionAsync or null if the extra does not exist
  82695. */
  82696. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  82697. /**
  82698. * Checks for presence of an extension.
  82699. * @param name The name of the extension to check
  82700. * @returns A boolean indicating the presence of the given extension name in `extensionsUsed`
  82701. */
  82702. isExtensionUsed(name: string): boolean;
  82703. /**
  82704. * Increments the indentation level and logs a message.
  82705. * @param message The message to log
  82706. */
  82707. logOpen(message: string): void;
  82708. /**
  82709. * Decrements the indentation level.
  82710. */
  82711. logClose(): void;
  82712. /**
  82713. * Logs a message
  82714. * @param message The message to log
  82715. */
  82716. log(message: string): void;
  82717. /**
  82718. * Starts a performance counter.
  82719. * @param counterName The name of the performance counter
  82720. */
  82721. startPerformanceCounter(counterName: string): void;
  82722. /**
  82723. * Ends a performance counter.
  82724. * @param counterName The name of the performance counter
  82725. */
  82726. endPerformanceCounter(counterName: string): void;
  82727. }
  82728. }
  82729. declare module BABYLON.GLTF2.Loader.Extensions {
  82730. /** @hidden */
  82731. interface IEXTLightsImageBased_LightImageBased {
  82732. _babylonTexture?: BaseTexture;
  82733. _loaded?: Promise<void>;
  82734. }
  82735. /**
  82736. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_lights_image_based/README.md)
  82737. */
  82738. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  82739. /**
  82740. * The name of this extension.
  82741. */
  82742. readonly name: string;
  82743. /**
  82744. * Defines whether this extension is enabled.
  82745. */
  82746. enabled: boolean;
  82747. private _loader;
  82748. private _lights?;
  82749. /** @hidden */
  82750. constructor(loader: GLTFLoader);
  82751. /** @hidden */
  82752. dispose(): void;
  82753. /** @hidden */
  82754. onLoading(): void;
  82755. /** @hidden */
  82756. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  82757. private _loadLightAsync;
  82758. }
  82759. }
  82760. declare module BABYLON.GLTF2.Loader.Extensions {
  82761. /**
  82762. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1691)
  82763. * [Playground Sample](https://playground.babylonjs.com/#QFIGLW#9)
  82764. * !!! Experimental Extension Subject to Changes !!!
  82765. */
  82766. export class EXT_mesh_gpu_instancing implements IGLTFLoaderExtension {
  82767. /**
  82768. * The name of this extension.
  82769. */
  82770. readonly name: string;
  82771. /**
  82772. * Defines whether this extension is enabled.
  82773. */
  82774. enabled: boolean;
  82775. private _loader;
  82776. /** @hidden */
  82777. constructor(loader: GLTFLoader);
  82778. /** @hidden */
  82779. dispose(): void;
  82780. /** @hidden */
  82781. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  82782. }
  82783. }
  82784. declare module BABYLON.GLTF2.Loader.Extensions {
  82785. /**
  82786. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Vendor/EXT_texture_webp/)
  82787. */
  82788. export class EXT_texture_webp implements IGLTFLoaderExtension {
  82789. /** The name of this extension. */
  82790. readonly name: string;
  82791. /** Defines whether this extension is enabled. */
  82792. enabled: boolean;
  82793. private _loader;
  82794. /** @hidden */
  82795. constructor(loader: GLTFLoader);
  82796. /** @hidden */
  82797. dispose(): void;
  82798. /** @hidden */
  82799. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  82800. }
  82801. }
  82802. declare module BABYLON.GLTF2.Loader.Extensions {
  82803. /**
  82804. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  82805. */
  82806. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  82807. /**
  82808. * The name of this extension.
  82809. */
  82810. readonly name: string;
  82811. /**
  82812. * The draco compression used to decode vertex data or DracoCompression.Default if not defined
  82813. */
  82814. dracoCompression?: DracoCompression;
  82815. /**
  82816. * Defines whether this extension is enabled.
  82817. */
  82818. enabled: boolean;
  82819. private _loader;
  82820. /** @hidden */
  82821. constructor(loader: GLTFLoader);
  82822. /** @hidden */
  82823. dispose(): void;
  82824. /** @hidden */
  82825. _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  82826. }
  82827. }
  82828. declare module BABYLON.GLTF2.Loader.Extensions {
  82829. /**
  82830. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual)
  82831. */
  82832. export class KHR_lights implements IGLTFLoaderExtension {
  82833. /**
  82834. * The name of this extension.
  82835. */
  82836. readonly name: string;
  82837. /**
  82838. * Defines whether this extension is enabled.
  82839. */
  82840. enabled: boolean;
  82841. private _loader;
  82842. private _lights?;
  82843. /** @hidden */
  82844. constructor(loader: GLTFLoader);
  82845. /** @hidden */
  82846. dispose(): void;
  82847. /** @hidden */
  82848. onLoading(): void;
  82849. /** @hidden */
  82850. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  82851. }
  82852. }
  82853. declare module BABYLON.GLTF2.Loader.Extensions {
  82854. /**
  82855. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  82856. */
  82857. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  82858. /**
  82859. * The name of this extension.
  82860. */
  82861. readonly name: string;
  82862. /**
  82863. * Defines whether this extension is enabled.
  82864. */
  82865. enabled: boolean;
  82866. /**
  82867. * Defines a number that determines the order the extensions are applied.
  82868. */
  82869. order: number;
  82870. private _loader;
  82871. /** @hidden */
  82872. constructor(loader: GLTFLoader);
  82873. /** @hidden */
  82874. dispose(): void;
  82875. /** @hidden */
  82876. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82877. private _loadSpecularGlossinessPropertiesAsync;
  82878. }
  82879. }
  82880. declare module BABYLON.GLTF2.Loader.Extensions {
  82881. /**
  82882. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  82883. */
  82884. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  82885. /**
  82886. * The name of this extension.
  82887. */
  82888. readonly name: string;
  82889. /**
  82890. * Defines whether this extension is enabled.
  82891. */
  82892. enabled: boolean;
  82893. /**
  82894. * Defines a number that determines the order the extensions are applied.
  82895. */
  82896. order: number;
  82897. private _loader;
  82898. /** @hidden */
  82899. constructor(loader: GLTFLoader);
  82900. /** @hidden */
  82901. dispose(): void;
  82902. /** @hidden */
  82903. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82904. private _loadUnlitPropertiesAsync;
  82905. }
  82906. }
  82907. declare module BABYLON.GLTF2.Loader.Extensions {
  82908. /**
  82909. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1677)
  82910. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#7F7PN6#8)
  82911. * !!! Experimental Extension Subject to Changes !!!
  82912. */
  82913. export class KHR_materials_clearcoat implements IGLTFLoaderExtension {
  82914. /**
  82915. * The name of this extension.
  82916. */
  82917. readonly name: string;
  82918. /**
  82919. * Defines whether this extension is enabled.
  82920. */
  82921. enabled: boolean;
  82922. /**
  82923. * Defines a number that determines the order the extensions are applied.
  82924. */
  82925. order: number;
  82926. private _loader;
  82927. /** @hidden */
  82928. constructor(loader: GLTFLoader);
  82929. /** @hidden */
  82930. dispose(): void;
  82931. /** @hidden */
  82932. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82933. private _loadClearCoatPropertiesAsync;
  82934. }
  82935. }
  82936. declare module BABYLON.GLTF2.Loader.Extensions {
  82937. /**
  82938. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1688)
  82939. * [Playground Sample](https://www.babylonjs-playground.com/frame.html#BNIZX6#4)
  82940. * !!! Experimental Extension Subject to Changes !!!
  82941. */
  82942. export class KHR_materials_sheen implements IGLTFLoaderExtension {
  82943. /**
  82944. * The name of this extension.
  82945. */
  82946. readonly name: string;
  82947. /**
  82948. * Defines whether this extension is enabled.
  82949. */
  82950. enabled: boolean;
  82951. /**
  82952. * Defines a number that determines the order the extensions are applied.
  82953. */
  82954. order: number;
  82955. private _loader;
  82956. /** @hidden */
  82957. constructor(loader: GLTFLoader);
  82958. /** @hidden */
  82959. dispose(): void;
  82960. /** @hidden */
  82961. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82962. private _loadSheenPropertiesAsync;
  82963. }
  82964. }
  82965. declare module BABYLON.GLTF2.Loader.Extensions {
  82966. /**
  82967. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1719)
  82968. * !!! Experimental Extension Subject to Changes !!!
  82969. */
  82970. export class KHR_materials_specular implements IGLTFLoaderExtension {
  82971. /**
  82972. * The name of this extension.
  82973. */
  82974. readonly name: string;
  82975. /**
  82976. * Defines whether this extension is enabled.
  82977. */
  82978. enabled: boolean;
  82979. /**
  82980. * Defines a number that determines the order the extensions are applied.
  82981. */
  82982. order: number;
  82983. private _loader;
  82984. /** @hidden */
  82985. constructor(loader: GLTFLoader);
  82986. /** @hidden */
  82987. dispose(): void;
  82988. /** @hidden */
  82989. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  82990. private _loadSpecularPropertiesAsync;
  82991. }
  82992. }
  82993. declare module BABYLON.GLTF2.Loader.Extensions {
  82994. /**
  82995. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1718)
  82996. * !!! Experimental Extension Subject to Changes !!!
  82997. */
  82998. export class KHR_materials_ior implements IGLTFLoaderExtension {
  82999. /**
  83000. * Default ior Value from the spec.
  83001. */
  83002. private static readonly _DEFAULT_IOR;
  83003. /**
  83004. * The name of this extension.
  83005. */
  83006. readonly name: string;
  83007. /**
  83008. * Defines whether this extension is enabled.
  83009. */
  83010. enabled: boolean;
  83011. /**
  83012. * Defines a number that determines the order the extensions are applied.
  83013. */
  83014. order: number;
  83015. private _loader;
  83016. /** @hidden */
  83017. constructor(loader: GLTFLoader);
  83018. /** @hidden */
  83019. dispose(): void;
  83020. /** @hidden */
  83021. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83022. private _loadIorPropertiesAsync;
  83023. }
  83024. }
  83025. declare module BABYLON.GLTF2.Loader.Extensions {
  83026. /**
  83027. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1681)
  83028. * !!! Experimental Extension Subject to Changes !!!
  83029. */
  83030. export class KHR_materials_variants implements IGLTFLoaderExtension {
  83031. /**
  83032. * The name of this extension.
  83033. */
  83034. readonly name: string;
  83035. /**
  83036. * Defines whether this extension is enabled.
  83037. */
  83038. enabled: boolean;
  83039. private _loader;
  83040. private _variants?;
  83041. /** @hidden */
  83042. constructor(loader: GLTFLoader);
  83043. /** @hidden */
  83044. dispose(): void;
  83045. /**
  83046. * Gets the list of available variant names for this asset.
  83047. * @param rootMesh The glTF root mesh
  83048. * @returns the list of all the variant names for this model
  83049. */
  83050. static GetAvailableVariants(rootMesh: Mesh): string[];
  83051. /**
  83052. * Gets the list of available variant names for this asset.
  83053. * @param rootMesh The glTF root mesh
  83054. * @returns the list of all the variant names for this model
  83055. */
  83056. getAvailableVariants(rootMesh: Mesh): string[];
  83057. /**
  83058. * Select a variant given a variant name or a list of variant names.
  83059. * @param rootMesh The glTF root mesh
  83060. * @param variantName The variant name(s) to select.
  83061. */
  83062. static SelectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  83063. /**
  83064. * Select a variant given a variant name or a list of variant names.
  83065. * @param rootMesh The glTF root mesh
  83066. * @param variantName The variant name(s) to select.
  83067. */
  83068. selectVariant(rootMesh: Mesh, variantName: string | string[]): void;
  83069. /**
  83070. * Reset back to the original before selecting a variant.
  83071. * @param rootMesh The glTF root mesh
  83072. */
  83073. static Reset(rootMesh: Mesh): void;
  83074. /**
  83075. * Reset back to the original before selecting a variant.
  83076. * @param rootMesh The glTF root mesh
  83077. */
  83078. reset(rootMesh: Mesh): void;
  83079. /**
  83080. * Gets the last selected variant name(s) or null if original.
  83081. * @param rootMesh The glTF root mesh
  83082. * @returns The selected variant name(s).
  83083. */
  83084. static GetLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  83085. /**
  83086. * Gets the last selected variant name(s) or null if original.
  83087. * @param rootMesh The glTF root mesh
  83088. * @returns The selected variant name(s).
  83089. */
  83090. getLastSelectedVariant(rootMesh: Mesh): Nullable<string | string[]>;
  83091. private static _GetExtensionMetadata;
  83092. /** @hidden */
  83093. onLoading(): void;
  83094. /** @hidden */
  83095. _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Nullable<Promise<AbstractMesh>>;
  83096. }
  83097. }
  83098. declare module BABYLON.GLTF2.Loader.Extensions {
  83099. /**
  83100. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1698)
  83101. * !!! Experimental Extension Subject to Changes !!!
  83102. */
  83103. export class KHR_materials_transmission implements IGLTFLoaderExtension {
  83104. /**
  83105. * The name of this extension.
  83106. */
  83107. readonly name: string;
  83108. /**
  83109. * Defines whether this extension is enabled.
  83110. */
  83111. enabled: boolean;
  83112. /**
  83113. * Defines a number that determines the order the extensions are applied.
  83114. */
  83115. order: number;
  83116. private _loader;
  83117. /** @hidden */
  83118. constructor(loader: GLTFLoader);
  83119. /** @hidden */
  83120. dispose(): void;
  83121. /** @hidden */
  83122. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83123. private _loadTransparentPropertiesAsync;
  83124. }
  83125. }
  83126. declare module BABYLON.GLTF2.Loader.Extensions {
  83127. /**
  83128. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_mesh_quantization)
  83129. */
  83130. export class KHR_mesh_quantization implements IGLTFLoaderExtension {
  83131. /**
  83132. * The name of this extension.
  83133. */
  83134. readonly name: string;
  83135. /**
  83136. * Defines whether this extension is enabled.
  83137. */
  83138. enabled: boolean;
  83139. /** @hidden */
  83140. constructor(loader: GLTFLoader);
  83141. /** @hidden */
  83142. dispose(): void;
  83143. }
  83144. }
  83145. declare module BABYLON.GLTF2.Loader.Extensions {
  83146. /**
  83147. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1751)
  83148. * !!! Experimental Extension Subject to Changes !!!
  83149. */
  83150. export class KHR_texture_basisu implements IGLTFLoaderExtension {
  83151. /** The name of this extension. */
  83152. readonly name: string;
  83153. /** Defines whether this extension is enabled. */
  83154. enabled: boolean;
  83155. private _loader;
  83156. /** @hidden */
  83157. constructor(loader: GLTFLoader);
  83158. /** @hidden */
  83159. dispose(): void;
  83160. /** @hidden */
  83161. _loadTextureAsync(context: string, texture: ITexture, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  83162. }
  83163. }
  83164. declare module BABYLON.GLTF2.Loader.Extensions {
  83165. /**
  83166. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform)
  83167. */
  83168. export class KHR_texture_transform implements IGLTFLoaderExtension {
  83169. /**
  83170. * The name of this extension.
  83171. */
  83172. readonly name: string;
  83173. /**
  83174. * Defines whether this extension is enabled.
  83175. */
  83176. enabled: boolean;
  83177. private _loader;
  83178. /** @hidden */
  83179. constructor(loader: GLTFLoader);
  83180. /** @hidden */
  83181. dispose(): void;
  83182. /** @hidden */
  83183. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  83184. }
  83185. }
  83186. declare module BABYLON.GLTF2.Loader.Extensions {
  83187. /**
  83188. * [Proposed Specification](https://github.com/KhronosGroup/glTF/pull/1553)
  83189. * !!! Experimental Extension Subject to Changes !!!
  83190. */
  83191. export class KHR_xmp implements IGLTFLoaderExtension {
  83192. /**
  83193. * The name of this extension.
  83194. */
  83195. readonly name: string;
  83196. /**
  83197. * Defines whether this extension is enabled.
  83198. */
  83199. enabled: boolean;
  83200. /**
  83201. * Defines a number that determines the order the extensions are applied.
  83202. */
  83203. order: number;
  83204. private _loader;
  83205. /** @hidden */
  83206. constructor(loader: GLTFLoader);
  83207. /** @hidden */
  83208. dispose(): void;
  83209. /**
  83210. * Called after the loader state changes to LOADING.
  83211. */
  83212. onLoading(): void;
  83213. }
  83214. }
  83215. declare module BABYLON.GLTF2.Loader.Extensions {
  83216. /**
  83217. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  83218. */
  83219. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  83220. /**
  83221. * The name of this extension.
  83222. */
  83223. readonly name: string;
  83224. /**
  83225. * Defines whether this extension is enabled.
  83226. */
  83227. enabled: boolean;
  83228. private _loader;
  83229. private _clips;
  83230. private _emitters;
  83231. /** @hidden */
  83232. constructor(loader: GLTFLoader);
  83233. /** @hidden */
  83234. dispose(): void;
  83235. /** @hidden */
  83236. onLoading(): void;
  83237. /** @hidden */
  83238. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  83239. /** @hidden */
  83240. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  83241. /** @hidden */
  83242. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  83243. private _loadClipAsync;
  83244. private _loadEmitterAsync;
  83245. private _getEventAction;
  83246. private _loadAnimationEventAsync;
  83247. }
  83248. }
  83249. declare module BABYLON.GLTF2.Loader.Extensions {
  83250. /**
  83251. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  83252. */
  83253. export class MSFT_lod implements IGLTFLoaderExtension {
  83254. /**
  83255. * The name of this extension.
  83256. */
  83257. readonly name: string;
  83258. /**
  83259. * Defines whether this extension is enabled.
  83260. */
  83261. enabled: boolean;
  83262. /**
  83263. * Defines a number that determines the order the extensions are applied.
  83264. */
  83265. order: number;
  83266. /**
  83267. * Maximum number of LODs to load, starting from the lowest LOD.
  83268. */
  83269. maxLODsToLoad: number;
  83270. /**
  83271. * Observable raised when all node LODs of one level are loaded.
  83272. * The event data is the index of the loaded LOD starting from zero.
  83273. * Dispose the loader to cancel the loading of the next level of LODs.
  83274. */
  83275. onNodeLODsLoadedObservable: Observable<number>;
  83276. /**
  83277. * Observable raised when all material LODs of one level are loaded.
  83278. * The event data is the index of the loaded LOD starting from zero.
  83279. * Dispose the loader to cancel the loading of the next level of LODs.
  83280. */
  83281. onMaterialLODsLoadedObservable: Observable<number>;
  83282. private _loader;
  83283. private _bufferLODs;
  83284. private _nodeIndexLOD;
  83285. private _nodeSignalLODs;
  83286. private _nodePromiseLODs;
  83287. private _nodeBufferLODs;
  83288. private _materialIndexLOD;
  83289. private _materialSignalLODs;
  83290. private _materialPromiseLODs;
  83291. private _materialBufferLODs;
  83292. /** @hidden */
  83293. constructor(loader: GLTFLoader);
  83294. /** @hidden */
  83295. dispose(): void;
  83296. /** @hidden */
  83297. onReady(): void;
  83298. /** @hidden */
  83299. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  83300. /** @hidden */
  83301. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  83302. /** @hidden */
  83303. _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Nullable<Mesh>, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  83304. /** @hidden */
  83305. _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  83306. /** @hidden */
  83307. loadBufferAsync(context: string, buffer: IBuffer, byteOffset: number, byteLength: number): Nullable<Promise<ArrayBufferView>>;
  83308. private _loadBufferLOD;
  83309. /**
  83310. * Gets an array of LOD properties from lowest to highest.
  83311. */
  83312. private _getLODs;
  83313. private _disposeTransformNode;
  83314. private _disposeMaterials;
  83315. }
  83316. }
  83317. declare module BABYLON.GLTF2.Loader.Extensions {
  83318. /** @hidden */
  83319. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  83320. readonly name: string;
  83321. enabled: boolean;
  83322. private _loader;
  83323. constructor(loader: GLTFLoader);
  83324. dispose(): void;
  83325. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83326. }
  83327. }
  83328. declare module BABYLON.GLTF2.Loader.Extensions {
  83329. /** @hidden */
  83330. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  83331. readonly name: string;
  83332. enabled: boolean;
  83333. private _loader;
  83334. constructor(loader: GLTFLoader);
  83335. dispose(): void;
  83336. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  83337. }
  83338. }
  83339. declare module BABYLON.GLTF2.Loader.Extensions {
  83340. /**
  83341. * Store glTF extras (if present) in BJS objects' metadata
  83342. */
  83343. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  83344. /**
  83345. * The name of this extension.
  83346. */
  83347. readonly name: string;
  83348. /**
  83349. * Defines whether this extension is enabled.
  83350. */
  83351. enabled: boolean;
  83352. private _loader;
  83353. private _assignExtras;
  83354. /** @hidden */
  83355. constructor(loader: GLTFLoader);
  83356. /** @hidden */
  83357. dispose(): void;
  83358. /** @hidden */
  83359. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  83360. /** @hidden */
  83361. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  83362. /** @hidden */
  83363. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  83364. }
  83365. }
  83366. declare module BABYLON {
  83367. /**
  83368. * Class reading and parsing the MTL file bundled with the obj file.
  83369. */
  83370. export class MTLFileLoader {
  83371. /**
  83372. * Invert Y-Axis of referenced textures on load
  83373. */
  83374. static INVERT_TEXTURE_Y: boolean;
  83375. /**
  83376. * All material loaded from the mtl will be set here
  83377. */
  83378. materials: StandardMaterial[];
  83379. /**
  83380. * This function will read the mtl file and create each material described inside
  83381. * This function could be improve by adding :
  83382. * -some component missing (Ni, Tf...)
  83383. * -including the specific options available
  83384. *
  83385. * @param scene defines the scene the material will be created in
  83386. * @param data defines the mtl data to parse
  83387. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  83388. * @param forAssetContainer defines if the material should be registered in the scene
  83389. */
  83390. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string, forAssetContainer: boolean): void;
  83391. /**
  83392. * Gets the texture for the material.
  83393. *
  83394. * If the material is imported from input file,
  83395. * We sanitize the url to ensure it takes the textre from aside the material.
  83396. *
  83397. * @param rootUrl The root url to load from
  83398. * @param value The value stored in the mtl
  83399. * @return The Texture
  83400. */
  83401. private static _getTexture;
  83402. }
  83403. }
  83404. declare module BABYLON {
  83405. /**
  83406. * Options for loading OBJ/MTL files
  83407. */
  83408. type MeshLoadOptions = {
  83409. /**
  83410. * Defines if UVs are optimized by default during load.
  83411. */
  83412. OptimizeWithUV: boolean;
  83413. /**
  83414. * Defines custom scaling of UV coordinates of loaded meshes.
  83415. */
  83416. UVScaling: Vector2;
  83417. /**
  83418. * Invert model on y-axis (does a model scaling inversion)
  83419. */
  83420. InvertY: boolean;
  83421. /**
  83422. * Invert Y-Axis of referenced textures on load
  83423. */
  83424. InvertTextureY: boolean;
  83425. /**
  83426. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  83427. */
  83428. ImportVertexColors: boolean;
  83429. /**
  83430. * Compute the normals for the model, even if normals are present in the file.
  83431. */
  83432. ComputeNormals: boolean;
  83433. /**
  83434. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  83435. */
  83436. SkipMaterials: boolean;
  83437. /**
  83438. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  83439. */
  83440. MaterialLoadingFailsSilently: boolean;
  83441. };
  83442. /**
  83443. * OBJ file type loader.
  83444. * This is a babylon scene loader plugin.
  83445. */
  83446. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  83447. /**
  83448. * Defines if UVs are optimized by default during load.
  83449. */
  83450. static OPTIMIZE_WITH_UV: boolean;
  83451. /**
  83452. * Invert model on y-axis (does a model scaling inversion)
  83453. */
  83454. static INVERT_Y: boolean;
  83455. /**
  83456. * Invert Y-Axis of referenced textures on load
  83457. */
  83458. static get INVERT_TEXTURE_Y(): boolean;
  83459. static set INVERT_TEXTURE_Y(value: boolean);
  83460. /**
  83461. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  83462. */
  83463. static IMPORT_VERTEX_COLORS: boolean;
  83464. /**
  83465. * Compute the normals for the model, even if normals are present in the file.
  83466. */
  83467. static COMPUTE_NORMALS: boolean;
  83468. /**
  83469. * Defines custom scaling of UV coordinates of loaded meshes.
  83470. */
  83471. static UV_SCALING: Vector2;
  83472. /**
  83473. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  83474. */
  83475. static SKIP_MATERIALS: boolean;
  83476. /**
  83477. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  83478. *
  83479. * Defaults to true for backwards compatibility.
  83480. */
  83481. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  83482. /**
  83483. * Defines the name of the plugin.
  83484. */
  83485. name: string;
  83486. /**
  83487. * Defines the extension the plugin is able to load.
  83488. */
  83489. extensions: string;
  83490. /** @hidden */
  83491. obj: RegExp;
  83492. /** @hidden */
  83493. group: RegExp;
  83494. /** @hidden */
  83495. mtllib: RegExp;
  83496. /** @hidden */
  83497. usemtl: RegExp;
  83498. /** @hidden */
  83499. smooth: RegExp;
  83500. /** @hidden */
  83501. vertexPattern: RegExp;
  83502. /** @hidden */
  83503. normalPattern: RegExp;
  83504. /** @hidden */
  83505. uvPattern: RegExp;
  83506. /** @hidden */
  83507. facePattern1: RegExp;
  83508. /** @hidden */
  83509. facePattern2: RegExp;
  83510. /** @hidden */
  83511. facePattern3: RegExp;
  83512. /** @hidden */
  83513. facePattern4: RegExp;
  83514. /** @hidden */
  83515. facePattern5: RegExp;
  83516. private _forAssetContainer;
  83517. private _meshLoadOptions;
  83518. /**
  83519. * Creates loader for .OBJ files
  83520. *
  83521. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  83522. */
  83523. constructor(meshLoadOptions?: MeshLoadOptions);
  83524. private static get currentMeshLoadOptions();
  83525. /**
  83526. * Calls synchronously the MTL file attached to this obj.
  83527. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  83528. * Without this function materials are not displayed in the first frame (but displayed after).
  83529. * In consequence it is impossible to get material information in your HTML file
  83530. *
  83531. * @param url The URL of the MTL file
  83532. * @param rootUrl
  83533. * @param onSuccess Callback function to be called when the MTL file is loaded
  83534. * @private
  83535. */
  83536. private _loadMTL;
  83537. /**
  83538. * Instantiates a OBJ file loader plugin.
  83539. * @returns the created plugin
  83540. */
  83541. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  83542. /**
  83543. * If the data string can be loaded directly.
  83544. *
  83545. * @param data string containing the file data
  83546. * @returns if the data can be loaded directly
  83547. */
  83548. canDirectLoad(data: string): boolean;
  83549. /**
  83550. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  83551. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  83552. * @param scene the scene the meshes should be added to
  83553. * @param data the OBJ data to load
  83554. * @param rootUrl root url to load from
  83555. * @param onProgress event that fires when loading progress has occured
  83556. * @param fileName Defines the name of the file to load
  83557. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  83558. */
  83559. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  83560. meshes: AbstractMesh[];
  83561. particleSystems: IParticleSystem[];
  83562. skeletons: Skeleton[];
  83563. animationGroups: AnimationGroup[];
  83564. }>;
  83565. /**
  83566. * Imports all objects from the loaded OBJ data and adds them to the scene
  83567. * @param scene the scene the objects should be added to
  83568. * @param data the OBJ data to load
  83569. * @param rootUrl root url to load from
  83570. * @param onProgress event that fires when loading progress has occured
  83571. * @param fileName Defines the name of the file to load
  83572. * @returns a promise which completes when objects have been loaded to the scene
  83573. */
  83574. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  83575. /**
  83576. * Load into an asset container.
  83577. * @param scene The scene to load into
  83578. * @param data The data to import
  83579. * @param rootUrl The root url for scene and resources
  83580. * @param onProgress The callback when the load progresses
  83581. * @param fileName Defines the name of the file to load
  83582. * @returns The loaded asset container
  83583. */
  83584. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  83585. /**
  83586. * Read the OBJ file and create an Array of meshes.
  83587. * Each mesh contains all information given by the OBJ and the MTL file.
  83588. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  83589. *
  83590. * @param meshesNames
  83591. * @param scene Scene The scene where are displayed the data
  83592. * @param data String The content of the obj file
  83593. * @param rootUrl String The path to the folder
  83594. * @returns Array<AbstractMesh>
  83595. * @private
  83596. */
  83597. private _parseSolid;
  83598. }
  83599. }
  83600. declare module BABYLON {
  83601. /**
  83602. * STL file type loader.
  83603. * This is a babylon scene loader plugin.
  83604. */
  83605. export class STLFileLoader implements ISceneLoaderPlugin {
  83606. /** @hidden */
  83607. solidPattern: RegExp;
  83608. /** @hidden */
  83609. facetsPattern: RegExp;
  83610. /** @hidden */
  83611. normalPattern: RegExp;
  83612. /** @hidden */
  83613. vertexPattern: RegExp;
  83614. /**
  83615. * Defines the name of the plugin.
  83616. */
  83617. name: string;
  83618. /**
  83619. * Defines the extensions the stl loader is able to load.
  83620. * force data to come in as an ArrayBuffer
  83621. * we'll convert to string if it looks like it's an ASCII .stl
  83622. */
  83623. extensions: ISceneLoaderPluginExtensions;
  83624. /**
  83625. * Import meshes into a scene.
  83626. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  83627. * @param scene The scene to import into
  83628. * @param data The data to import
  83629. * @param rootUrl The root url for scene and resources
  83630. * @param meshes The meshes array to import into
  83631. * @param particleSystems The particle systems array to import into
  83632. * @param skeletons The skeletons array to import into
  83633. * @param onError The callback when import fails
  83634. * @returns True if successful or false otherwise
  83635. */
  83636. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  83637. /**
  83638. * Load into a scene.
  83639. * @param scene The scene to load into
  83640. * @param data The data to import
  83641. * @param rootUrl The root url for scene and resources
  83642. * @param onError The callback when import fails
  83643. * @returns true if successful or false otherwise
  83644. */
  83645. load(scene: Scene, data: any, rootUrl: string): boolean;
  83646. /**
  83647. * Load into an asset container.
  83648. * @param scene The scene to load into
  83649. * @param data The data to import
  83650. * @param rootUrl The root url for scene and resources
  83651. * @param onError The callback when import fails
  83652. * @returns The loaded asset container
  83653. */
  83654. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  83655. private _isBinary;
  83656. private _parseBinary;
  83657. private _parseASCII;
  83658. }
  83659. }
  83660. declare module BABYLON {
  83661. /**
  83662. * Class for generating OBJ data from a Babylon scene.
  83663. */
  83664. export class OBJExport {
  83665. /**
  83666. * Exports the geometry of a Mesh array in .OBJ file format (text)
  83667. * @param mesh defines the list of meshes to serialize
  83668. * @param materials defines if materials should be exported
  83669. * @param matlibname defines the name of the associated mtl file
  83670. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  83671. * @returns the OBJ content
  83672. */
  83673. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  83674. /**
  83675. * Exports the material(s) of a mesh in .MTL file format (text)
  83676. * @param mesh defines the mesh to extract the material from
  83677. * @returns the mtl content
  83678. */
  83679. static MTL(mesh: Mesh): string;
  83680. }
  83681. }
  83682. declare module BABYLON {
  83683. /** @hidden */
  83684. export var __IGLTFExporterExtension: number;
  83685. /**
  83686. * Interface for extending the exporter
  83687. * @hidden
  83688. */
  83689. export interface IGLTFExporterExtension {
  83690. /**
  83691. * The name of this extension
  83692. */
  83693. readonly name: string;
  83694. /**
  83695. * Defines whether this extension is enabled
  83696. */
  83697. enabled: boolean;
  83698. /**
  83699. * Defines whether this extension is required
  83700. */
  83701. required: boolean;
  83702. }
  83703. }
  83704. declare module BABYLON.GLTF2.Exporter {
  83705. /** @hidden */
  83706. export var __IGLTFExporterExtensionV2: number;
  83707. /**
  83708. * Interface for a glTF exporter extension
  83709. * @hidden
  83710. */
  83711. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  83712. /**
  83713. * Define this method to modify the default behavior before exporting a texture
  83714. * @param context The context when loading the asset
  83715. * @param babylonTexture The Babylon.js texture
  83716. * @param mimeType The mime-type of the generated image
  83717. * @returns A promise that resolves with the exported texture
  83718. */
  83719. preExportTextureAsync?(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Texture>;
  83720. /**
  83721. * Define this method to get notified when a texture info is created
  83722. * @param context The context when loading the asset
  83723. * @param textureInfo The glTF texture info
  83724. * @param babylonTexture The Babylon.js texture
  83725. */
  83726. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  83727. /**
  83728. * Define this method to modify the default behavior when exporting texture info
  83729. * @param context The context when loading the asset
  83730. * @param meshPrimitive glTF mesh primitive
  83731. * @param babylonSubMesh Babylon submesh
  83732. * @param binaryWriter glTF serializer binary writer instance
  83733. * @returns nullable IMeshPrimitive promise
  83734. */
  83735. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: Nullable<IMeshPrimitive>, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<IMeshPrimitive>;
  83736. /**
  83737. * Define this method to modify the default behavior when exporting a node
  83738. * @param context The context when exporting the node
  83739. * @param node glTF node
  83740. * @param babylonNode BabylonJS node
  83741. * @returns nullable INode promise
  83742. */
  83743. postExportNodeAsync?(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  83744. [key: number]: number;
  83745. }): Promise<Nullable<INode>>;
  83746. /**
  83747. * Define this method to modify the default behavior when exporting a material
  83748. * @param material glTF material
  83749. * @param babylonMaterial BabylonJS material
  83750. * @returns nullable IMaterial promise
  83751. */
  83752. postExportMaterialAsync?(context: string, node: Nullable<IMaterial>, babylonMaterial: Material): Promise<IMaterial>;
  83753. /**
  83754. * Define this method to return additional textures to export from a material
  83755. * @param material glTF material
  83756. * @param babylonMaterial BabylonJS material
  83757. * @returns List of textures
  83758. */
  83759. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  83760. /** Gets a boolean indicating that this extension was used */
  83761. wasUsed: boolean;
  83762. /** Gets a boolean indicating that this extension is required for the file to work */
  83763. required: boolean;
  83764. /**
  83765. * Called after the exporter state changes to EXPORTING
  83766. */
  83767. onExporting?(): void;
  83768. }
  83769. }
  83770. declare module BABYLON.GLTF2.Exporter {
  83771. /**
  83772. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  83773. * @hidden
  83774. */
  83775. export class _GLTFMaterialExporter {
  83776. /**
  83777. * Represents the dielectric specular values for R, G and B
  83778. */
  83779. private static readonly _DielectricSpecular;
  83780. /**
  83781. * Allows the maximum specular power to be defined for material calculations
  83782. */
  83783. private static readonly _MaxSpecularPower;
  83784. /**
  83785. * Mapping to store textures
  83786. */
  83787. private _textureMap;
  83788. /**
  83789. * Numeric tolerance value
  83790. */
  83791. private static readonly _Epsilon;
  83792. /**
  83793. * Reference to the glTF Exporter
  83794. */
  83795. private _exporter;
  83796. constructor(exporter: _Exporter);
  83797. /**
  83798. * Specifies if two colors are approximately equal in value
  83799. * @param color1 first color to compare to
  83800. * @param color2 second color to compare to
  83801. * @param epsilon threshold value
  83802. */
  83803. private static FuzzyEquals;
  83804. /**
  83805. * Gets the materials from a Babylon scene and converts them to glTF materials
  83806. * @param scene babylonjs scene
  83807. * @param mimeType texture mime type
  83808. * @param images array of images
  83809. * @param textures array of textures
  83810. * @param materials array of materials
  83811. * @param imageData mapping of texture names to base64 textures
  83812. * @param hasTextureCoords specifies if texture coordinates are present on the material
  83813. */
  83814. _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  83815. /**
  83816. * Makes a copy of the glTF material without the texture parameters
  83817. * @param originalMaterial original glTF material
  83818. * @returns glTF material without texture parameters
  83819. */
  83820. _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  83821. /**
  83822. * Specifies if the material has any texture parameters present
  83823. * @param material glTF Material
  83824. * @returns boolean specifying if texture parameters are present
  83825. */
  83826. _hasTexturesPresent(material: IMaterial): boolean;
  83827. /**
  83828. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  83829. * @param babylonStandardMaterial
  83830. * @returns glTF Metallic Roughness Material representation
  83831. */
  83832. _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  83833. /**
  83834. * Computes the metallic factor
  83835. * @param diffuse diffused value
  83836. * @param specular specular value
  83837. * @param oneMinusSpecularStrength one minus the specular strength
  83838. * @returns metallic value
  83839. */
  83840. static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  83841. /**
  83842. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  83843. * @param glTFMaterial glTF material
  83844. * @param babylonMaterial Babylon material
  83845. */
  83846. private static _SetAlphaMode;
  83847. /**
  83848. * Converts a Babylon Standard Material to a glTF Material
  83849. * @param babylonStandardMaterial BJS Standard Material
  83850. * @param mimeType mime type to use for the textures
  83851. * @param images array of glTF image interfaces
  83852. * @param textures array of glTF texture interfaces
  83853. * @param materials array of glTF material interfaces
  83854. * @param imageData map of image file name to data
  83855. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  83856. */
  83857. _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  83858. private _finishMaterial;
  83859. /**
  83860. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  83861. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  83862. * @param mimeType mime type to use for the textures
  83863. * @param images array of glTF image interfaces
  83864. * @param textures array of glTF texture interfaces
  83865. * @param materials array of glTF material interfaces
  83866. * @param imageData map of image file name to data
  83867. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  83868. */
  83869. _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  83870. /**
  83871. * Converts an image typed array buffer to a base64 image
  83872. * @param buffer typed array buffer
  83873. * @param width width of the image
  83874. * @param height height of the image
  83875. * @param mimeType mimetype of the image
  83876. * @returns base64 image string
  83877. */
  83878. private _createBase64FromCanvasAsync;
  83879. /**
  83880. * Generates a white texture based on the specified width and height
  83881. * @param width width of the texture in pixels
  83882. * @param height height of the texture in pixels
  83883. * @param scene babylonjs scene
  83884. * @returns white texture
  83885. */
  83886. private _createWhiteTexture;
  83887. /**
  83888. * 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
  83889. * @param texture1 first texture to resize
  83890. * @param texture2 second texture to resize
  83891. * @param scene babylonjs scene
  83892. * @returns resized textures or null
  83893. */
  83894. private _resizeTexturesToSameDimensions;
  83895. /**
  83896. * Converts an array of pixels to a Float32Array
  83897. * Throws an error if the pixel format is not supported
  83898. * @param pixels - array buffer containing pixel values
  83899. * @returns Float32 of pixels
  83900. */
  83901. private _convertPixelArrayToFloat32;
  83902. /**
  83903. * Convert Specular Glossiness Textures to Metallic Roughness
  83904. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  83905. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  83906. * @param diffuseTexture texture used to store diffuse information
  83907. * @param specularGlossinessTexture texture used to store specular and glossiness information
  83908. * @param factors specular glossiness material factors
  83909. * @param mimeType the mime type to use for the texture
  83910. * @returns pbr metallic roughness interface or null
  83911. */
  83912. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  83913. /**
  83914. * Converts specular glossiness material properties to metallic roughness
  83915. * @param specularGlossiness interface with specular glossiness material properties
  83916. * @returns interface with metallic roughness material properties
  83917. */
  83918. private _convertSpecularGlossinessToMetallicRoughness;
  83919. /**
  83920. * Calculates the surface reflectance, independent of lighting conditions
  83921. * @param color Color source to calculate brightness from
  83922. * @returns number representing the perceived brightness, or zero if color is undefined
  83923. */
  83924. private _getPerceivedBrightness;
  83925. /**
  83926. * Returns the maximum color component value
  83927. * @param color
  83928. * @returns maximum color component value, or zero if color is null or undefined
  83929. */
  83930. private _getMaxComponent;
  83931. /**
  83932. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  83933. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  83934. * @param mimeType mime type to use for the textures
  83935. * @param images array of glTF image interfaces
  83936. * @param textures array of glTF texture interfaces
  83937. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  83938. * @param imageData map of image file name to data
  83939. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  83940. * @returns glTF PBR Metallic Roughness factors
  83941. */
  83942. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  83943. private _getGLTFTextureSampler;
  83944. private _getGLTFTextureWrapMode;
  83945. private _getGLTFTextureWrapModesSampler;
  83946. /**
  83947. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  83948. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  83949. * @param mimeType mime type to use for the textures
  83950. * @param images array of glTF image interfaces
  83951. * @param textures array of glTF texture interfaces
  83952. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  83953. * @param imageData map of image file name to data
  83954. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  83955. * @returns glTF PBR Metallic Roughness factors
  83956. */
  83957. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  83958. /**
  83959. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  83960. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  83961. * @param mimeType mime type to use for the textures
  83962. * @param images array of glTF image interfaces
  83963. * @param textures array of glTF texture interfaces
  83964. * @param materials array of glTF material interfaces
  83965. * @param imageData map of image file name to data
  83966. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  83967. */
  83968. _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<IMaterial>;
  83969. private setMetallicRoughnessPbrMaterial;
  83970. private getPixelsFromTexture;
  83971. /**
  83972. * Extracts a texture from a Babylon texture into file data and glTF data
  83973. * @param babylonTexture Babylon texture to extract
  83974. * @param mimeType Mime Type of the babylonTexture
  83975. * @return glTF texture info, or null if the texture format is not supported
  83976. */
  83977. _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  83978. _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  83979. /**
  83980. * Builds a texture from base64 string
  83981. * @param base64Texture base64 texture string
  83982. * @param baseTextureName Name to use for the texture
  83983. * @param mimeType image mime type for the texture
  83984. * @param images array of images
  83985. * @param textures array of textures
  83986. * @param imageData map of image data
  83987. * @returns glTF texture info, or null if the texture format is not supported
  83988. */
  83989. private _getTextureInfoFromBase64;
  83990. }
  83991. }
  83992. declare module BABYLON {
  83993. /**
  83994. * Class for holding and downloading glTF file data
  83995. */
  83996. export class GLTFData {
  83997. /**
  83998. * Object which contains the file name as the key and its data as the value
  83999. */
  84000. glTFFiles: {
  84001. [fileName: string]: string | Blob;
  84002. };
  84003. /**
  84004. * Initializes the glTF file object
  84005. */
  84006. constructor();
  84007. /**
  84008. * Downloads the glTF data as files based on their names and data
  84009. */
  84010. downloadFiles(): void;
  84011. }
  84012. }
  84013. declare module BABYLON {
  84014. /**
  84015. * Holds a collection of exporter options and parameters
  84016. */
  84017. export interface IExportOptions {
  84018. /**
  84019. * Function which indicates whether a babylon node should be exported or not
  84020. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  84021. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  84022. */
  84023. shouldExportNode?(node: Node): boolean;
  84024. /**
  84025. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  84026. * @param metadata source metadata to read from
  84027. * @returns the data to store to glTF node extras
  84028. */
  84029. metadataSelector?(metadata: any): any;
  84030. /**
  84031. * The sample rate to bake animation curves
  84032. */
  84033. animationSampleRate?: number;
  84034. /**
  84035. * Begin serialization without waiting for the scene to be ready
  84036. */
  84037. exportWithoutWaitingForScene?: boolean;
  84038. /**
  84039. * Indicates if coordinate system swapping root nodes should be included in export
  84040. */
  84041. includeCoordinateSystemConversionNodes?: boolean;
  84042. }
  84043. /**
  84044. * Class for generating glTF data from a Babylon scene.
  84045. */
  84046. export class GLTF2Export {
  84047. /**
  84048. * Exports the geometry of the scene to .gltf file format asynchronously
  84049. * @param scene Babylon scene with scene hierarchy information
  84050. * @param filePrefix File prefix to use when generating the glTF file
  84051. * @param options Exporter options
  84052. * @returns Returns an object with a .gltf file and associates texture names
  84053. * as keys and their data and paths as values
  84054. */
  84055. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  84056. private static _PreExportAsync;
  84057. private static _PostExportAsync;
  84058. /**
  84059. * Exports the geometry of the scene to .glb file format asychronously
  84060. * @param scene Babylon scene with scene hierarchy information
  84061. * @param filePrefix File prefix to use when generating glb file
  84062. * @param options Exporter options
  84063. * @returns Returns an object with a .glb filename as key and data as value
  84064. */
  84065. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  84066. }
  84067. }
  84068. declare module BABYLON.GLTF2.Exporter {
  84069. /**
  84070. * @hidden
  84071. */
  84072. export class _GLTFUtilities {
  84073. /**
  84074. * Creates a buffer view based on the supplied arguments
  84075. * @param bufferIndex index value of the specified buffer
  84076. * @param byteOffset byte offset value
  84077. * @param byteLength byte length of the bufferView
  84078. * @param byteStride byte distance between conequential elements
  84079. * @param name name of the buffer view
  84080. * @returns bufferView for glTF
  84081. */
  84082. static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  84083. /**
  84084. * Creates an accessor based on the supplied arguments
  84085. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  84086. * @param name The name of the accessor
  84087. * @param type The type of the accessor
  84088. * @param componentType The datatype of components in the attribute
  84089. * @param count The number of attributes referenced by this accessor
  84090. * @param byteOffset The offset relative to the start of the bufferView in bytes
  84091. * @param min Minimum value of each component in this attribute
  84092. * @param max Maximum value of each component in this attribute
  84093. * @returns accessor for glTF
  84094. */
  84095. static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  84096. /**
  84097. * Calculates the minimum and maximum values of an array of position floats
  84098. * @param positions Positions array of a mesh
  84099. * @param vertexStart Starting vertex offset to calculate min and max values
  84100. * @param vertexCount Number of vertices to check for min and max values
  84101. * @returns min number array and max number array
  84102. */
  84103. static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  84104. min: number[];
  84105. max: number[];
  84106. };
  84107. /**
  84108. * Converts a new right-handed Vector3
  84109. * @param vector vector3 array
  84110. * @returns right-handed Vector3
  84111. */
  84112. static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  84113. /**
  84114. * Converts a Vector3 to right-handed
  84115. * @param vector Vector3 to convert to right-handed
  84116. */
  84117. static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  84118. /**
  84119. * Converts a three element number array to right-handed
  84120. * @param vector number array to convert to right-handed
  84121. */
  84122. static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  84123. /**
  84124. * Converts a new right-handed Vector3
  84125. * @param vector vector3 array
  84126. * @returns right-handed Vector3
  84127. */
  84128. static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  84129. /**
  84130. * Converts a Vector3 to right-handed
  84131. * @param vector Vector3 to convert to right-handed
  84132. */
  84133. static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  84134. /**
  84135. * Converts a three element number array to right-handed
  84136. * @param vector number array to convert to right-handed
  84137. */
  84138. static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  84139. /**
  84140. * Converts a Vector4 to right-handed
  84141. * @param vector Vector4 to convert to right-handed
  84142. */
  84143. static _GetRightHandedVector4FromRef(vector: Vector4): void;
  84144. /**
  84145. * Converts a Vector4 to right-handed
  84146. * @param vector Vector4 to convert to right-handed
  84147. */
  84148. static _GetRightHandedArray4FromRef(vector: number[]): void;
  84149. /**
  84150. * Converts a Quaternion to right-handed
  84151. * @param quaternion Source quaternion to convert to right-handed
  84152. */
  84153. static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  84154. /**
  84155. * Converts a Quaternion to right-handed
  84156. * @param quaternion Source quaternion to convert to right-handed
  84157. */
  84158. static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void;
  84159. static _NormalizeTangentFromRef(tangent: Vector4): void;
  84160. static _GetRightHandedMatrixFromRef(matrix: Matrix): void;
  84161. static _GetDataAccessorElementCount(accessorType: AccessorType): 1 | 3 | 2 | 4 | 9 | 16;
  84162. }
  84163. }
  84164. declare module BABYLON.GLTF2.Exporter {
  84165. /**
  84166. * Converts Babylon Scene into glTF 2.0.
  84167. * @hidden
  84168. */
  84169. export class _Exporter {
  84170. /**
  84171. * Stores the glTF to export
  84172. */
  84173. _glTF: IGLTF;
  84174. /**
  84175. * Stores all generated buffer views, which represents views into the main glTF buffer data
  84176. */
  84177. _bufferViews: IBufferView[];
  84178. /**
  84179. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  84180. */
  84181. _accessors: IAccessor[];
  84182. /**
  84183. * Stores all the generated nodes, which contains transform and/or mesh information per node
  84184. */
  84185. _nodes: INode[];
  84186. /**
  84187. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  84188. */
  84189. private _scenes;
  84190. /**
  84191. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  84192. */
  84193. private _meshes;
  84194. /**
  84195. * Stores all the generated material information, which represents the appearance of each primitive
  84196. */
  84197. _materials: IMaterial[];
  84198. _materialMap: {
  84199. [materialID: number]: number;
  84200. };
  84201. /**
  84202. * Stores all the generated texture information, which is referenced by glTF materials
  84203. */
  84204. _textures: ITexture[];
  84205. /**
  84206. * Stores all the generated image information, which is referenced by glTF textures
  84207. */
  84208. _images: IImage[];
  84209. /**
  84210. * Stores all the texture samplers
  84211. */
  84212. _samplers: ISampler[];
  84213. /**
  84214. * Stores all the generated glTF skins
  84215. */
  84216. _skins: ISkin[];
  84217. /**
  84218. * Stores all the generated animation samplers, which is referenced by glTF animations
  84219. */
  84220. /**
  84221. * Stores the animations for glTF models
  84222. */
  84223. private _animations;
  84224. /**
  84225. * Stores the total amount of bytes stored in the glTF buffer
  84226. */
  84227. private _totalByteLength;
  84228. /**
  84229. * Stores a reference to the Babylon scene containing the source geometry and material information
  84230. */
  84231. _babylonScene: Scene;
  84232. /**
  84233. * Stores a map of the image data, where the key is the file name and the value
  84234. * is the image data
  84235. */
  84236. _imageData: {
  84237. [fileName: string]: {
  84238. data: Uint8Array;
  84239. mimeType: ImageMimeType;
  84240. };
  84241. };
  84242. protected _orderedImageData: Array<{
  84243. data: Uint8Array;
  84244. mimeType: ImageMimeType;
  84245. }>;
  84246. /**
  84247. * Stores a map of the unique id of a node to its index in the node array
  84248. */
  84249. _nodeMap: {
  84250. [key: number]: number;
  84251. };
  84252. /**
  84253. * Specifies if the source Babylon scene was left handed, and needed conversion.
  84254. */
  84255. _convertToRightHandedSystem: boolean;
  84256. /**
  84257. * Specifies if a Babylon node should be converted to right-handed on export
  84258. */
  84259. _convertToRightHandedSystemMap: {
  84260. [nodeId: number]: boolean;
  84261. };
  84262. _includeCoordinateSystemConversionNodes: boolean;
  84263. /**
  84264. * Baked animation sample rate
  84265. */
  84266. private _animationSampleRate;
  84267. private _options;
  84268. private _localEngine;
  84269. _glTFMaterialExporter: _GLTFMaterialExporter;
  84270. private _extensions;
  84271. private static _ExtensionNames;
  84272. private static _ExtensionFactories;
  84273. private _applyExtension;
  84274. private _applyExtensions;
  84275. _extensionsPreExportTextureAsync(context: string, babylonTexture: Nullable<Texture>, mimeType: ImageMimeType): Promise<Nullable<BaseTexture>>;
  84276. _extensionsPostExportMeshPrimitiveAsync(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Promise<Nullable<IMeshPrimitive>>;
  84277. _extensionsPostExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  84278. [key: number]: number;
  84279. }): Promise<Nullable<INode>>;
  84280. _extensionsPostExportMaterialAsync(context: string, material: Nullable<IMaterial>, babylonMaterial: Material): Promise<Nullable<IMaterial>>;
  84281. _extensionsPostExportMaterialAdditionalTextures(context: string, material: IMaterial, babylonMaterial: Material): BaseTexture[];
  84282. _extensionsPostExportTextures(context: string, textureInfo: ITextureInfo, babylonTexture: BaseTexture): void;
  84283. private _forEachExtensions;
  84284. private _extensionsOnExporting;
  84285. /**
  84286. * Load glTF serializer extensions
  84287. */
  84288. private _loadExtensions;
  84289. /**
  84290. * Creates a glTF Exporter instance, which can accept optional exporter options
  84291. * @param babylonScene Babylon scene object
  84292. * @param options Options to modify the behavior of the exporter
  84293. */
  84294. constructor(babylonScene: Scene, options?: IExportOptions);
  84295. dispose(): void;
  84296. /**
  84297. * Registers a glTF exporter extension
  84298. * @param name Name of the extension to export
  84299. * @param factory The factory function that creates the exporter extension
  84300. */
  84301. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  84302. /**
  84303. * Un-registers an exporter extension
  84304. * @param name The name fo the exporter extension
  84305. * @returns A boolean indicating whether the extension has been un-registered
  84306. */
  84307. static UnregisterExtension(name: string): boolean;
  84308. /**
  84309. * Lazy load a local engine
  84310. */
  84311. _getLocalEngine(): Engine;
  84312. private reorderIndicesBasedOnPrimitiveMode;
  84313. /**
  84314. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  84315. * clock-wise during export to glTF
  84316. * @param submesh BabylonJS submesh
  84317. * @param primitiveMode Primitive mode of the mesh
  84318. * @param sideOrientation the winding order of the submesh
  84319. * @param vertexBufferKind The type of vertex attribute
  84320. * @param meshAttributeArray The vertex attribute data
  84321. * @param byteOffset The offset to the binary data
  84322. * @param binaryWriter The binary data for the glTF file
  84323. * @param convertToRightHandedSystem Converts the values to right-handed
  84324. */
  84325. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  84326. /**
  84327. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  84328. * clock-wise during export to glTF
  84329. * @param submesh BabylonJS submesh
  84330. * @param primitiveMode Primitive mode of the mesh
  84331. * @param sideOrientation the winding order of the submesh
  84332. * @param vertexBufferKind The type of vertex attribute
  84333. * @param meshAttributeArray The vertex attribute data
  84334. * @param byteOffset The offset to the binary data
  84335. * @param binaryWriter The binary data for the glTF file
  84336. * @param convertToRightHandedSystem Converts the values to right-handed
  84337. */
  84338. private reorderTriangleFillMode;
  84339. /**
  84340. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  84341. * clock-wise during export to glTF
  84342. * @param submesh BabylonJS submesh
  84343. * @param primitiveMode Primitive mode of the mesh
  84344. * @param sideOrientation the winding order of the submesh
  84345. * @param vertexBufferKind The type of vertex attribute
  84346. * @param meshAttributeArray The vertex attribute data
  84347. * @param byteOffset The offset to the binary data
  84348. * @param binaryWriter The binary data for the glTF file
  84349. * @param convertToRightHandedSystem Converts the values to right-handed
  84350. */
  84351. private reorderTriangleStripDrawMode;
  84352. /**
  84353. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  84354. * clock-wise during export to glTF
  84355. * @param submesh BabylonJS submesh
  84356. * @param primitiveMode Primitive mode of the mesh
  84357. * @param sideOrientation the winding order of the submesh
  84358. * @param vertexBufferKind The type of vertex attribute
  84359. * @param meshAttributeArray The vertex attribute data
  84360. * @param byteOffset The offset to the binary data
  84361. * @param binaryWriter The binary data for the glTF file
  84362. * @param convertToRightHandedSystem Converts the values to right-handed
  84363. */
  84364. private reorderTriangleFanMode;
  84365. /**
  84366. * Writes the vertex attribute data to binary
  84367. * @param vertices The vertices to write to the binary writer
  84368. * @param byteOffset The offset into the binary writer to overwrite binary data
  84369. * @param vertexAttributeKind The vertex attribute type
  84370. * @param meshAttributeArray The vertex attribute data
  84371. * @param binaryWriter The writer containing the binary data
  84372. * @param convertToRightHandedSystem Converts the values to right-handed
  84373. */
  84374. private writeVertexAttributeData;
  84375. /**
  84376. * Writes mesh attribute data to a data buffer
  84377. * Returns the bytelength of the data
  84378. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  84379. * @param meshAttributeArray Array containing the attribute data
  84380. * @param byteStride Specifies the space between data
  84381. * @param binaryWriter The buffer to write the binary data to
  84382. * @param convertToRightHandedSystem Converts the values to right-handed
  84383. */
  84384. writeAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, babylonTransformNode: TransformNode): void;
  84385. /**
  84386. * Writes mesh attribute data to a data buffer
  84387. * Returns the bytelength of the data
  84388. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  84389. * @param meshAttributeArray Array containing the attribute data
  84390. * @param byteStride Specifies the space between data
  84391. * @param binaryWriter The buffer to write the binary data to
  84392. * @param convertToRightHandedSystem Converts the values to right-handed
  84393. */
  84394. writeMorphTargetAttributeData(vertexBufferKind: string, attributeComponentKind: AccessorComponentType, meshPrimitive: SubMesh, morphTarget: MorphTarget, meshAttributeArray: FloatArray, morphTargetAttributeArray: FloatArray, stride: number, binaryWriter: _BinaryWriter, convertToRightHandedSystem: boolean, minMax?: any): void;
  84395. /**
  84396. * Generates glTF json data
  84397. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  84398. * @param glTFPrefix Text to use when prefixing a glTF file
  84399. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  84400. * @returns json data as string
  84401. */
  84402. private generateJSON;
  84403. /**
  84404. * Generates data for .gltf and .bin files based on the glTF prefix string
  84405. * @param glTFPrefix Text to use when prefixing a glTF file
  84406. * @param dispose Dispose the exporter
  84407. * @returns GLTFData with glTF file data
  84408. */
  84409. _generateGLTFAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  84410. /**
  84411. * Creates a binary buffer for glTF
  84412. * @returns array buffer for binary data
  84413. */
  84414. private _generateBinaryAsync;
  84415. /**
  84416. * Pads the number to a multiple of 4
  84417. * @param num number to pad
  84418. * @returns padded number
  84419. */
  84420. private _getPadding;
  84421. /**
  84422. * @hidden
  84423. */
  84424. _generateGLBAsync(glTFPrefix: string, dispose?: boolean): Promise<GLTFData>;
  84425. /**
  84426. * Sets the TRS for each node
  84427. * @param node glTF Node for storing the transformation data
  84428. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  84429. * @param convertToRightHandedSystem Converts the values to right-handed
  84430. */
  84431. private setNodeTransformation;
  84432. private getVertexBufferFromMesh;
  84433. /**
  84434. * Creates a bufferview based on the vertices type for the Babylon mesh
  84435. * @param kind Indicates the type of vertices data
  84436. * @param componentType Indicates the numerical type used to store the data
  84437. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  84438. * @param binaryWriter The buffer to write the bufferview data to
  84439. * @param convertToRightHandedSystem Converts the values to right-handed
  84440. */
  84441. private createBufferViewKind;
  84442. /**
  84443. * Creates a bufferview based on the vertices type for the Babylon mesh
  84444. * @param babylonSubMesh The Babylon submesh that the morph target is applied to
  84445. * @param babylonMorphTarget the morph target to be exported
  84446. * @param binaryWriter The buffer to write the bufferview data to
  84447. * @param convertToRightHandedSystem Converts the values to right-handed
  84448. */
  84449. private setMorphTargetAttributes;
  84450. /**
  84451. * The primitive mode of the Babylon mesh
  84452. * @param babylonMesh The BabylonJS mesh
  84453. */
  84454. private getMeshPrimitiveMode;
  84455. /**
  84456. * Sets the primitive mode of the glTF mesh primitive
  84457. * @param meshPrimitive glTF mesh primitive
  84458. * @param primitiveMode The primitive mode
  84459. */
  84460. private setPrimitiveMode;
  84461. /**
  84462. * Sets the vertex attribute accessor based of the glTF mesh primitive
  84463. * @param meshPrimitive glTF mesh primitive
  84464. * @param attributeKind vertex attribute
  84465. * @returns boolean specifying if uv coordinates are present
  84466. */
  84467. private setAttributeKind;
  84468. /**
  84469. * Sets data for the primitive attributes of each submesh
  84470. * @param mesh glTF Mesh object to store the primitive attribute information
  84471. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  84472. * @param binaryWriter Buffer to write the attribute data to
  84473. * @param convertToRightHandedSystem Converts the values to right-handed
  84474. */
  84475. private setPrimitiveAttributesAsync;
  84476. /**
  84477. * Check if the node is used to convert its descendants from a right handed coordinate system to the Babylon scene's coordinate system.
  84478. * @param node The node to check
  84479. * @returns True if the node is used to convert its descendants from right-handed to left-handed. False otherwise
  84480. */
  84481. private isBabylonCoordinateSystemConvertingNode;
  84482. /**
  84483. * Creates a glTF scene based on the array of meshes
  84484. * Returns the the total byte offset
  84485. * @param babylonScene Babylon scene to get the mesh data from
  84486. * @param binaryWriter Buffer to write binary data to
  84487. */
  84488. private createSceneAsync;
  84489. /**
  84490. * Creates a mapping of Node unique id to node index and handles animations
  84491. * @param babylonScene Babylon Scene
  84492. * @param nodes Babylon transform nodes
  84493. * @param binaryWriter Buffer to write binary data to
  84494. * @returns Node mapping of unique id to index
  84495. */
  84496. private createNodeMapAndAnimationsAsync;
  84497. /**
  84498. * Creates a glTF node from a Babylon mesh
  84499. * @param babylonMesh Source Babylon mesh
  84500. * @param binaryWriter Buffer for storing geometry data
  84501. * @param convertToRightHandedSystem Converts the values to right-handed
  84502. * @param nodeMap Node mapping of unique id to glTF node index
  84503. * @returns glTF node
  84504. */
  84505. private createNodeAsync;
  84506. /**
  84507. * Creates a glTF skin from a Babylon skeleton
  84508. * @param babylonScene Babylon Scene
  84509. * @param nodes Babylon transform nodes
  84510. * @param binaryWriter Buffer to write binary data to
  84511. * @returns Node mapping of unique id to index
  84512. */
  84513. private createSkinsAsync;
  84514. }
  84515. /**
  84516. * @hidden
  84517. *
  84518. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  84519. */
  84520. export class _BinaryWriter {
  84521. /**
  84522. * Array buffer which stores all binary data
  84523. */
  84524. private _arrayBuffer;
  84525. /**
  84526. * View of the array buffer
  84527. */
  84528. private _dataView;
  84529. /**
  84530. * byte offset of data in array buffer
  84531. */
  84532. private _byteOffset;
  84533. /**
  84534. * Initialize binary writer with an initial byte length
  84535. * @param byteLength Initial byte length of the array buffer
  84536. */
  84537. constructor(byteLength: number);
  84538. /**
  84539. * Resize the array buffer to the specified byte length
  84540. * @param byteLength
  84541. */
  84542. private resizeBuffer;
  84543. /**
  84544. * Get an array buffer with the length of the byte offset
  84545. * @returns ArrayBuffer resized to the byte offset
  84546. */
  84547. getArrayBuffer(): ArrayBuffer;
  84548. /**
  84549. * Get the byte offset of the array buffer
  84550. * @returns byte offset
  84551. */
  84552. getByteOffset(): number;
  84553. /**
  84554. * Stores an UInt8 in the array buffer
  84555. * @param entry
  84556. * @param byteOffset If defined, specifies where to set the value as an offset.
  84557. */
  84558. setUInt8(entry: number, byteOffset?: number): void;
  84559. /**
  84560. * Stores an UInt16 in the array buffer
  84561. * @param entry
  84562. * @param byteOffset If defined, specifies where to set the value as an offset.
  84563. */
  84564. setUInt16(entry: number, byteOffset?: number): void;
  84565. /**
  84566. * Gets an UInt32 in the array buffer
  84567. * @param entry
  84568. * @param byteOffset If defined, specifies where to set the value as an offset.
  84569. */
  84570. getUInt32(byteOffset: number): number;
  84571. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  84572. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  84573. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  84574. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  84575. /**
  84576. * Stores a Float32 in the array buffer
  84577. * @param entry
  84578. */
  84579. setFloat32(entry: number, byteOffset?: number): void;
  84580. /**
  84581. * Stores an UInt32 in the array buffer
  84582. * @param entry
  84583. * @param byteOffset If defined, specifies where to set the value as an offset.
  84584. */
  84585. setUInt32(entry: number, byteOffset?: number): void;
  84586. }
  84587. }
  84588. declare module BABYLON.GLTF2.Exporter {
  84589. /**
  84590. * @hidden
  84591. * Interface to store animation data.
  84592. */
  84593. export interface _IAnimationData {
  84594. /**
  84595. * Keyframe data.
  84596. */
  84597. inputs: number[];
  84598. /**
  84599. * Value data.
  84600. */
  84601. outputs: number[][];
  84602. /**
  84603. * Animation interpolation data.
  84604. */
  84605. samplerInterpolation: AnimationSamplerInterpolation;
  84606. /**
  84607. * Minimum keyframe value.
  84608. */
  84609. inputsMin: number;
  84610. /**
  84611. * Maximum keyframe value.
  84612. */
  84613. inputsMax: number;
  84614. }
  84615. /**
  84616. * @hidden
  84617. */
  84618. export interface _IAnimationInfo {
  84619. /**
  84620. * The target channel for the animation
  84621. */
  84622. animationChannelTargetPath: AnimationChannelTargetPath;
  84623. /**
  84624. * The glTF accessor type for the data.
  84625. */
  84626. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4 | AccessorType.SCALAR;
  84627. /**
  84628. * Specifies if quaternions should be used.
  84629. */
  84630. useQuaternion: boolean;
  84631. }
  84632. /**
  84633. * @hidden
  84634. * Utility class for generating glTF animation data from BabylonJS.
  84635. */
  84636. export class _GLTFAnimation {
  84637. /**
  84638. * @ignore
  84639. *
  84640. * Creates glTF channel animation from BabylonJS animation.
  84641. * @param babylonTransformNode - BabylonJS mesh.
  84642. * @param animation - animation.
  84643. * @param animationChannelTargetPath - The target animation channel.
  84644. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  84645. * @param useQuaternion - Specifies if quaternions are used.
  84646. * @returns nullable IAnimationData
  84647. */
  84648. static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  84649. private static _DeduceAnimationInfo;
  84650. /**
  84651. * @ignore
  84652. * Create node animations from the transform node animations
  84653. * @param babylonNode
  84654. * @param runtimeGLTFAnimation
  84655. * @param idleGLTFAnimations
  84656. * @param nodeMap
  84657. * @param nodes
  84658. * @param binaryWriter
  84659. * @param bufferViews
  84660. * @param accessors
  84661. * @param convertToRightHandedSystem
  84662. * @param animationSampleRate
  84663. */
  84664. static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  84665. [key: number]: number;
  84666. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  84667. /**
  84668. * @ignore
  84669. * Create individual morph animations from the mesh's morph target animation tracks
  84670. * @param babylonNode
  84671. * @param runtimeGLTFAnimation
  84672. * @param idleGLTFAnimations
  84673. * @param nodeMap
  84674. * @param nodes
  84675. * @param binaryWriter
  84676. * @param bufferViews
  84677. * @param accessors
  84678. * @param convertToRightHandedSystem
  84679. * @param animationSampleRate
  84680. */
  84681. static _CreateMorphTargetAnimationFromMorphTargetAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  84682. [key: number]: number;
  84683. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  84684. /**
  84685. * @ignore
  84686. * Create node and morph animations from the animation groups
  84687. * @param babylonScene
  84688. * @param glTFAnimations
  84689. * @param nodeMap
  84690. * @param nodes
  84691. * @param binaryWriter
  84692. * @param bufferViews
  84693. * @param accessors
  84694. * @param convertToRightHandedSystemMap
  84695. * @param animationSampleRate
  84696. */
  84697. static _CreateNodeAndMorphAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  84698. [key: number]: number;
  84699. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystemMap: {
  84700. [nodeId: number]: boolean;
  84701. }, animationSampleRate: number): void;
  84702. private static AddAnimation;
  84703. /**
  84704. * Create a baked animation
  84705. * @param babylonTransformNode BabylonJS mesh
  84706. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  84707. * @param animationChannelTargetPath animation target channel
  84708. * @param minFrame minimum animation frame
  84709. * @param maxFrame maximum animation frame
  84710. * @param fps frames per second of the animation
  84711. * @param inputs input key frames of the animation
  84712. * @param outputs output key frame data of the animation
  84713. * @param convertToRightHandedSystem converts the values to right-handed
  84714. * @param useQuaternion specifies if quaternions should be used
  84715. */
  84716. private static _CreateBakedAnimation;
  84717. private static _ConvertFactorToVector3OrQuaternion;
  84718. private static _SetInterpolatedValue;
  84719. /**
  84720. * Creates linear animation from the animation key frames
  84721. * @param babylonTransformNode BabylonJS mesh
  84722. * @param animation BabylonJS animation
  84723. * @param animationChannelTargetPath The target animation channel
  84724. * @param frameDelta The difference between the last and first frame of the animation
  84725. * @param inputs Array to store the key frame times
  84726. * @param outputs Array to store the key frame data
  84727. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  84728. * @param useQuaternion Specifies if quaternions are used in the animation
  84729. */
  84730. private static _CreateLinearOrStepAnimation;
  84731. /**
  84732. * Creates cubic spline animation from the animation key frames
  84733. * @param babylonTransformNode BabylonJS mesh
  84734. * @param animation BabylonJS animation
  84735. * @param animationChannelTargetPath The target animation channel
  84736. * @param frameDelta The difference between the last and first frame of the animation
  84737. * @param inputs Array to store the key frame times
  84738. * @param outputs Array to store the key frame data
  84739. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  84740. * @param useQuaternion Specifies if quaternions are used in the animation
  84741. */
  84742. private static _CreateCubicSplineAnimation;
  84743. private static _GetBasePositionRotationOrScale;
  84744. /**
  84745. * Adds a key frame value
  84746. * @param keyFrame
  84747. * @param animation
  84748. * @param outputs
  84749. * @param animationChannelTargetPath
  84750. * @param basePositionRotationOrScale
  84751. * @param convertToRightHandedSystem
  84752. * @param useQuaternion
  84753. */
  84754. private static _AddKeyframeValue;
  84755. /**
  84756. * Determine the interpolation based on the key frames
  84757. * @param keyFrames
  84758. * @param animationChannelTargetPath
  84759. * @param useQuaternion
  84760. */
  84761. private static _DeduceInterpolation;
  84762. /**
  84763. * Adds an input tangent or output tangent to the output data
  84764. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  84765. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  84766. * @param outputs The animation data by keyframe
  84767. * @param animationChannelTargetPath The target animation channel
  84768. * @param interpolation The interpolation type
  84769. * @param keyFrame The key frame with the animation data
  84770. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  84771. * @param useQuaternion Specifies if quaternions are used
  84772. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  84773. */
  84774. private static AddSplineTangent;
  84775. /**
  84776. * Get the minimum and maximum key frames' frame values
  84777. * @param keyFrames animation key frames
  84778. * @returns the minimum and maximum key frame value
  84779. */
  84780. private static calculateMinMaxKeyFrames;
  84781. }
  84782. }
  84783. declare module BABYLON.GLTF2.Exporter {
  84784. /** @hidden */
  84785. export var textureTransformPixelShader: {
  84786. name: string;
  84787. shader: string;
  84788. };
  84789. }
  84790. declare module BABYLON.GLTF2.Exporter.Extensions {
  84791. /**
  84792. * @hidden
  84793. */
  84794. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  84795. private _recordedTextures;
  84796. /** Name of this extension */
  84797. readonly name: string;
  84798. /** Defines whether this extension is enabled */
  84799. enabled: boolean;
  84800. /** Defines whether this extension is required */
  84801. required: boolean;
  84802. /** Reference to the glTF exporter */
  84803. private _wasUsed;
  84804. constructor(exporter: _Exporter);
  84805. dispose(): void;
  84806. /** @hidden */
  84807. get wasUsed(): boolean;
  84808. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  84809. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Promise<Texture>;
  84810. /**
  84811. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  84812. * @param babylonTexture
  84813. * @param offset
  84814. * @param rotation
  84815. * @param scale
  84816. * @param scene
  84817. */
  84818. private _textureTransformTextureAsync;
  84819. }
  84820. }
  84821. declare module BABYLON.GLTF2.Exporter.Extensions {
  84822. /**
  84823. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  84824. */
  84825. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  84826. /** The name of this extension. */
  84827. readonly name: string;
  84828. /** Defines whether this extension is enabled. */
  84829. enabled: boolean;
  84830. /** Defines whether this extension is required */
  84831. required: boolean;
  84832. /** Reference to the glTF exporter */
  84833. private _exporter;
  84834. private _lights;
  84835. /** @hidden */
  84836. constructor(exporter: _Exporter);
  84837. /** @hidden */
  84838. dispose(): void;
  84839. /** @hidden */
  84840. get wasUsed(): boolean;
  84841. /** @hidden */
  84842. onExporting(): void;
  84843. /**
  84844. * Define this method to modify the default behavior when exporting a node
  84845. * @param context The context when exporting the node
  84846. * @param node glTF node
  84847. * @param babylonNode BabylonJS node
  84848. * @param nodeMap Node mapping of unique id to glTF node index
  84849. * @returns nullable INode promise
  84850. */
  84851. postExportNodeAsync(context: string, node: Nullable<INode>, babylonNode: Node, nodeMap?: {
  84852. [key: number]: number;
  84853. }): Promise<Nullable<INode>>;
  84854. }
  84855. }
  84856. declare module BABYLON.GLTF2.Exporter.Extensions {
  84857. /**
  84858. * @hidden
  84859. */
  84860. export class KHR_materials_sheen implements IGLTFExporterExtensionV2 {
  84861. /** Name of this extension */
  84862. readonly name: string;
  84863. /** Defines whether this extension is enabled */
  84864. enabled: boolean;
  84865. /** Defines whether this extension is required */
  84866. required: boolean;
  84867. /** Reference to the glTF exporter */
  84868. private _textureInfos;
  84869. private _exportedTextures;
  84870. private _wasUsed;
  84871. constructor(exporter: _Exporter);
  84872. dispose(): void;
  84873. /** @hidden */
  84874. get wasUsed(): boolean;
  84875. private _getTextureIndex;
  84876. postExportTexture?(context: string, textureInfo: ITextureInfo, babylonTexture: Texture): void;
  84877. postExportMaterialAdditionalTextures?(context: string, node: IMaterial, babylonMaterial: Material): BaseTexture[];
  84878. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  84879. }
  84880. }
  84881. declare module BABYLON.GLTF2.Exporter.Extensions {
  84882. /**
  84883. * @hidden
  84884. */
  84885. export class KHR_materials_unlit implements IGLTFExporterExtensionV2 {
  84886. /** Name of this extension */
  84887. readonly name: string;
  84888. /** Defines whether this extension is enabled */
  84889. enabled: boolean;
  84890. /** Defines whether this extension is required */
  84891. required: boolean;
  84892. private _wasUsed;
  84893. constructor(exporter: _Exporter);
  84894. /** @hidden */
  84895. get wasUsed(): boolean;
  84896. dispose(): void;
  84897. postExportMaterialAsync?(context: string, node: IMaterial, babylonMaterial: Material): Promise<IMaterial>;
  84898. }
  84899. }
  84900. declare module BABYLON {
  84901. /**
  84902. * Class for generating STL data from a Babylon scene.
  84903. */
  84904. export class STLExport {
  84905. /**
  84906. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  84907. * @param meshes list defines the mesh to serialize
  84908. * @param download triggers the automatic download of the file.
  84909. * @param fileName changes the downloads fileName.
  84910. * @param binary changes the STL to a binary type.
  84911. * @param isLittleEndian toggle for binary type exporter.
  84912. * @returns the STL as UTF8 string
  84913. */
  84914. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  84915. }
  84916. }
  84917. declare module "babylonjs-gltf2interface" {
  84918. export = BABYLON.GLTF2;
  84919. }
  84920. /**
  84921. * Module for glTF 2.0 Interface
  84922. */
  84923. declare module BABYLON.GLTF2 {
  84924. /**
  84925. * The datatype of the components in the attribute
  84926. */
  84927. const enum AccessorComponentType {
  84928. /**
  84929. * Byte
  84930. */
  84931. BYTE = 5120,
  84932. /**
  84933. * Unsigned Byte
  84934. */
  84935. UNSIGNED_BYTE = 5121,
  84936. /**
  84937. * Short
  84938. */
  84939. SHORT = 5122,
  84940. /**
  84941. * Unsigned Short
  84942. */
  84943. UNSIGNED_SHORT = 5123,
  84944. /**
  84945. * Unsigned Int
  84946. */
  84947. UNSIGNED_INT = 5125,
  84948. /**
  84949. * Float
  84950. */
  84951. FLOAT = 5126,
  84952. }
  84953. /**
  84954. * Specifies if the attirbute is a scalar, vector, or matrix
  84955. */
  84956. const enum AccessorType {
  84957. /**
  84958. * Scalar
  84959. */
  84960. SCALAR = "SCALAR",
  84961. /**
  84962. * Vector2
  84963. */
  84964. VEC2 = "VEC2",
  84965. /**
  84966. * Vector3
  84967. */
  84968. VEC3 = "VEC3",
  84969. /**
  84970. * Vector4
  84971. */
  84972. VEC4 = "VEC4",
  84973. /**
  84974. * Matrix2x2
  84975. */
  84976. MAT2 = "MAT2",
  84977. /**
  84978. * Matrix3x3
  84979. */
  84980. MAT3 = "MAT3",
  84981. /**
  84982. * Matrix4x4
  84983. */
  84984. MAT4 = "MAT4",
  84985. }
  84986. /**
  84987. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  84988. */
  84989. const enum AnimationChannelTargetPath {
  84990. /**
  84991. * Translation
  84992. */
  84993. TRANSLATION = "translation",
  84994. /**
  84995. * Rotation
  84996. */
  84997. ROTATION = "rotation",
  84998. /**
  84999. * Scale
  85000. */
  85001. SCALE = "scale",
  85002. /**
  85003. * Weights
  85004. */
  85005. WEIGHTS = "weights",
  85006. }
  85007. /**
  85008. * Interpolation algorithm
  85009. */
  85010. const enum AnimationSamplerInterpolation {
  85011. /**
  85012. * The animated values are linearly interpolated between keyframes
  85013. */
  85014. LINEAR = "LINEAR",
  85015. /**
  85016. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  85017. */
  85018. STEP = "STEP",
  85019. /**
  85020. * The animation's interpolation is computed using a cubic spline with specified tangents
  85021. */
  85022. CUBICSPLINE = "CUBICSPLINE",
  85023. }
  85024. /**
  85025. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  85026. */
  85027. const enum CameraType {
  85028. /**
  85029. * A perspective camera containing properties to create a perspective projection matrix
  85030. */
  85031. PERSPECTIVE = "perspective",
  85032. /**
  85033. * An orthographic camera containing properties to create an orthographic projection matrix
  85034. */
  85035. ORTHOGRAPHIC = "orthographic",
  85036. }
  85037. /**
  85038. * The mime-type of the image
  85039. */
  85040. const enum ImageMimeType {
  85041. /**
  85042. * JPEG Mime-type
  85043. */
  85044. JPEG = "image/jpeg",
  85045. /**
  85046. * PNG Mime-type
  85047. */
  85048. PNG = "image/png",
  85049. }
  85050. /**
  85051. * The alpha rendering mode of the material
  85052. */
  85053. const enum MaterialAlphaMode {
  85054. /**
  85055. * The alpha value is ignored and the rendered output is fully opaque
  85056. */
  85057. OPAQUE = "OPAQUE",
  85058. /**
  85059. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  85060. */
  85061. MASK = "MASK",
  85062. /**
  85063. * 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)
  85064. */
  85065. BLEND = "BLEND",
  85066. }
  85067. /**
  85068. * The type of the primitives to render
  85069. */
  85070. const enum MeshPrimitiveMode {
  85071. /**
  85072. * Points
  85073. */
  85074. POINTS = 0,
  85075. /**
  85076. * Lines
  85077. */
  85078. LINES = 1,
  85079. /**
  85080. * Line Loop
  85081. */
  85082. LINE_LOOP = 2,
  85083. /**
  85084. * Line Strip
  85085. */
  85086. LINE_STRIP = 3,
  85087. /**
  85088. * Triangles
  85089. */
  85090. TRIANGLES = 4,
  85091. /**
  85092. * Triangle Strip
  85093. */
  85094. TRIANGLE_STRIP = 5,
  85095. /**
  85096. * Triangle Fan
  85097. */
  85098. TRIANGLE_FAN = 6,
  85099. }
  85100. /**
  85101. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  85102. */
  85103. const enum TextureMagFilter {
  85104. /**
  85105. * Nearest
  85106. */
  85107. NEAREST = 9728,
  85108. /**
  85109. * Linear
  85110. */
  85111. LINEAR = 9729,
  85112. }
  85113. /**
  85114. * Minification filter. All valid values correspond to WebGL enums
  85115. */
  85116. const enum TextureMinFilter {
  85117. /**
  85118. * Nearest
  85119. */
  85120. NEAREST = 9728,
  85121. /**
  85122. * Linear
  85123. */
  85124. LINEAR = 9729,
  85125. /**
  85126. * Nearest Mip-Map Nearest
  85127. */
  85128. NEAREST_MIPMAP_NEAREST = 9984,
  85129. /**
  85130. * Linear Mipmap Nearest
  85131. */
  85132. LINEAR_MIPMAP_NEAREST = 9985,
  85133. /**
  85134. * Nearest Mipmap Linear
  85135. */
  85136. NEAREST_MIPMAP_LINEAR = 9986,
  85137. /**
  85138. * Linear Mipmap Linear
  85139. */
  85140. LINEAR_MIPMAP_LINEAR = 9987,
  85141. }
  85142. /**
  85143. * S (U) wrapping mode. All valid values correspond to WebGL enums
  85144. */
  85145. const enum TextureWrapMode {
  85146. /**
  85147. * Clamp to Edge
  85148. */
  85149. CLAMP_TO_EDGE = 33071,
  85150. /**
  85151. * Mirrored Repeat
  85152. */
  85153. MIRRORED_REPEAT = 33648,
  85154. /**
  85155. * Repeat
  85156. */
  85157. REPEAT = 10497,
  85158. }
  85159. /**
  85160. * glTF Property
  85161. */
  85162. interface IProperty {
  85163. /**
  85164. * Dictionary object with extension-specific objects
  85165. */
  85166. extensions?: {
  85167. [key: string]: any;
  85168. };
  85169. /**
  85170. * Application-Specific data
  85171. */
  85172. extras?: any;
  85173. }
  85174. /**
  85175. * glTF Child of Root Property
  85176. */
  85177. interface IChildRootProperty extends IProperty {
  85178. /**
  85179. * The user-defined name of this object
  85180. */
  85181. name?: string;
  85182. }
  85183. /**
  85184. * Indices of those attributes that deviate from their initialization value
  85185. */
  85186. interface IAccessorSparseIndices extends IProperty {
  85187. /**
  85188. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  85189. */
  85190. bufferView: number;
  85191. /**
  85192. * The offset relative to the start of the bufferView in bytes. Must be aligned
  85193. */
  85194. byteOffset?: number;
  85195. /**
  85196. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  85197. */
  85198. componentType: AccessorComponentType;
  85199. }
  85200. /**
  85201. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  85202. */
  85203. interface IAccessorSparseValues extends IProperty {
  85204. /**
  85205. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  85206. */
  85207. bufferView: number;
  85208. /**
  85209. * The offset relative to the start of the bufferView in bytes. Must be aligned
  85210. */
  85211. byteOffset?: number;
  85212. }
  85213. /**
  85214. * Sparse storage of attributes that deviate from their initialization value
  85215. */
  85216. interface IAccessorSparse extends IProperty {
  85217. /**
  85218. * The number of attributes encoded in this sparse accessor
  85219. */
  85220. count: number;
  85221. /**
  85222. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  85223. */
  85224. indices: IAccessorSparseIndices;
  85225. /**
  85226. * 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
  85227. */
  85228. values: IAccessorSparseValues;
  85229. }
  85230. /**
  85231. * 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
  85232. */
  85233. interface IAccessor extends IChildRootProperty {
  85234. /**
  85235. * The index of the bufferview
  85236. */
  85237. bufferView?: number;
  85238. /**
  85239. * The offset relative to the start of the bufferView in bytes
  85240. */
  85241. byteOffset?: number;
  85242. /**
  85243. * The datatype of components in the attribute
  85244. */
  85245. componentType: AccessorComponentType;
  85246. /**
  85247. * Specifies whether integer data values should be normalized
  85248. */
  85249. normalized?: boolean;
  85250. /**
  85251. * The number of attributes referenced by this accessor
  85252. */
  85253. count: number;
  85254. /**
  85255. * Specifies if the attribute is a scalar, vector, or matrix
  85256. */
  85257. type: AccessorType;
  85258. /**
  85259. * Maximum value of each component in this attribute
  85260. */
  85261. max?: number[];
  85262. /**
  85263. * Minimum value of each component in this attribute
  85264. */
  85265. min?: number[];
  85266. /**
  85267. * Sparse storage of attributes that deviate from their initialization value
  85268. */
  85269. sparse?: IAccessorSparse;
  85270. }
  85271. /**
  85272. * Targets an animation's sampler at a node's property
  85273. */
  85274. interface IAnimationChannel extends IProperty {
  85275. /**
  85276. * The index of a sampler in this animation used to compute the value for the target
  85277. */
  85278. sampler: number;
  85279. /**
  85280. * The index of the node and TRS property to target
  85281. */
  85282. target: IAnimationChannelTarget;
  85283. }
  85284. /**
  85285. * The index of the node and TRS property that an animation channel targets
  85286. */
  85287. interface IAnimationChannelTarget extends IProperty {
  85288. /**
  85289. * The index of the node to target
  85290. */
  85291. node: number;
  85292. /**
  85293. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  85294. */
  85295. path: AnimationChannelTargetPath;
  85296. }
  85297. /**
  85298. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  85299. */
  85300. interface IAnimationSampler extends IProperty {
  85301. /**
  85302. * The index of an accessor containing keyframe input values, e.g., time
  85303. */
  85304. input: number;
  85305. /**
  85306. * Interpolation algorithm
  85307. */
  85308. interpolation?: AnimationSamplerInterpolation;
  85309. /**
  85310. * The index of an accessor, containing keyframe output values
  85311. */
  85312. output: number;
  85313. }
  85314. /**
  85315. * A keyframe animation
  85316. */
  85317. interface IAnimation extends IChildRootProperty {
  85318. /**
  85319. * An array of channels, each of which targets an animation's sampler at a node's property
  85320. */
  85321. channels: IAnimationChannel[];
  85322. /**
  85323. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  85324. */
  85325. samplers: IAnimationSampler[];
  85326. }
  85327. /**
  85328. * Metadata about the glTF asset
  85329. */
  85330. interface IAsset extends IChildRootProperty {
  85331. /**
  85332. * A copyright message suitable for display to credit the content creator
  85333. */
  85334. copyright?: string;
  85335. /**
  85336. * Tool that generated this glTF model. Useful for debugging
  85337. */
  85338. generator?: string;
  85339. /**
  85340. * The glTF version that this asset targets
  85341. */
  85342. version: string;
  85343. /**
  85344. * The minimum glTF version that this asset targets
  85345. */
  85346. minVersion?: string;
  85347. }
  85348. /**
  85349. * A buffer points to binary geometry, animation, or skins
  85350. */
  85351. interface IBuffer extends IChildRootProperty {
  85352. /**
  85353. * 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
  85354. */
  85355. uri?: string;
  85356. /**
  85357. * The length of the buffer in bytes
  85358. */
  85359. byteLength: number;
  85360. }
  85361. /**
  85362. * A view into a buffer generally representing a subset of the buffer
  85363. */
  85364. interface IBufferView extends IChildRootProperty {
  85365. /**
  85366. * The index of the buffer
  85367. */
  85368. buffer: number;
  85369. /**
  85370. * The offset into the buffer in bytes
  85371. */
  85372. byteOffset?: number;
  85373. /**
  85374. * The lenth of the bufferView in bytes
  85375. */
  85376. byteLength: number;
  85377. /**
  85378. * The stride, in bytes
  85379. */
  85380. byteStride?: number;
  85381. }
  85382. /**
  85383. * An orthographic camera containing properties to create an orthographic projection matrix
  85384. */
  85385. interface ICameraOrthographic extends IProperty {
  85386. /**
  85387. * The floating-point horizontal magnification of the view. Must not be zero
  85388. */
  85389. xmag: number;
  85390. /**
  85391. * The floating-point vertical magnification of the view. Must not be zero
  85392. */
  85393. ymag: number;
  85394. /**
  85395. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  85396. */
  85397. zfar: number;
  85398. /**
  85399. * The floating-point distance to the near clipping plane
  85400. */
  85401. znear: number;
  85402. }
  85403. /**
  85404. * A perspective camera containing properties to create a perspective projection matrix
  85405. */
  85406. interface ICameraPerspective extends IProperty {
  85407. /**
  85408. * The floating-point aspect ratio of the field of view
  85409. */
  85410. aspectRatio?: number;
  85411. /**
  85412. * The floating-point vertical field of view in radians
  85413. */
  85414. yfov: number;
  85415. /**
  85416. * The floating-point distance to the far clipping plane
  85417. */
  85418. zfar?: number;
  85419. /**
  85420. * The floating-point distance to the near clipping plane
  85421. */
  85422. znear: number;
  85423. }
  85424. /**
  85425. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  85426. */
  85427. interface ICamera extends IChildRootProperty {
  85428. /**
  85429. * An orthographic camera containing properties to create an orthographic projection matrix
  85430. */
  85431. orthographic?: ICameraOrthographic;
  85432. /**
  85433. * A perspective camera containing properties to create a perspective projection matrix
  85434. */
  85435. perspective?: ICameraPerspective;
  85436. /**
  85437. * Specifies if the camera uses a perspective or orthographic projection
  85438. */
  85439. type: CameraType;
  85440. }
  85441. /**
  85442. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  85443. */
  85444. interface IImage extends IChildRootProperty {
  85445. /**
  85446. * 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
  85447. */
  85448. uri?: string;
  85449. /**
  85450. * The image's MIME type
  85451. */
  85452. mimeType?: ImageMimeType;
  85453. /**
  85454. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  85455. */
  85456. bufferView?: number;
  85457. }
  85458. /**
  85459. * Material Normal Texture Info
  85460. */
  85461. interface IMaterialNormalTextureInfo extends ITextureInfo {
  85462. /**
  85463. * The scalar multiplier applied to each normal vector of the normal texture
  85464. */
  85465. scale?: number;
  85466. }
  85467. /**
  85468. * Material Occlusion Texture Info
  85469. */
  85470. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  85471. /**
  85472. * A scalar multiplier controlling the amount of occlusion applied
  85473. */
  85474. strength?: number;
  85475. }
  85476. /**
  85477. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  85478. */
  85479. interface IMaterialPbrMetallicRoughness {
  85480. /**
  85481. * The material's base color factor
  85482. */
  85483. baseColorFactor?: number[];
  85484. /**
  85485. * The base color texture
  85486. */
  85487. baseColorTexture?: ITextureInfo;
  85488. /**
  85489. * The metalness of the material
  85490. */
  85491. metallicFactor?: number;
  85492. /**
  85493. * The roughness of the material
  85494. */
  85495. roughnessFactor?: number;
  85496. /**
  85497. * The metallic-roughness texture
  85498. */
  85499. metallicRoughnessTexture?: ITextureInfo;
  85500. }
  85501. /**
  85502. * The material appearance of a primitive
  85503. */
  85504. interface IMaterial extends IChildRootProperty {
  85505. /**
  85506. * 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
  85507. */
  85508. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  85509. /**
  85510. * The normal map texture
  85511. */
  85512. normalTexture?: IMaterialNormalTextureInfo;
  85513. /**
  85514. * The occlusion map texture
  85515. */
  85516. occlusionTexture?: IMaterialOcclusionTextureInfo;
  85517. /**
  85518. * The emissive map texture
  85519. */
  85520. emissiveTexture?: ITextureInfo;
  85521. /**
  85522. * 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
  85523. */
  85524. emissiveFactor?: number[];
  85525. /**
  85526. * The alpha rendering mode of the material
  85527. */
  85528. alphaMode?: MaterialAlphaMode;
  85529. /**
  85530. * The alpha cutoff value of the material
  85531. */
  85532. alphaCutoff?: number;
  85533. /**
  85534. * Specifies whether the material is double sided
  85535. */
  85536. doubleSided?: boolean;
  85537. }
  85538. /**
  85539. * Geometry to be rendered with the given material
  85540. */
  85541. interface IMeshPrimitive extends IProperty {
  85542. /**
  85543. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  85544. */
  85545. attributes: {
  85546. [name: string]: number;
  85547. };
  85548. /**
  85549. * The index of the accessor that contains the indices
  85550. */
  85551. indices?: number;
  85552. /**
  85553. * The index of the material to apply to this primitive when rendering
  85554. */
  85555. material?: number;
  85556. /**
  85557. * The type of primitives to render. All valid values correspond to WebGL enums
  85558. */
  85559. mode?: MeshPrimitiveMode;
  85560. /**
  85561. * 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
  85562. */
  85563. targets?: {
  85564. [name: string]: number;
  85565. }[];
  85566. }
  85567. /**
  85568. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  85569. */
  85570. interface IMesh extends IChildRootProperty {
  85571. /**
  85572. * An array of primitives, each defining geometry to be rendered with a material
  85573. */
  85574. primitives: IMeshPrimitive[];
  85575. /**
  85576. * Array of weights to be applied to the Morph Targets
  85577. */
  85578. weights?: number[];
  85579. }
  85580. /**
  85581. * A node in the node hierarchy
  85582. */
  85583. interface INode extends IChildRootProperty {
  85584. /**
  85585. * The index of the camera referenced by this node
  85586. */
  85587. camera?: number;
  85588. /**
  85589. * The indices of this node's children
  85590. */
  85591. children?: number[];
  85592. /**
  85593. * The index of the skin referenced by this node
  85594. */
  85595. skin?: number;
  85596. /**
  85597. * A floating-point 4x4 transformation matrix stored in column-major order
  85598. */
  85599. matrix?: number[];
  85600. /**
  85601. * The index of the mesh in this node
  85602. */
  85603. mesh?: number;
  85604. /**
  85605. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  85606. */
  85607. rotation?: number[];
  85608. /**
  85609. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  85610. */
  85611. scale?: number[];
  85612. /**
  85613. * The node's translation along the x, y, and z axes
  85614. */
  85615. translation?: number[];
  85616. /**
  85617. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  85618. */
  85619. weights?: number[];
  85620. }
  85621. /**
  85622. * Texture sampler properties for filtering and wrapping modes
  85623. */
  85624. interface ISampler extends IChildRootProperty {
  85625. /**
  85626. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  85627. */
  85628. magFilter?: TextureMagFilter;
  85629. /**
  85630. * Minification filter. All valid values correspond to WebGL enums
  85631. */
  85632. minFilter?: TextureMinFilter;
  85633. /**
  85634. * S (U) wrapping mode. All valid values correspond to WebGL enums
  85635. */
  85636. wrapS?: TextureWrapMode;
  85637. /**
  85638. * T (V) wrapping mode. All valid values correspond to WebGL enums
  85639. */
  85640. wrapT?: TextureWrapMode;
  85641. }
  85642. /**
  85643. * The root nodes of a scene
  85644. */
  85645. interface IScene extends IChildRootProperty {
  85646. /**
  85647. * The indices of each root node
  85648. */
  85649. nodes: number[];
  85650. }
  85651. /**
  85652. * Joints and matrices defining a skin
  85653. */
  85654. interface ISkin extends IChildRootProperty {
  85655. /**
  85656. * 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
  85657. */
  85658. inverseBindMatrices?: number;
  85659. /**
  85660. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  85661. */
  85662. skeleton?: number;
  85663. /**
  85664. * 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)
  85665. */
  85666. joints: number[];
  85667. }
  85668. /**
  85669. * A texture and its sampler
  85670. */
  85671. interface ITexture extends IChildRootProperty {
  85672. /**
  85673. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  85674. */
  85675. sampler?: number;
  85676. /**
  85677. * The index of the image used by this texture
  85678. */
  85679. source: number;
  85680. }
  85681. /**
  85682. * Reference to a texture
  85683. */
  85684. interface ITextureInfo extends IProperty {
  85685. /**
  85686. * The index of the texture
  85687. */
  85688. index: number;
  85689. /**
  85690. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  85691. */
  85692. texCoord?: number;
  85693. }
  85694. /**
  85695. * The root object for a glTF asset
  85696. */
  85697. interface IGLTF extends IProperty {
  85698. /**
  85699. * An array of accessors. An accessor is a typed view into a bufferView
  85700. */
  85701. accessors?: IAccessor[];
  85702. /**
  85703. * An array of keyframe animations
  85704. */
  85705. animations?: IAnimation[];
  85706. /**
  85707. * Metadata about the glTF asset
  85708. */
  85709. asset: IAsset;
  85710. /**
  85711. * An array of buffers. A buffer points to binary geometry, animation, or skins
  85712. */
  85713. buffers?: IBuffer[];
  85714. /**
  85715. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  85716. */
  85717. bufferViews?: IBufferView[];
  85718. /**
  85719. * An array of cameras
  85720. */
  85721. cameras?: ICamera[];
  85722. /**
  85723. * Names of glTF extensions used somewhere in this asset
  85724. */
  85725. extensionsUsed?: string[];
  85726. /**
  85727. * Names of glTF extensions required to properly load this asset
  85728. */
  85729. extensionsRequired?: string[];
  85730. /**
  85731. * An array of images. An image defines data used to create a texture
  85732. */
  85733. images?: IImage[];
  85734. /**
  85735. * An array of materials. A material defines the appearance of a primitive
  85736. */
  85737. materials?: IMaterial[];
  85738. /**
  85739. * An array of meshes. A mesh is a set of primitives to be rendered
  85740. */
  85741. meshes?: IMesh[];
  85742. /**
  85743. * An array of nodes
  85744. */
  85745. nodes?: INode[];
  85746. /**
  85747. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  85748. */
  85749. samplers?: ISampler[];
  85750. /**
  85751. * The index of the default scene
  85752. */
  85753. scene?: number;
  85754. /**
  85755. * An array of scenes
  85756. */
  85757. scenes?: IScene[];
  85758. /**
  85759. * An array of skins. A skin is defined by joints and matrices
  85760. */
  85761. skins?: ISkin[];
  85762. /**
  85763. * An array of textures
  85764. */
  85765. textures?: ITexture[];
  85766. }
  85767. /**
  85768. * The glTF validation results
  85769. * @ignore
  85770. */
  85771. interface IGLTFValidationResults {
  85772. info: {
  85773. generator: string;
  85774. hasAnimations: boolean;
  85775. hasDefaultScene: boolean;
  85776. hasMaterials: boolean;
  85777. hasMorphTargets: boolean;
  85778. hasSkins: boolean;
  85779. hasTextures: boolean;
  85780. maxAttributesUsed: number;
  85781. primitivesCount: number
  85782. };
  85783. issues: {
  85784. messages: Array<string>;
  85785. numErrors: number;
  85786. numHints: number;
  85787. numInfos: number;
  85788. numWarnings: number;
  85789. truncated: boolean
  85790. };
  85791. mimeType: string;
  85792. uri: string;
  85793. validatedAt: string;
  85794. validatorVersion: string;
  85795. }
  85796. /**
  85797. * The glTF validation options
  85798. */
  85799. interface IGLTFValidationOptions {
  85800. /** Uri to use */
  85801. uri?: string;
  85802. /** Function used to load external resources */
  85803. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  85804. /** Boolean indicating that we need to validate accessor data */
  85805. validateAccessorData?: boolean;
  85806. /** max number of issues allowed */
  85807. maxIssues?: number;
  85808. /** Ignored issues */
  85809. ignoredIssues?: Array<string>;
  85810. /** Value to override severy settings */
  85811. severityOverrides?: Object;
  85812. }
  85813. /**
  85814. * The glTF validator object
  85815. * @ignore
  85816. */
  85817. interface IGLTFValidator {
  85818. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  85819. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  85820. }
  85821. /**
  85822. * Interfaces from the EXT_lights_image_based extension
  85823. */
  85824. /** @hidden */
  85825. interface IEXTLightsImageBased_LightReferenceImageBased {
  85826. light: number;
  85827. }
  85828. /** @hidden */
  85829. interface IEXTLightsImageBased_LightImageBased extends IChildRootProperty {
  85830. intensity: number;
  85831. rotation: number[];
  85832. specularImageSize: number;
  85833. specularImages: number[][];
  85834. irradianceCoefficients: number[][];
  85835. }
  85836. /** @hidden */
  85837. interface IEXTLightsImageBased {
  85838. lights: IEXTLightsImageBased_LightImageBased[];
  85839. }
  85840. /**
  85841. * Interfaces from the EXT_mesh_gpu_instancing extension
  85842. * !!! Experimental Extension Subject to Changes !!!
  85843. */
  85844. /** @hidden */
  85845. interface IEXTMeshGpuInstancing {
  85846. mesh?: number;
  85847. attributes: { [name: string]: number };
  85848. }
  85849. /**
  85850. * Interfaces from the KHR_draco_mesh_compression extension
  85851. */
  85852. /** @hidden */
  85853. interface IKHRDracoMeshCompression {
  85854. bufferView: number;
  85855. attributes: { [name: string]: number };
  85856. }
  85857. /**
  85858. * Interfaces from the KHR_lights_punctual extension
  85859. */
  85860. /** @hidden */
  85861. const enum IKHRLightsPunctual_LightType {
  85862. DIRECTIONAL = "directional",
  85863. POINT = "point",
  85864. SPOT = "spot"
  85865. }
  85866. /** @hidden */
  85867. interface IKHRLightsPunctual_LightReference {
  85868. light: number;
  85869. }
  85870. /** @hidden */
  85871. interface IKHRLightsPunctual_Light extends IChildRootProperty {
  85872. type: IKHRLightsPunctual_LightType;
  85873. color?: number[];
  85874. intensity?: number;
  85875. range?: number;
  85876. spot?: {
  85877. innerConeAngle?: number;
  85878. outerConeAngle?: number;
  85879. };
  85880. }
  85881. /** @hidden */
  85882. interface IKHRLightsPunctual {
  85883. lights: IKHRLightsPunctual_Light[];
  85884. }
  85885. /**
  85886. * Interfaces from the KHR_materials_clearcoat extension
  85887. * !!! Experimental Extension Subject to Changes !!!
  85888. */
  85889. /** @hidden */
  85890. interface IKHRMaterialsClearcoat {
  85891. clearcoatFactor: number;
  85892. clearcoatTexture: ITextureInfo;
  85893. clearcoatRoughnessFactor: number;
  85894. clearcoatRoughnessTexture: ITextureInfo;
  85895. clearcoatNormalTexture: IMaterialNormalTextureInfo;
  85896. }
  85897. /**
  85898. * Interfaces from the KHR_materials_ior extension
  85899. * !!! Experimental Extension Subject to Changes !!!
  85900. */
  85901. /** @hidden */
  85902. interface IKHRMaterialsIor {
  85903. ior: number;
  85904. }
  85905. /**
  85906. * Interfaces from the KHR_materials_pbrSpecularGlossiness extension
  85907. */
  85908. /** @hidden */
  85909. interface IKHRMaterialsPbrSpecularGlossiness {
  85910. diffuseFactor: number[];
  85911. diffuseTexture: ITextureInfo;
  85912. specularFactor: number[];
  85913. glossinessFactor: number;
  85914. specularGlossinessTexture: ITextureInfo;
  85915. }
  85916. /**
  85917. * Interfaces from the KHR_materials_sheen extension
  85918. * !!! Experimental Extension Subject to Changes !!!
  85919. */
  85920. /** @hidden */
  85921. interface IKHRMaterialsSheen {
  85922. sheenColorFactor?: number[];
  85923. sheenTexture?: ITextureInfo;
  85924. sheenRoughnessFactor?: number;
  85925. }
  85926. /**
  85927. * Interfaces from the KHR_materials_specular extension
  85928. * !!! Experimental Extension Subject to Changes !!!
  85929. */
  85930. /** @hidden */
  85931. interface IKHRMaterialsSpecular {
  85932. specularFactor: number;
  85933. specularColorFactor: number[];
  85934. specularTexture: ITextureInfo;
  85935. }
  85936. /**
  85937. * Interfaces from the KHR_materials_transmission extension
  85938. * !!! Experimental Extension Subject to Changes !!!
  85939. */
  85940. /** @hidden */
  85941. interface IKHRMaterialsTransmission {
  85942. transmissionFactor?: number;
  85943. transmissionTexture?: ITextureInfo;
  85944. }
  85945. /**
  85946. * Interfaces from the KHR_materials_variants extension
  85947. * !!! Experimental Extension Subject to Changes !!!
  85948. */
  85949. /** @hidden */
  85950. interface IKHRMaterialVariants_Mapping extends IProperty {
  85951. mappings: Array<{
  85952. variants: number[];
  85953. material: number;
  85954. }>;
  85955. }
  85956. /** @hidden */
  85957. interface IKHRMaterialVariants_Variant extends IProperty {
  85958. name: string;
  85959. }
  85960. /** @hidden */
  85961. interface IKHRMaterialVariants_Variants extends IChildRootProperty {
  85962. variants: Array<IKHRMaterialVariants_Variant>;
  85963. }
  85964. /**
  85965. * Interfaces from the KHR_texture_basisu extension
  85966. * !!! Experimental Extension Subject to Changes !!!
  85967. */
  85968. /** @hidden */
  85969. interface IKHRTextureBasisU {
  85970. source: number;
  85971. }
  85972. /**
  85973. * Interfaces from the EXT_texture_webp extension
  85974. */
  85975. /** @hidden */
  85976. interface IEXTTextureWebP {
  85977. source: number;
  85978. }
  85979. /**
  85980. * Interfaces from the KHR_texture_transform extension
  85981. */
  85982. /** @hidden */
  85983. interface IKHRTextureTransform {
  85984. offset?: number[];
  85985. rotation?: number;
  85986. scale?: number[];
  85987. texCoord?: number;
  85988. }
  85989. /**
  85990. * Interfaces from the KHR_xmp extension
  85991. * !!! Experimental Extension Subject to Changes !!!
  85992. */
  85993. /** @hidden */
  85994. interface IKHRXmp_Data {
  85995. [key: string]: unknown;
  85996. }
  85997. /** @hidden */
  85998. interface IKHRXmp_Gltf {
  85999. packets: IKHRXmp_Data[];
  86000. }
  86001. /** @hidden */
  86002. interface IKHRXmp_Node {
  86003. packet: number;
  86004. }
  86005. /**
  86006. * Interfaces from the MSFT_audio_emitter extension
  86007. */
  86008. /** @hidden */
  86009. interface IMSFTAudioEmitter_ClipReference {
  86010. clip: number;
  86011. weight?: number;
  86012. }
  86013. /** @hidden */
  86014. interface IMSFTAudioEmitter_EmittersReference {
  86015. emitters: number[];
  86016. }
  86017. /** @hidden */
  86018. const enum IMSFTAudioEmitter_DistanceModel {
  86019. linear = "linear",
  86020. inverse = "inverse",
  86021. exponential = "exponential",
  86022. }
  86023. /** @hidden */
  86024. interface IMSFTAudioEmitter_Emitter {
  86025. name?: string;
  86026. distanceModel?: IMSFTAudioEmitter_DistanceModel;
  86027. refDistance?: number;
  86028. maxDistance?: number;
  86029. rolloffFactor?: number;
  86030. innerAngle?: number;
  86031. outerAngle?: number;
  86032. loop?: boolean;
  86033. volume?: number;
  86034. clips: IMSFTAudioEmitter_ClipReference[];
  86035. }
  86036. /** @hidden */
  86037. const enum IMSFTAudioEmitter_AudioMimeType {
  86038. WAV = "audio/wav",
  86039. }
  86040. /** @hidden */
  86041. interface IMSFTAudioEmitter_Clip extends IProperty {
  86042. uri?: string;
  86043. bufferView?: number;
  86044. mimeType?: IMSFTAudioEmitter_AudioMimeType;
  86045. }
  86046. /** @hidden */
  86047. const enum IMSFTAudioEmitter_AnimationEventAction {
  86048. play = "play",
  86049. pause = "pause",
  86050. stop = "stop",
  86051. }
  86052. /** @hidden */
  86053. interface IMSFTAudioEmitter_AnimationEvent {
  86054. action: IMSFTAudioEmitter_AnimationEventAction;
  86055. emitter: number;
  86056. time: number;
  86057. startOffset?: number;
  86058. }
  86059. /**
  86060. * Interfaces from the MSFT_lod extension
  86061. */
  86062. /** @hidden */
  86063. interface IMSFTLOD {
  86064. ids: number[];
  86065. }
  86066. }
  86067. declare module BABYLON {
  86068. /** @hidden */
  86069. export var cellPixelShader: {
  86070. name: string;
  86071. shader: string;
  86072. };
  86073. }
  86074. declare module BABYLON {
  86075. /** @hidden */
  86076. export var cellVertexShader: {
  86077. name: string;
  86078. shader: string;
  86079. };
  86080. }
  86081. declare module BABYLON {
  86082. export class CellMaterial extends BABYLON.PushMaterial {
  86083. private _diffuseTexture;
  86084. diffuseTexture: BABYLON.BaseTexture;
  86085. diffuseColor: BABYLON.Color3;
  86086. _computeHighLevel: boolean;
  86087. computeHighLevel: boolean;
  86088. private _disableLighting;
  86089. disableLighting: boolean;
  86090. private _maxSimultaneousLights;
  86091. maxSimultaneousLights: number;
  86092. constructor(name: string, scene: BABYLON.Scene);
  86093. needAlphaBlending(): boolean;
  86094. needAlphaTesting(): boolean;
  86095. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86096. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86097. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86098. getAnimatables(): BABYLON.IAnimatable[];
  86099. getActiveTextures(): BABYLON.BaseTexture[];
  86100. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86101. dispose(forceDisposeEffect?: boolean): void;
  86102. getClassName(): string;
  86103. clone(name: string): CellMaterial;
  86104. serialize(): any;
  86105. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  86106. }
  86107. }
  86108. declare module BABYLON {
  86109. export class CustomShaderStructure {
  86110. FragmentStore: string;
  86111. VertexStore: string;
  86112. constructor();
  86113. }
  86114. export class ShaderSpecialParts {
  86115. constructor();
  86116. Fragment_Begin: string;
  86117. Fragment_Definitions: string;
  86118. Fragment_MainBegin: string;
  86119. Fragment_Custom_Diffuse: string;
  86120. Fragment_Before_Lights: string;
  86121. Fragment_Before_Fog: string;
  86122. Fragment_Custom_Alpha: string;
  86123. Fragment_Before_FragColor: string;
  86124. Vertex_Begin: string;
  86125. Vertex_Definitions: string;
  86126. Vertex_MainBegin: string;
  86127. Vertex_Before_PositionUpdated: string;
  86128. Vertex_Before_NormalUpdated: string;
  86129. Vertex_After_WorldPosComputed: string;
  86130. Vertex_MainEnd: string;
  86131. }
  86132. export class CustomMaterial extends BABYLON.StandardMaterial {
  86133. static ShaderIndexer: number;
  86134. CustomParts: ShaderSpecialParts;
  86135. _isCreatedShader: boolean;
  86136. _createdShaderName: string;
  86137. _customUniform: string[];
  86138. _newUniforms: string[];
  86139. _newUniformInstances: {
  86140. [name: string]: any;
  86141. };
  86142. _newSamplerInstances: {
  86143. [name: string]: BABYLON.Texture;
  86144. };
  86145. _customAttributes: string[];
  86146. FragmentShader: string;
  86147. VertexShader: string;
  86148. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  86149. ReviewUniform(name: string, arr: string[]): string[];
  86150. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  86151. constructor(name: string, scene: BABYLON.Scene);
  86152. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  86153. AddAttribute(name: string): CustomMaterial;
  86154. Fragment_Begin(shaderPart: string): CustomMaterial;
  86155. Fragment_Definitions(shaderPart: string): CustomMaterial;
  86156. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  86157. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  86158. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  86159. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  86160. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  86161. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  86162. Vertex_Begin(shaderPart: string): CustomMaterial;
  86163. Vertex_Definitions(shaderPart: string): CustomMaterial;
  86164. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  86165. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  86166. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  86167. Vertex_After_WorldPosComputed(shaderPart: string): CustomMaterial;
  86168. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  86169. }
  86170. }
  86171. declare module BABYLON {
  86172. export class ShaderAlebdoParts {
  86173. constructor();
  86174. Fragment_Begin: string;
  86175. Fragment_Definitions: string;
  86176. Fragment_MainBegin: string;
  86177. Fragment_Custom_Albedo: string;
  86178. Fragment_Before_Lights: string;
  86179. Fragment_Custom_MetallicRoughness: string;
  86180. Fragment_Custom_MicroSurface: string;
  86181. Fragment_Before_Fog: string;
  86182. Fragment_Custom_Alpha: string;
  86183. Fragment_Before_FragColor: string;
  86184. Vertex_Begin: string;
  86185. Vertex_Definitions: string;
  86186. Vertex_MainBegin: string;
  86187. Vertex_Before_PositionUpdated: string;
  86188. Vertex_Before_NormalUpdated: string;
  86189. Vertex_After_WorldPosComputed: string;
  86190. Vertex_MainEnd: string;
  86191. }
  86192. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  86193. static ShaderIndexer: number;
  86194. CustomParts: ShaderAlebdoParts;
  86195. _isCreatedShader: boolean;
  86196. _createdShaderName: string;
  86197. _customUniform: string[];
  86198. _newUniforms: string[];
  86199. _newUniformInstances: {
  86200. [name: string]: any;
  86201. };
  86202. _newSamplerInstances: {
  86203. [name: string]: BABYLON.Texture;
  86204. };
  86205. _customAttributes: string[];
  86206. FragmentShader: string;
  86207. VertexShader: string;
  86208. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  86209. ReviewUniform(name: string, arr: string[]): string[];
  86210. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.MaterialDefines | string[], attributes?: string[]): string;
  86211. constructor(name: string, scene: BABYLON.Scene);
  86212. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  86213. AddAttribute(name: string): PBRCustomMaterial;
  86214. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  86215. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  86216. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  86217. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  86218. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  86219. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  86220. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  86221. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  86222. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  86223. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  86224. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  86225. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  86226. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  86227. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  86228. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  86229. Vertex_After_WorldPosComputed(shaderPart: string): PBRCustomMaterial;
  86230. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  86231. }
  86232. }
  86233. declare module BABYLON {
  86234. /** @hidden */
  86235. export var firePixelShader: {
  86236. name: string;
  86237. shader: string;
  86238. };
  86239. }
  86240. declare module BABYLON {
  86241. /** @hidden */
  86242. export var fireVertexShader: {
  86243. name: string;
  86244. shader: string;
  86245. };
  86246. }
  86247. declare module BABYLON {
  86248. export class FireMaterial extends BABYLON.PushMaterial {
  86249. private _diffuseTexture;
  86250. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  86251. private _distortionTexture;
  86252. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  86253. private _opacityTexture;
  86254. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  86255. diffuseColor: BABYLON.Color3;
  86256. speed: number;
  86257. private _scaledDiffuse;
  86258. private _lastTime;
  86259. constructor(name: string, scene: BABYLON.Scene);
  86260. needAlphaBlending(): boolean;
  86261. needAlphaTesting(): boolean;
  86262. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86263. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86264. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86265. getAnimatables(): BABYLON.IAnimatable[];
  86266. getActiveTextures(): BABYLON.BaseTexture[];
  86267. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86268. getClassName(): string;
  86269. dispose(forceDisposeEffect?: boolean): void;
  86270. clone(name: string): FireMaterial;
  86271. serialize(): any;
  86272. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  86273. }
  86274. }
  86275. declare module BABYLON {
  86276. /** @hidden */
  86277. export var furPixelShader: {
  86278. name: string;
  86279. shader: string;
  86280. };
  86281. }
  86282. declare module BABYLON {
  86283. /** @hidden */
  86284. export var furVertexShader: {
  86285. name: string;
  86286. shader: string;
  86287. };
  86288. }
  86289. declare module BABYLON {
  86290. export class FurMaterial extends BABYLON.PushMaterial {
  86291. private _diffuseTexture;
  86292. diffuseTexture: BABYLON.BaseTexture;
  86293. private _heightTexture;
  86294. heightTexture: BABYLON.BaseTexture;
  86295. diffuseColor: BABYLON.Color3;
  86296. furLength: number;
  86297. furAngle: number;
  86298. furColor: BABYLON.Color3;
  86299. furOffset: number;
  86300. furSpacing: number;
  86301. furGravity: BABYLON.Vector3;
  86302. furSpeed: number;
  86303. furDensity: number;
  86304. furOcclusion: number;
  86305. furTexture: BABYLON.DynamicTexture;
  86306. private _disableLighting;
  86307. disableLighting: boolean;
  86308. private _maxSimultaneousLights;
  86309. maxSimultaneousLights: number;
  86310. highLevelFur: boolean;
  86311. _meshes: BABYLON.AbstractMesh[];
  86312. private _furTime;
  86313. constructor(name: string, scene: BABYLON.Scene);
  86314. get furTime(): number;
  86315. set furTime(furTime: number);
  86316. needAlphaBlending(): boolean;
  86317. needAlphaTesting(): boolean;
  86318. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86319. updateFur(): void;
  86320. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86321. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86322. getAnimatables(): BABYLON.IAnimatable[];
  86323. getActiveTextures(): BABYLON.BaseTexture[];
  86324. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86325. dispose(forceDisposeEffect?: boolean): void;
  86326. clone(name: string): FurMaterial;
  86327. serialize(): any;
  86328. getClassName(): string;
  86329. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  86330. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  86331. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  86332. }
  86333. }
  86334. declare module BABYLON {
  86335. /** @hidden */
  86336. export var gradientPixelShader: {
  86337. name: string;
  86338. shader: string;
  86339. };
  86340. }
  86341. declare module BABYLON {
  86342. /** @hidden */
  86343. export var gradientVertexShader: {
  86344. name: string;
  86345. shader: string;
  86346. };
  86347. }
  86348. declare module BABYLON {
  86349. export class GradientMaterial extends BABYLON.PushMaterial {
  86350. private _maxSimultaneousLights;
  86351. maxSimultaneousLights: number;
  86352. topColor: BABYLON.Color3;
  86353. topColorAlpha: number;
  86354. bottomColor: BABYLON.Color3;
  86355. bottomColorAlpha: number;
  86356. offset: number;
  86357. scale: number;
  86358. smoothness: number;
  86359. private _disableLighting;
  86360. disableLighting: boolean;
  86361. constructor(name: string, scene: BABYLON.Scene);
  86362. needAlphaBlending(): boolean;
  86363. needAlphaTesting(): boolean;
  86364. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86365. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86366. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86367. getAnimatables(): BABYLON.IAnimatable[];
  86368. dispose(forceDisposeEffect?: boolean): void;
  86369. clone(name: string): GradientMaterial;
  86370. serialize(): any;
  86371. getClassName(): string;
  86372. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  86373. }
  86374. }
  86375. declare module BABYLON {
  86376. /** @hidden */
  86377. export var gridPixelShader: {
  86378. name: string;
  86379. shader: string;
  86380. };
  86381. }
  86382. declare module BABYLON {
  86383. /** @hidden */
  86384. export var gridVertexShader: {
  86385. name: string;
  86386. shader: string;
  86387. };
  86388. }
  86389. declare module BABYLON {
  86390. /**
  86391. * The grid materials allows you to wrap any shape with a grid.
  86392. * Colors are customizable.
  86393. */
  86394. export class GridMaterial extends BABYLON.PushMaterial {
  86395. /**
  86396. * Main color of the grid (e.g. between lines)
  86397. */
  86398. mainColor: BABYLON.Color3;
  86399. /**
  86400. * Color of the grid lines.
  86401. */
  86402. lineColor: BABYLON.Color3;
  86403. /**
  86404. * The scale of the grid compared to unit.
  86405. */
  86406. gridRatio: number;
  86407. /**
  86408. * Allows setting an offset for the grid lines.
  86409. */
  86410. gridOffset: BABYLON.Vector3;
  86411. /**
  86412. * The frequency of thicker lines.
  86413. */
  86414. majorUnitFrequency: number;
  86415. /**
  86416. * The visibility of minor units in the grid.
  86417. */
  86418. minorUnitVisibility: number;
  86419. /**
  86420. * The grid opacity outside of the lines.
  86421. */
  86422. opacity: number;
  86423. /**
  86424. * Determine RBG output is premultiplied by alpha value.
  86425. */
  86426. preMultiplyAlpha: boolean;
  86427. private _opacityTexture;
  86428. opacityTexture: BABYLON.BaseTexture;
  86429. private _gridControl;
  86430. /**
  86431. * constructor
  86432. * @param name The name given to the material in order to identify it afterwards.
  86433. * @param scene The scene the material is used in.
  86434. */
  86435. constructor(name: string, scene: BABYLON.Scene);
  86436. /**
  86437. * Returns wehter or not the grid requires alpha blending.
  86438. */
  86439. needAlphaBlending(): boolean;
  86440. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  86441. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86442. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86443. /**
  86444. * Dispose the material and its associated resources.
  86445. * @param forceDisposeEffect will also dispose the used effect when true
  86446. */
  86447. dispose(forceDisposeEffect?: boolean): void;
  86448. clone(name: string): GridMaterial;
  86449. serialize(): any;
  86450. getClassName(): string;
  86451. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  86452. }
  86453. }
  86454. declare module BABYLON {
  86455. /** @hidden */
  86456. export var lavaPixelShader: {
  86457. name: string;
  86458. shader: string;
  86459. };
  86460. }
  86461. declare module BABYLON {
  86462. /** @hidden */
  86463. export var lavaVertexShader: {
  86464. name: string;
  86465. shader: string;
  86466. };
  86467. }
  86468. declare module BABYLON {
  86469. export class LavaMaterial extends BABYLON.PushMaterial {
  86470. private _diffuseTexture;
  86471. diffuseTexture: BABYLON.BaseTexture;
  86472. noiseTexture: BABYLON.BaseTexture;
  86473. fogColor: BABYLON.Color3;
  86474. speed: number;
  86475. movingSpeed: number;
  86476. lowFrequencySpeed: number;
  86477. fogDensity: number;
  86478. private _lastTime;
  86479. diffuseColor: BABYLON.Color3;
  86480. private _disableLighting;
  86481. disableLighting: boolean;
  86482. private _unlit;
  86483. unlit: boolean;
  86484. private _maxSimultaneousLights;
  86485. maxSimultaneousLights: number;
  86486. private _scaledDiffuse;
  86487. constructor(name: string, scene: BABYLON.Scene);
  86488. needAlphaBlending(): boolean;
  86489. needAlphaTesting(): boolean;
  86490. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86491. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86492. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86493. getAnimatables(): BABYLON.IAnimatable[];
  86494. getActiveTextures(): BABYLON.BaseTexture[];
  86495. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86496. dispose(forceDisposeEffect?: boolean): void;
  86497. clone(name: string): LavaMaterial;
  86498. serialize(): any;
  86499. getClassName(): string;
  86500. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  86501. }
  86502. }
  86503. declare module BABYLON {
  86504. /** @hidden */
  86505. export var mixPixelShader: {
  86506. name: string;
  86507. shader: string;
  86508. };
  86509. }
  86510. declare module BABYLON {
  86511. /** @hidden */
  86512. export var mixVertexShader: {
  86513. name: string;
  86514. shader: string;
  86515. };
  86516. }
  86517. declare module BABYLON {
  86518. export class MixMaterial extends BABYLON.PushMaterial {
  86519. /**
  86520. * Mix textures
  86521. */
  86522. private _mixTexture1;
  86523. mixTexture1: BABYLON.BaseTexture;
  86524. private _mixTexture2;
  86525. mixTexture2: BABYLON.BaseTexture;
  86526. /**
  86527. * Diffuse textures
  86528. */
  86529. private _diffuseTexture1;
  86530. diffuseTexture1: BABYLON.Texture;
  86531. private _diffuseTexture2;
  86532. diffuseTexture2: BABYLON.Texture;
  86533. private _diffuseTexture3;
  86534. diffuseTexture3: BABYLON.Texture;
  86535. private _diffuseTexture4;
  86536. diffuseTexture4: BABYLON.Texture;
  86537. private _diffuseTexture5;
  86538. diffuseTexture5: BABYLON.Texture;
  86539. private _diffuseTexture6;
  86540. diffuseTexture6: BABYLON.Texture;
  86541. private _diffuseTexture7;
  86542. diffuseTexture7: BABYLON.Texture;
  86543. private _diffuseTexture8;
  86544. diffuseTexture8: BABYLON.Texture;
  86545. /**
  86546. * Uniforms
  86547. */
  86548. diffuseColor: BABYLON.Color3;
  86549. specularColor: BABYLON.Color3;
  86550. specularPower: number;
  86551. private _disableLighting;
  86552. disableLighting: boolean;
  86553. private _maxSimultaneousLights;
  86554. maxSimultaneousLights: number;
  86555. constructor(name: string, scene: BABYLON.Scene);
  86556. needAlphaBlending(): boolean;
  86557. needAlphaTesting(): boolean;
  86558. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86559. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86560. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86561. getAnimatables(): BABYLON.IAnimatable[];
  86562. getActiveTextures(): BABYLON.BaseTexture[];
  86563. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86564. dispose(forceDisposeEffect?: boolean): void;
  86565. clone(name: string): MixMaterial;
  86566. serialize(): any;
  86567. getClassName(): string;
  86568. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  86569. }
  86570. }
  86571. declare module BABYLON {
  86572. /** @hidden */
  86573. export var normalPixelShader: {
  86574. name: string;
  86575. shader: string;
  86576. };
  86577. }
  86578. declare module BABYLON {
  86579. /** @hidden */
  86580. export var normalVertexShader: {
  86581. name: string;
  86582. shader: string;
  86583. };
  86584. }
  86585. declare module BABYLON {
  86586. export class NormalMaterial extends BABYLON.PushMaterial {
  86587. private _diffuseTexture;
  86588. diffuseTexture: BABYLON.BaseTexture;
  86589. diffuseColor: BABYLON.Color3;
  86590. private _disableLighting;
  86591. disableLighting: boolean;
  86592. private _maxSimultaneousLights;
  86593. maxSimultaneousLights: number;
  86594. constructor(name: string, scene: BABYLON.Scene);
  86595. needAlphaBlending(): boolean;
  86596. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  86597. needAlphaTesting(): boolean;
  86598. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86599. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86600. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86601. getAnimatables(): BABYLON.IAnimatable[];
  86602. getActiveTextures(): BABYLON.BaseTexture[];
  86603. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86604. dispose(forceDisposeEffect?: boolean): void;
  86605. clone(name: string): NormalMaterial;
  86606. serialize(): any;
  86607. getClassName(): string;
  86608. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  86609. }
  86610. }
  86611. declare module BABYLON {
  86612. /** @hidden */
  86613. export var shadowOnlyPixelShader: {
  86614. name: string;
  86615. shader: string;
  86616. };
  86617. }
  86618. declare module BABYLON {
  86619. /** @hidden */
  86620. export var shadowOnlyVertexShader: {
  86621. name: string;
  86622. shader: string;
  86623. };
  86624. }
  86625. declare module BABYLON {
  86626. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  86627. private _activeLight;
  86628. private _needAlphaBlending;
  86629. constructor(name: string, scene: BABYLON.Scene);
  86630. shadowColor: BABYLON.Color3;
  86631. needAlphaBlending(): boolean;
  86632. needAlphaTesting(): boolean;
  86633. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86634. get activeLight(): BABYLON.IShadowLight;
  86635. set activeLight(light: BABYLON.IShadowLight);
  86636. private _getFirstShadowLightForMesh;
  86637. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86638. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86639. clone(name: string): ShadowOnlyMaterial;
  86640. serialize(): any;
  86641. getClassName(): string;
  86642. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  86643. }
  86644. }
  86645. declare module BABYLON {
  86646. /** @hidden */
  86647. export var simplePixelShader: {
  86648. name: string;
  86649. shader: string;
  86650. };
  86651. }
  86652. declare module BABYLON {
  86653. /** @hidden */
  86654. export var simpleVertexShader: {
  86655. name: string;
  86656. shader: string;
  86657. };
  86658. }
  86659. declare module BABYLON {
  86660. export class SimpleMaterial extends BABYLON.PushMaterial {
  86661. private _diffuseTexture;
  86662. diffuseTexture: BABYLON.BaseTexture;
  86663. diffuseColor: BABYLON.Color3;
  86664. private _disableLighting;
  86665. disableLighting: boolean;
  86666. private _maxSimultaneousLights;
  86667. maxSimultaneousLights: number;
  86668. constructor(name: string, scene: BABYLON.Scene);
  86669. needAlphaBlending(): boolean;
  86670. needAlphaTesting(): boolean;
  86671. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86672. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86673. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86674. getAnimatables(): BABYLON.IAnimatable[];
  86675. getActiveTextures(): BABYLON.BaseTexture[];
  86676. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86677. dispose(forceDisposeEffect?: boolean): void;
  86678. clone(name: string): SimpleMaterial;
  86679. serialize(): any;
  86680. getClassName(): string;
  86681. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  86682. }
  86683. }
  86684. declare module BABYLON {
  86685. /** @hidden */
  86686. export var skyPixelShader: {
  86687. name: string;
  86688. shader: string;
  86689. };
  86690. }
  86691. declare module BABYLON {
  86692. /** @hidden */
  86693. export var skyVertexShader: {
  86694. name: string;
  86695. shader: string;
  86696. };
  86697. }
  86698. declare module BABYLON {
  86699. /**
  86700. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  86701. * @see https://doc.babylonjs.com/extensions/sky
  86702. */
  86703. export class SkyMaterial extends BABYLON.PushMaterial {
  86704. /**
  86705. * Defines the overall luminance of sky in interval ]0, 1[.
  86706. */
  86707. luminance: number;
  86708. /**
  86709. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  86710. */
  86711. turbidity: number;
  86712. /**
  86713. * Defines the sky appearance (light intensity).
  86714. */
  86715. rayleigh: number;
  86716. /**
  86717. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  86718. */
  86719. mieCoefficient: number;
  86720. /**
  86721. * Defines the amount of haze particles following the Mie scattering theory.
  86722. */
  86723. mieDirectionalG: number;
  86724. /**
  86725. * Defines the distance of the sun according to the active scene camera.
  86726. */
  86727. distance: number;
  86728. /**
  86729. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  86730. * "inclined".
  86731. */
  86732. inclination: number;
  86733. /**
  86734. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  86735. * an object direction and a reference direction.
  86736. */
  86737. azimuth: number;
  86738. /**
  86739. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  86740. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  86741. */
  86742. sunPosition: BABYLON.Vector3;
  86743. /**
  86744. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  86745. * .sunPosition property.
  86746. */
  86747. useSunPosition: boolean;
  86748. /**
  86749. * Defines an offset vector used to get a horizon offset.
  86750. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  86751. */
  86752. cameraOffset: BABYLON.Vector3;
  86753. private _cameraPosition;
  86754. /**
  86755. * Instantiates a new sky material.
  86756. * This material allows to create dynamic and texture free
  86757. * effects for skyboxes by taking care of the atmosphere state.
  86758. * @see https://doc.babylonjs.com/extensions/sky
  86759. * @param name Define the name of the material in the scene
  86760. * @param scene Define the scene the material belong to
  86761. */
  86762. constructor(name: string, scene: BABYLON.Scene);
  86763. /**
  86764. * Specifies if the material will require alpha blending
  86765. * @returns a boolean specifying if alpha blending is needed
  86766. */
  86767. needAlphaBlending(): boolean;
  86768. /**
  86769. * Specifies if this material should be rendered in alpha test mode
  86770. * @returns false as the sky material doesn't need alpha testing.
  86771. */
  86772. needAlphaTesting(): boolean;
  86773. /**
  86774. * Get the texture used for alpha test purpose.
  86775. * @returns null as the sky material has no texture.
  86776. */
  86777. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86778. /**
  86779. * Get if the submesh is ready to be used and all its information available.
  86780. * Child classes can use it to update shaders
  86781. * @param mesh defines the mesh to check
  86782. * @param subMesh defines which submesh to check
  86783. * @param useInstances specifies that instances should be used
  86784. * @returns a boolean indicating that the submesh is ready or not
  86785. */
  86786. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86787. /**
  86788. * Binds the submesh to this material by preparing the effect and shader to draw
  86789. * @param world defines the world transformation matrix
  86790. * @param mesh defines the mesh containing the submesh
  86791. * @param subMesh defines the submesh to bind the material to
  86792. */
  86793. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86794. /**
  86795. * Get the list of animatables in the material.
  86796. * @returns the list of animatables object used in the material
  86797. */
  86798. getAnimatables(): BABYLON.IAnimatable[];
  86799. /**
  86800. * Disposes the material
  86801. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  86802. */
  86803. dispose(forceDisposeEffect?: boolean): void;
  86804. /**
  86805. * Makes a duplicate of the material, and gives it a new name
  86806. * @param name defines the new name for the duplicated material
  86807. * @returns the cloned material
  86808. */
  86809. clone(name: string): SkyMaterial;
  86810. /**
  86811. * Serializes this material in a JSON representation
  86812. * @returns the serialized material object
  86813. */
  86814. serialize(): any;
  86815. /**
  86816. * Gets the current class name of the material e.g. "SkyMaterial"
  86817. * Mainly use in serialization.
  86818. * @returns the class name
  86819. */
  86820. getClassName(): string;
  86821. /**
  86822. * Creates a sky material from parsed material data
  86823. * @param source defines the JSON representation of the material
  86824. * @param scene defines the hosting scene
  86825. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  86826. * @returns a new sky material
  86827. */
  86828. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  86829. }
  86830. }
  86831. declare module BABYLON {
  86832. /** @hidden */
  86833. export var terrainPixelShader: {
  86834. name: string;
  86835. shader: string;
  86836. };
  86837. }
  86838. declare module BABYLON {
  86839. /** @hidden */
  86840. export var terrainVertexShader: {
  86841. name: string;
  86842. shader: string;
  86843. };
  86844. }
  86845. declare module BABYLON {
  86846. export class TerrainMaterial extends BABYLON.PushMaterial {
  86847. private _mixTexture;
  86848. mixTexture: BABYLON.BaseTexture;
  86849. private _diffuseTexture1;
  86850. diffuseTexture1: BABYLON.Texture;
  86851. private _diffuseTexture2;
  86852. diffuseTexture2: BABYLON.Texture;
  86853. private _diffuseTexture3;
  86854. diffuseTexture3: BABYLON.Texture;
  86855. private _bumpTexture1;
  86856. bumpTexture1: BABYLON.Texture;
  86857. private _bumpTexture2;
  86858. bumpTexture2: BABYLON.Texture;
  86859. private _bumpTexture3;
  86860. bumpTexture3: BABYLON.Texture;
  86861. diffuseColor: BABYLON.Color3;
  86862. specularColor: BABYLON.Color3;
  86863. specularPower: number;
  86864. private _disableLighting;
  86865. disableLighting: boolean;
  86866. private _maxSimultaneousLights;
  86867. maxSimultaneousLights: number;
  86868. constructor(name: string, scene: BABYLON.Scene);
  86869. needAlphaBlending(): boolean;
  86870. needAlphaTesting(): boolean;
  86871. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86872. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86873. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86874. getAnimatables(): BABYLON.IAnimatable[];
  86875. getActiveTextures(): BABYLON.BaseTexture[];
  86876. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86877. dispose(forceDisposeEffect?: boolean): void;
  86878. clone(name: string): TerrainMaterial;
  86879. serialize(): any;
  86880. getClassName(): string;
  86881. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  86882. }
  86883. }
  86884. declare module BABYLON {
  86885. /** @hidden */
  86886. export var triplanarPixelShader: {
  86887. name: string;
  86888. shader: string;
  86889. };
  86890. }
  86891. declare module BABYLON {
  86892. /** @hidden */
  86893. export var triplanarVertexShader: {
  86894. name: string;
  86895. shader: string;
  86896. };
  86897. }
  86898. declare module BABYLON {
  86899. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  86900. mixTexture: BABYLON.BaseTexture;
  86901. private _diffuseTextureX;
  86902. diffuseTextureX: BABYLON.BaseTexture;
  86903. private _diffuseTextureY;
  86904. diffuseTextureY: BABYLON.BaseTexture;
  86905. private _diffuseTextureZ;
  86906. diffuseTextureZ: BABYLON.BaseTexture;
  86907. private _normalTextureX;
  86908. normalTextureX: BABYLON.BaseTexture;
  86909. private _normalTextureY;
  86910. normalTextureY: BABYLON.BaseTexture;
  86911. private _normalTextureZ;
  86912. normalTextureZ: BABYLON.BaseTexture;
  86913. tileSize: number;
  86914. diffuseColor: BABYLON.Color3;
  86915. specularColor: BABYLON.Color3;
  86916. specularPower: number;
  86917. private _disableLighting;
  86918. disableLighting: boolean;
  86919. private _maxSimultaneousLights;
  86920. maxSimultaneousLights: number;
  86921. constructor(name: string, scene: BABYLON.Scene);
  86922. needAlphaBlending(): boolean;
  86923. needAlphaTesting(): boolean;
  86924. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  86925. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  86926. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  86927. getAnimatables(): BABYLON.IAnimatable[];
  86928. getActiveTextures(): BABYLON.BaseTexture[];
  86929. hasTexture(texture: BABYLON.BaseTexture): boolean;
  86930. dispose(forceDisposeEffect?: boolean): void;
  86931. clone(name: string): TriPlanarMaterial;
  86932. serialize(): any;
  86933. getClassName(): string;
  86934. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  86935. }
  86936. }
  86937. declare module BABYLON {
  86938. /** @hidden */
  86939. export var waterPixelShader: {
  86940. name: string;
  86941. shader: string;
  86942. };
  86943. }
  86944. declare module BABYLON {
  86945. /** @hidden */
  86946. export var waterVertexShader: {
  86947. name: string;
  86948. shader: string;
  86949. };
  86950. }
  86951. declare module BABYLON {
  86952. export class WaterMaterial extends BABYLON.PushMaterial {
  86953. renderTargetSize: BABYLON.Vector2;
  86954. private _bumpTexture;
  86955. bumpTexture: BABYLON.BaseTexture;
  86956. diffuseColor: BABYLON.Color3;
  86957. specularColor: BABYLON.Color3;
  86958. specularPower: number;
  86959. private _disableLighting;
  86960. disableLighting: boolean;
  86961. private _maxSimultaneousLights;
  86962. maxSimultaneousLights: number;
  86963. /**
  86964. * Defines the wind force.
  86965. */
  86966. windForce: number;
  86967. /**
  86968. * Defines the direction of the wind in the plane (X, Z).
  86969. */
  86970. windDirection: BABYLON.Vector2;
  86971. /**
  86972. * Defines the height of the waves.
  86973. */
  86974. waveHeight: number;
  86975. /**
  86976. * Defines the bump height related to the bump map.
  86977. */
  86978. bumpHeight: number;
  86979. /**
  86980. * Defines wether or not: to add a smaller moving bump to less steady waves.
  86981. */
  86982. private _bumpSuperimpose;
  86983. bumpSuperimpose: boolean;
  86984. /**
  86985. * Defines wether or not color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  86986. */
  86987. private _fresnelSeparate;
  86988. fresnelSeparate: boolean;
  86989. /**
  86990. * Defines wether or not bump Wwves modify the reflection.
  86991. */
  86992. private _bumpAffectsReflection;
  86993. bumpAffectsReflection: boolean;
  86994. /**
  86995. * Defines the water color blended with the refraction (near).
  86996. */
  86997. waterColor: BABYLON.Color3;
  86998. /**
  86999. * Defines the blend factor related to the water color.
  87000. */
  87001. colorBlendFactor: number;
  87002. /**
  87003. * Defines the water color blended with the reflection (far).
  87004. */
  87005. waterColor2: BABYLON.Color3;
  87006. /**
  87007. * Defines the blend factor related to the water color (reflection, far).
  87008. */
  87009. colorBlendFactor2: number;
  87010. /**
  87011. * Defines the maximum length of a wave.
  87012. */
  87013. waveLength: number;
  87014. /**
  87015. * Defines the waves speed.
  87016. */
  87017. waveSpeed: number;
  87018. /**
  87019. * Defines the number of times waves are repeated. This is typically used to adjust waves count according to the ground's size where the material is applied on.
  87020. */
  87021. waveCount: number;
  87022. /**
  87023. * Sets or gets whether or not automatic clipping should be enabled or not. Setting to true will save performances and
  87024. * will avoid calculating useless pixels in the pixel shader of the water material.
  87025. */
  87026. disableClipPlane: boolean;
  87027. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  87028. private _mesh;
  87029. private _refractionRTT;
  87030. private _reflectionRTT;
  87031. private _reflectionTransform;
  87032. private _lastTime;
  87033. private _lastDeltaTime;
  87034. private _useLogarithmicDepth;
  87035. private _waitingRenderList;
  87036. private _imageProcessingConfiguration;
  87037. private _imageProcessingObserver;
  87038. /**
  87039. * Gets a boolean indicating that current material needs to register RTT
  87040. */
  87041. get hasRenderTargetTextures(): boolean;
  87042. /**
  87043. * Constructor
  87044. */
  87045. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  87046. get useLogarithmicDepth(): boolean;
  87047. set useLogarithmicDepth(value: boolean);
  87048. get refractionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  87049. get reflectionTexture(): BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  87050. addToRenderList(node: any): void;
  87051. enableRenderTargets(enable: boolean): void;
  87052. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  87053. get renderTargetsEnabled(): boolean;
  87054. needAlphaBlending(): boolean;
  87055. needAlphaTesting(): boolean;
  87056. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  87057. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  87058. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  87059. private _createRenderTargets;
  87060. getAnimatables(): BABYLON.IAnimatable[];
  87061. getActiveTextures(): BABYLON.BaseTexture[];
  87062. hasTexture(texture: BABYLON.BaseTexture): boolean;
  87063. dispose(forceDisposeEffect?: boolean): void;
  87064. clone(name: string): WaterMaterial;
  87065. serialize(): any;
  87066. getClassName(): string;
  87067. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  87068. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  87069. }
  87070. }
  87071. declare module BABYLON {
  87072. /** @hidden */
  87073. export var asciiartPixelShader: {
  87074. name: string;
  87075. shader: string;
  87076. };
  87077. }
  87078. declare module BABYLON {
  87079. /**
  87080. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  87081. *
  87082. * It basically takes care rendering the font front the given font size to a texture.
  87083. * This is used later on in the postprocess.
  87084. */
  87085. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  87086. private _font;
  87087. private _text;
  87088. private _charSize;
  87089. /**
  87090. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  87091. */
  87092. get charSize(): number;
  87093. /**
  87094. * Create a new instance of the Ascii Art FontTexture class
  87095. * @param name the name of the texture
  87096. * @param font the font to use, use the W3C CSS notation
  87097. * @param text the caracter set to use in the rendering.
  87098. * @param scene the scene that owns the texture
  87099. */
  87100. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  87101. /**
  87102. * Gets the max char width of a font.
  87103. * @param font the font to use, use the W3C CSS notation
  87104. * @return the max char width
  87105. */
  87106. private getFontWidth;
  87107. /**
  87108. * Gets the max char height of a font.
  87109. * @param font the font to use, use the W3C CSS notation
  87110. * @return the max char height
  87111. */
  87112. private getFontHeight;
  87113. /**
  87114. * Clones the current AsciiArtTexture.
  87115. * @return the clone of the texture.
  87116. */
  87117. clone(): AsciiArtFontTexture;
  87118. /**
  87119. * Parses a json object representing the texture and returns an instance of it.
  87120. * @param source the source JSON representation
  87121. * @param scene the scene to create the texture for
  87122. * @return the parsed texture
  87123. */
  87124. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  87125. }
  87126. /**
  87127. * Option available in the Ascii Art Post Process.
  87128. */
  87129. export interface IAsciiArtPostProcessOptions {
  87130. /**
  87131. * The font to use following the w3c font definition.
  87132. */
  87133. font?: string;
  87134. /**
  87135. * The character set to use in the postprocess.
  87136. */
  87137. characterSet?: string;
  87138. /**
  87139. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  87140. * This number is defined between 0 and 1;
  87141. */
  87142. mixToTile?: number;
  87143. /**
  87144. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  87145. * This number is defined between 0 and 1;
  87146. */
  87147. mixToNormal?: number;
  87148. }
  87149. /**
  87150. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  87151. *
  87152. * Simmply add it to your scene and let the nerd that lives in you have fun.
  87153. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  87154. */
  87155. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  87156. /**
  87157. * The font texture used to render the char in the post process.
  87158. */
  87159. private _asciiArtFontTexture;
  87160. /**
  87161. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  87162. * This number is defined between 0 and 1;
  87163. */
  87164. mixToTile: number;
  87165. /**
  87166. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  87167. * This number is defined between 0 and 1;
  87168. */
  87169. mixToNormal: number;
  87170. /**
  87171. * Instantiates a new Ascii Art Post Process.
  87172. * @param name the name to give to the postprocess
  87173. * @camera the camera to apply the post process to.
  87174. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  87175. */
  87176. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  87177. }
  87178. }
  87179. declare module BABYLON {
  87180. /** @hidden */
  87181. export var digitalrainPixelShader: {
  87182. name: string;
  87183. shader: string;
  87184. };
  87185. }
  87186. declare module BABYLON {
  87187. /**
  87188. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  87189. *
  87190. * It basically takes care rendering the font front the given font size to a texture.
  87191. * This is used later on in the postprocess.
  87192. */
  87193. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  87194. private _font;
  87195. private _text;
  87196. private _charSize;
  87197. /**
  87198. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  87199. */
  87200. get charSize(): number;
  87201. /**
  87202. * Create a new instance of the Digital Rain FontTexture class
  87203. * @param name the name of the texture
  87204. * @param font the font to use, use the W3C CSS notation
  87205. * @param text the caracter set to use in the rendering.
  87206. * @param scene the scene that owns the texture
  87207. */
  87208. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  87209. /**
  87210. * Gets the max char width of a font.
  87211. * @param font the font to use, use the W3C CSS notation
  87212. * @return the max char width
  87213. */
  87214. private getFontWidth;
  87215. /**
  87216. * Gets the max char height of a font.
  87217. * @param font the font to use, use the W3C CSS notation
  87218. * @return the max char height
  87219. */
  87220. private getFontHeight;
  87221. /**
  87222. * Clones the current DigitalRainFontTexture.
  87223. * @return the clone of the texture.
  87224. */
  87225. clone(): DigitalRainFontTexture;
  87226. /**
  87227. * Parses a json object representing the texture and returns an instance of it.
  87228. * @param source the source JSON representation
  87229. * @param scene the scene to create the texture for
  87230. * @return the parsed texture
  87231. */
  87232. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  87233. }
  87234. /**
  87235. * Option available in the Digital Rain Post Process.
  87236. */
  87237. export interface IDigitalRainPostProcessOptions {
  87238. /**
  87239. * The font to use following the w3c font definition.
  87240. */
  87241. font?: string;
  87242. /**
  87243. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  87244. * This number is defined between 0 and 1;
  87245. */
  87246. mixToTile?: number;
  87247. /**
  87248. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  87249. * This number is defined between 0 and 1;
  87250. */
  87251. mixToNormal?: number;
  87252. }
  87253. /**
  87254. * DigitalRainPostProcess helps rendering everithing in digital rain.
  87255. *
  87256. * Simmply add it to your scene and let the nerd that lives in you have fun.
  87257. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  87258. */
  87259. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  87260. /**
  87261. * The font texture used to render the char in the post process.
  87262. */
  87263. private _digitalRainFontTexture;
  87264. /**
  87265. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  87266. * This number is defined between 0 and 1;
  87267. */
  87268. mixToTile: number;
  87269. /**
  87270. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  87271. * This number is defined between 0 and 1;
  87272. */
  87273. mixToNormal: number;
  87274. /**
  87275. * Instantiates a new Digital Rain Post Process.
  87276. * @param name the name to give to the postprocess
  87277. * @camera the camera to apply the post process to.
  87278. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  87279. */
  87280. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  87281. }
  87282. }
  87283. declare module BABYLON {
  87284. /** @hidden */
  87285. export var brickProceduralTexturePixelShader: {
  87286. name: string;
  87287. shader: string;
  87288. };
  87289. }
  87290. declare module BABYLON {
  87291. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  87292. private _numberOfBricksHeight;
  87293. private _numberOfBricksWidth;
  87294. private _jointColor;
  87295. private _brickColor;
  87296. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87297. updateShaderUniforms(): void;
  87298. get numberOfBricksHeight(): number;
  87299. set numberOfBricksHeight(value: number);
  87300. get numberOfBricksWidth(): number;
  87301. set numberOfBricksWidth(value: number);
  87302. get jointColor(): BABYLON.Color3;
  87303. set jointColor(value: BABYLON.Color3);
  87304. get brickColor(): BABYLON.Color3;
  87305. set brickColor(value: BABYLON.Color3);
  87306. /**
  87307. * Serializes this brick procedural texture
  87308. * @returns a serialized brick procedural texture object
  87309. */
  87310. serialize(): any;
  87311. /**
  87312. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  87313. * @param parsedTexture defines parsed texture data
  87314. * @param scene defines the current scene
  87315. * @param rootUrl defines the root URL containing brick procedural texture information
  87316. * @returns a parsed Brick Procedural BABYLON.Texture
  87317. */
  87318. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  87319. }
  87320. }
  87321. declare module BABYLON {
  87322. /** @hidden */
  87323. export var cloudProceduralTexturePixelShader: {
  87324. name: string;
  87325. shader: string;
  87326. };
  87327. }
  87328. declare module BABYLON {
  87329. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  87330. private _skyColor;
  87331. private _cloudColor;
  87332. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87333. updateShaderUniforms(): void;
  87334. get skyColor(): BABYLON.Color4;
  87335. set skyColor(value: BABYLON.Color4);
  87336. get cloudColor(): BABYLON.Color4;
  87337. set cloudColor(value: BABYLON.Color4);
  87338. /**
  87339. * Serializes this cloud procedural texture
  87340. * @returns a serialized cloud procedural texture object
  87341. */
  87342. serialize(): any;
  87343. /**
  87344. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  87345. * @param parsedTexture defines parsed texture data
  87346. * @param scene defines the current scene
  87347. * @param rootUrl defines the root URL containing cloud procedural texture information
  87348. * @returns a parsed Cloud Procedural BABYLON.Texture
  87349. */
  87350. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  87351. }
  87352. }
  87353. declare module BABYLON {
  87354. /** @hidden */
  87355. export var fireProceduralTexturePixelShader: {
  87356. name: string;
  87357. shader: string;
  87358. };
  87359. }
  87360. declare module BABYLON {
  87361. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  87362. private _time;
  87363. private _speed;
  87364. private _autoGenerateTime;
  87365. private _fireColors;
  87366. private _alphaThreshold;
  87367. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87368. updateShaderUniforms(): void;
  87369. render(useCameraPostProcess?: boolean): void;
  87370. static get PurpleFireColors(): BABYLON.Color3[];
  87371. static get GreenFireColors(): BABYLON.Color3[];
  87372. static get RedFireColors(): BABYLON.Color3[];
  87373. static get BlueFireColors(): BABYLON.Color3[];
  87374. get autoGenerateTime(): boolean;
  87375. set autoGenerateTime(value: boolean);
  87376. get fireColors(): BABYLON.Color3[];
  87377. set fireColors(value: BABYLON.Color3[]);
  87378. get time(): number;
  87379. set time(value: number);
  87380. get speed(): BABYLON.Vector2;
  87381. set speed(value: BABYLON.Vector2);
  87382. get alphaThreshold(): number;
  87383. set alphaThreshold(value: number);
  87384. /**
  87385. * Serializes this fire procedural texture
  87386. * @returns a serialized fire procedural texture object
  87387. */
  87388. serialize(): any;
  87389. /**
  87390. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  87391. * @param parsedTexture defines parsed texture data
  87392. * @param scene defines the current scene
  87393. * @param rootUrl defines the root URL containing fire procedural texture information
  87394. * @returns a parsed Fire Procedural BABYLON.Texture
  87395. */
  87396. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  87397. }
  87398. }
  87399. declare module BABYLON {
  87400. /** @hidden */
  87401. export var grassProceduralTexturePixelShader: {
  87402. name: string;
  87403. shader: string;
  87404. };
  87405. }
  87406. declare module BABYLON {
  87407. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  87408. private _grassColors;
  87409. private _groundColor;
  87410. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87411. updateShaderUniforms(): void;
  87412. get grassColors(): BABYLON.Color3[];
  87413. set grassColors(value: BABYLON.Color3[]);
  87414. get groundColor(): BABYLON.Color3;
  87415. set groundColor(value: BABYLON.Color3);
  87416. /**
  87417. * Serializes this grass procedural texture
  87418. * @returns a serialized grass procedural texture object
  87419. */
  87420. serialize(): any;
  87421. /**
  87422. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  87423. * @param parsedTexture defines parsed texture data
  87424. * @param scene defines the current scene
  87425. * @param rootUrl defines the root URL containing grass procedural texture information
  87426. * @returns a parsed Grass Procedural BABYLON.Texture
  87427. */
  87428. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  87429. }
  87430. }
  87431. declare module BABYLON {
  87432. /** @hidden */
  87433. export var marbleProceduralTexturePixelShader: {
  87434. name: string;
  87435. shader: string;
  87436. };
  87437. }
  87438. declare module BABYLON {
  87439. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  87440. private _numberOfTilesHeight;
  87441. private _numberOfTilesWidth;
  87442. private _amplitude;
  87443. private _jointColor;
  87444. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87445. updateShaderUniforms(): void;
  87446. get numberOfTilesHeight(): number;
  87447. set numberOfTilesHeight(value: number);
  87448. get amplitude(): number;
  87449. set amplitude(value: number);
  87450. get numberOfTilesWidth(): number;
  87451. set numberOfTilesWidth(value: number);
  87452. get jointColor(): BABYLON.Color3;
  87453. set jointColor(value: BABYLON.Color3);
  87454. /**
  87455. * Serializes this marble procedural texture
  87456. * @returns a serialized marble procedural texture object
  87457. */
  87458. serialize(): any;
  87459. /**
  87460. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  87461. * @param parsedTexture defines parsed texture data
  87462. * @param scene defines the current scene
  87463. * @param rootUrl defines the root URL containing marble procedural texture information
  87464. * @returns a parsed Marble Procedural BABYLON.Texture
  87465. */
  87466. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  87467. }
  87468. }
  87469. declare module BABYLON {
  87470. /** @hidden */
  87471. export var normalMapProceduralTexturePixelShader: {
  87472. name: string;
  87473. shader: string;
  87474. };
  87475. }
  87476. declare module BABYLON {
  87477. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  87478. private _baseTexture;
  87479. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87480. updateShaderUniforms(): void;
  87481. render(useCameraPostProcess?: boolean): void;
  87482. resize(size: any, generateMipMaps: any): void;
  87483. get baseTexture(): BABYLON.Texture;
  87484. set baseTexture(texture: BABYLON.Texture);
  87485. /**
  87486. * Serializes this normal map procedural texture
  87487. * @returns a serialized normal map procedural texture object
  87488. */
  87489. serialize(): any;
  87490. /**
  87491. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  87492. * @param parsedTexture defines parsed texture data
  87493. * @param scene defines the current scene
  87494. * @param rootUrl defines the root URL containing normal map procedural texture information
  87495. * @returns a parsed Normal Map Procedural BABYLON.Texture
  87496. */
  87497. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  87498. }
  87499. }
  87500. declare module BABYLON {
  87501. /** @hidden */
  87502. export var perlinNoiseProceduralTexturePixelShader: {
  87503. name: string;
  87504. shader: string;
  87505. };
  87506. }
  87507. declare module BABYLON {
  87508. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  87509. time: number;
  87510. timeScale: number;
  87511. translationSpeed: number;
  87512. private _currentTranslation;
  87513. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87514. updateShaderUniforms(): void;
  87515. render(useCameraPostProcess?: boolean): void;
  87516. resize(size: any, generateMipMaps: any): void;
  87517. /**
  87518. * Serializes this perlin noise procedural texture
  87519. * @returns a serialized perlin noise procedural texture object
  87520. */
  87521. serialize(): any;
  87522. /**
  87523. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  87524. * @param parsedTexture defines parsed texture data
  87525. * @param scene defines the current scene
  87526. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  87527. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  87528. */
  87529. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  87530. }
  87531. }
  87532. declare module BABYLON {
  87533. /** @hidden */
  87534. export var roadProceduralTexturePixelShader: {
  87535. name: string;
  87536. shader: string;
  87537. };
  87538. }
  87539. declare module BABYLON {
  87540. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  87541. private _roadColor;
  87542. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87543. updateShaderUniforms(): void;
  87544. get roadColor(): BABYLON.Color3;
  87545. set roadColor(value: BABYLON.Color3);
  87546. /**
  87547. * Serializes this road procedural texture
  87548. * @returns a serialized road procedural texture object
  87549. */
  87550. serialize(): any;
  87551. /**
  87552. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  87553. * @param parsedTexture defines parsed texture data
  87554. * @param scene defines the current scene
  87555. * @param rootUrl defines the root URL containing road procedural texture information
  87556. * @returns a parsed Road Procedural BABYLON.Texture
  87557. */
  87558. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  87559. }
  87560. }
  87561. declare module BABYLON {
  87562. /** @hidden */
  87563. export var starfieldProceduralTexturePixelShader: {
  87564. name: string;
  87565. shader: string;
  87566. };
  87567. }
  87568. declare module BABYLON {
  87569. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  87570. private _time;
  87571. private _alpha;
  87572. private _beta;
  87573. private _zoom;
  87574. private _formuparam;
  87575. private _stepsize;
  87576. private _tile;
  87577. private _brightness;
  87578. private _darkmatter;
  87579. private _distfading;
  87580. private _saturation;
  87581. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87582. updateShaderUniforms(): void;
  87583. get time(): number;
  87584. set time(value: number);
  87585. get alpha(): number;
  87586. set alpha(value: number);
  87587. get beta(): number;
  87588. set beta(value: number);
  87589. get formuparam(): number;
  87590. set formuparam(value: number);
  87591. get stepsize(): number;
  87592. set stepsize(value: number);
  87593. get zoom(): number;
  87594. set zoom(value: number);
  87595. get tile(): number;
  87596. set tile(value: number);
  87597. get brightness(): number;
  87598. set brightness(value: number);
  87599. get darkmatter(): number;
  87600. set darkmatter(value: number);
  87601. get distfading(): number;
  87602. set distfading(value: number);
  87603. get saturation(): number;
  87604. set saturation(value: number);
  87605. /**
  87606. * Serializes this starfield procedural texture
  87607. * @returns a serialized starfield procedural texture object
  87608. */
  87609. serialize(): any;
  87610. /**
  87611. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  87612. * @param parsedTexture defines parsed texture data
  87613. * @param scene defines the current scene
  87614. * @param rootUrl defines the root URL containing startfield procedural texture information
  87615. * @returns a parsed Starfield Procedural BABYLON.Texture
  87616. */
  87617. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  87618. }
  87619. }
  87620. declare module BABYLON {
  87621. /** @hidden */
  87622. export var woodProceduralTexturePixelShader: {
  87623. name: string;
  87624. shader: string;
  87625. };
  87626. }
  87627. declare module BABYLON {
  87628. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  87629. private _ampScale;
  87630. private _woodColor;
  87631. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  87632. updateShaderUniforms(): void;
  87633. get ampScale(): number;
  87634. set ampScale(value: number);
  87635. get woodColor(): BABYLON.Color3;
  87636. set woodColor(value: BABYLON.Color3);
  87637. /**
  87638. * Serializes this wood procedural texture
  87639. * @returns a serialized wood procedural texture object
  87640. */
  87641. serialize(): any;
  87642. /**
  87643. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  87644. * @param parsedTexture defines parsed texture data
  87645. * @param scene defines the current scene
  87646. * @param rootUrl defines the root URL containing wood procedural texture information
  87647. * @returns a parsed Wood Procedural BABYLON.Texture
  87648. */
  87649. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  87650. }
  87651. }